Home Insert Histogram into Line Chart
Post
Cancel

Insert Histogram into Line Chart

How To Insert Histogram into Line Chart


Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
% insert multiple histograms into line chart
figure;
ax0 = axes('position',[0.1,0.1,0.8,0.8]); 
ax1 = axes('position',[0.175,0.47,0.2,0.15]); 
ax2 = axes('position',[0.175,0.27,0.2,0.15]); 
ax3 = axes('position',[0.425,0.47,0.2,0.15]); 
ax4 = axes('position',[0.425,0.27,0.2,0.15]); 
ax5 = axes('position',[0.675,0.47,0.2,0.15]); 
ax6 = axes('position',[0.675,0.27,0.2,0.15]); 
axes(ax0)
A = importdata('vg_calibration.csv'); % line chart data
x = A.data(:,1);
y = A.data(:,2);
plot(x,y,'d-','LineWidth',2);
% xlim([-80 140]);
% ylim([0.7 0.85]);
xlabel({'Tempreture (\circC)'});
ylabel({'Voltage (V)'});
legend('Gate voltage varies with tempreture','FontName','Times New Roman','FontSize',10);
legend('boxoff');
grid on
hold on;
text(-20,0.805, ...
    {'@T=-40\circC'}, ...
     'FontName','Times New Roman','FontSize',10,'FontWeight','Bold');
text(25,0.805, ...
    {'@T=30\circC'}, ...
     'FontName','Times New Roman','FontSize',10,'FontWeight','Bold');
text(67,0.805, ...
    {'@T=100\circC'}, ...
     'FontName','Times New Roman','FontSize',10,'FontWeight','Bold');

N = 2000;
axes(ax1)
A = importdata('Rmos_calibration.csv'); %histogram data (Monte Cralo results)
MC = A.data(:,7) * 1e-3;
% N = length(MC);
nbins = 8;
h1 = histogram(MC,nbins);
h1.FaceColor = 'c';
hold on;
x = linspace(min(MC)*0.9,max(MC)*1.001,100);
[mu,sigma]=normfit(MC);
f = exp(-(x-mu).^2./(2*sigma^2))./(sigma*sqrt(2*pi)); %probability density function (pdf)
y=f/max(f)*max(h1.Values);
plot(x,y,'LineWidth',1.5)
% xlabel({'R_{ON} (K\Omega)'});
% ylabel({'Count'});
set(gca,'color','none');
text(420,640, ...
    {strcat('\mu=', num2str(mu,'%1.2f')); ...
     strcat('\sigma=', num2str(sigma,'%1.2f')); ...
     strcat('n=', num2str(N,'%1.0f'))}, ...
     'FontName','Times New Roman','FontSize',8);

axes(ax2)
A = importdata('Rmos_calibration.csv');
MC = A.data(:,1) * 1e-3;
% N = length(MC);
nbins = 8;
h1 = histogram(MC,nbins);
h1.FaceColor = 'g';
hold on;
x = linspace(min(MC),max(MC)*1.001,100);
[mu,sigma]=normfit(MC);
f = exp(-(x-mu).^2./(2*sigma^2))./(sigma*sqrt(2*pi)); %probability density function (pdf)
y=f/max(f)*max(h1.Values);
plot(x,y,'LineWidth',1.5)
xlabel({'R_{ON} (K\Omega)'});
% ylabel({'Count'});
set(gca,'color','none');
text(min(MC),1300, ...
    {strcat('\mu=', num2str(mu,'%1.2f')); ...
     strcat('\sigma=', num2str(sigma,'%1.2f')); ...
     strcat('n=', num2str(N,'%1.0f'))}, ...
     'FontName','Times New Roman','FontSize',8);

axes(ax3)
A = importdata('Rmos_calibration.csv');
MC = A.data(1:1982,9) * 1e-3;
% N = length(MC);
nbins = 8;
h3 = histogram(MC,nbins);
h3.FaceColor = 'c';
hold on;
x = linspace(min(MC)*0.9,max(MC)*1.001,100);
[mu,sigma]=normfit(MC);
f = exp(-(x-mu).^2./(2*sigma^2))./(sigma*sqrt(2*pi)); %probability density function (pdf)
y=f/max(f)*max(h3.Values);
plot(x,y,'LineWidth',1.5)
ylim([0, 1000]);
% xlabel({'R_{ON} (K\Omega)'});
% ylabel({'Count'});
set(gca,'color','none');
text(350,640, ...
    {strcat('\mu=', num2str(mu,'%1.2f')); ...
     strcat('\sigma=', num2str(sigma,'%1.2f')); ...
     strcat('n=', num2str(N,'%1.0f'))}, ...
     'FontName','Times New Roman','FontSize',8);

