How to replicate a graph from some data collected using webplot digitiser
3 次查看(过去 30 天)
显示 更早的评论
I have two .csv files I made from webplot digitiser and I want to replicate this graph
the csv files are called 'Strength_Mpa' and 'Grainsize_nm' repectively.
The data is in tabular for as follows
Strength_Mpa Grainsize_nm
20 2880 25 90
20 3280 1200 120
20 3990 1300 150
1200 2000 1350 310
1200 2990 1400 450
1200 3500 1500 790
1300 2200
1300 2700
1300 3280
1400 1390
1400 1770
1400 2150
I have been using this with no success
x = [20,1200,1300,1400]'
y = [3280,2990,2700,1770]'
err = [((3990-2880)/2),((3500-2000)/2),((3280-2200)/2),((2150-1390)/2)]
errorbar(x,y,err)
Which does not output as gracefull of a graph as I am looking for.
Please help me figure out how to properly use the error bar function and fit a curve to the graph alongside haveing three axes.
Many thanks
Alex
2 个评论
Dyuman Joshi
2023-11-10
编辑:Dyuman Joshi
2023-11-10
On which values do you want to get the error bars?
And what should be the relative sizes of the error bars?
Note that sizes includes the length above and below the curve, as the error bars shown in the sample figure are unequal in lengths across the curve.
采纳的回答
Voss
2023-11-10
编辑:Voss
2023-11-10
Strength_Mpa = [
20 2880
20 3280
20 3990
1200 2000
1200 2990
1200 3500
1300 2200
1300 2700
1300 3280
1400 1390
1400 1770
1400 2150 ];
Grainsize_nm = [
25 90
1200 120
1300 150
1350 310
1400 450
1500 790 ];
y = reshape(Strength_Mpa,3,[]);
x = y(1,1:end/2);
y_min = y(1,end/2+1:end);
y_mid = y(2,end/2+1:end);
y_max = y(3,end/2+1:end);
yyaxis left
errorbar(x,y_mid,y_mid-y_min,y_max-y_mid)
ylim([0 4500])
ylabel('Strength [MPa]')
hold on
yyaxis right
plot(Grainsize_nm(:,1),Grainsize_nm(:,2),'-ro','MarkerFaceColor','r')
ylim([0 900])
ylabel('Grain size [nm]')
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Bar Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!