[討論] 多條曲線點 errorbar詢問

作者: amateuruser (U文心得大師)   2018-12-03 15:06:24
如題
先附上程式碼
clear;
x1 = [1,2,3];
y1= [1.1,1.2,1.5];
x2 = [1,2,3];
y2= [1.41,1.42,1.45];
err1 = [0.016,0.05,0.10];
err2 = [0.026,0.053,0.069];
errorbar(x1,y1,err1,'-o');
errorbar(x2,y2,err2,'-diamond');
grid % grid on plot
axis([1 3 1 2.5]); % axis: x between 1 and 40, y between 0 to 10
set(gca, 'xtick', [1 2 3])
set(gca,'xticklabel', {'condition1','condition2','condition3'})% x axis tick value
set(gca,'ytick', 0:1:4); % y axis tick value
set(gca, 'ytick', [1,1.5,2,2.5]);
set(gca,'FontSize',15);
title('pH measurement Design 1 & Design 2')
xlabel('Conditions', 'FontSize', 15);
ylabel('Output, 'FontSize', 15);
想問一下版上的大大
為什麼當單一組曲線 一組errorbar 可以繪製
但是同時兩組errorbar放在一塊卻只出現一條線呢?
再者 legend要怎麼弄才會對到圖上當兩條線呢?
謝謝
作者: book5601 (蒼瀾野獸)   2018-12-03 19:40:00
查查 hold on 應該有用
作者: sblk (Time)   2018-12-03 21:53:00
her01 = errorbar(x1,y1,err1,'-o'); hold on;her02 = errorbar(x2,y2,err2,'-diamond');legend([her01,her02],'Group1','Group2')查查legend裡的例子

Links booklink

Contact Us: admin [ a t ] ucptt.com