axes(ax4)
A = importdata('Rmos_calibration.csv');
MC = A.data(1:1982,3) * 1e-3;
% N = length(MC);
nbins = 8;
h4 = histogram(MC,nbins);
h4.FaceColor = 'g';
hold on;
x = linspace(min(MC),max(MC)*1.001,100);
[mu,sigma]=normfit(MC);
f = exp(-(x-mu).^2./(2*sigma^2))./(sigma*sqrt(2*pi)); %probability density function (pdf)
y=f/max(f)*max(h4.Values);
plot(x,y,'LineWidth',1.5)
xlabel({'R_{ON} (K\Omega)'});
% ylabel({'Count'});
set(gca,'color','none');
text(min(MC),1300, ...
    {strcat('\mu=', num2str(mu,'%1.2f')); ...
     strcat('\sigma=', num2str(sigma,'%1.2f')); ...
     strcat('n=', num2str(N,'%1.0f'))}, ...
     'FontName','Times New Roman','FontSize',8);

axes(ax5)
A = importdata('Rmos_calibration.csv');
MC = A.data(1:1969,11) * 1e-3;
% N = length(MC);
nbins = 8;
h5 = histogram(MC,nbins);
h5.FaceColor = 'c';
legend('MOS resistance distribution w/o calibration','FontName','Times New Roman','FontSize',10);
legend('boxoff');
hold on;
x = linspace(min(MC)*0.9,max(MC)*1.001,100);
[mu,sigma]=normfit(MC);
f = exp(-(x-mu).^2./(2*sigma^2))./(sigma*sqrt(2*pi)); %probability density function (pdf)
y=f/max(f)*max(h5.Values);
plot(x,y,'LineWidth',1.5)
xlim([150 420]);
ylim([0, 1000]);
% xlabel({'R_{ON} (K\Omega)'});
% ylabel({'Count'});
set(gca,'color','none');
text(300,640, ...
    {strcat('\mu=', num2str(mu,'%1.2f')); ...
     strcat('\sigma=', num2str(sigma,'%1.2f')); ...
     strcat('n=', num2str(N,'%1.0f'))}, ...
     'FontName','Times New Roman','FontSize',8);

axes(ax6)
A = importdata('Rmos_calibration.csv');
MC = A.data(1:1969,5) * 1e-3;
% N = length(MC);
nbins = 8;
h6 = histogram(MC,nbins);
h6.FaceColor = 'g';
legend('MOS resistance distribution w/ calibration','FontName','Times New Roman','FontSize',10);
legend('boxoff');
hold on;
x = linspace(min(MC),max(MC)*1.001,100);
[mu,sigma]=normfit(MC);
f = exp(-(x-mu).^2./(2*sigma^2))./(sigma*sqrt(2*pi)); %probability density function (pdf)
y=f/max(f)*max(h6.Values);
plot(x,y,'LineWidth',1.5)
ylim([0, 2000])
xlabel({'R_{ON} (K\Omega)'});
% ylabel({'Count'});
set(gca,'color','none');
text(min(MC),1300, ...
    {strcat('\mu=', num2str(mu,'%1.2f')); ...
     strcat('\sigma=', num2str(sigma,'%1.2f')); ...
     strcat('n=', num2str(N,'%1.0f'))}, ...
     'FontName','Times New Roman','FontSize',8);

% axes(ax0)
% set(gca,'color','none');
% legend([h5],'MOS resistance distribution w/o calibration');
% legend([h6],'MOS resistance distribution w/ calibration');
% legend('boxoff')
% legend([h3 h4],...
%      {'MOS resistance distribution w/o calibration',...
%       'MOS resistance distribution w/ calibration'},...
%       'Location','northoutside')

Need modify the legends manually.

Result

histogram Histograms inserted into line chart

This post is licensed under CC BY 4.0 by the author.

Statistical analysis -- Boxplot

Import MC results from Cadence and Plot using Matlab