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

看板MATLAB作者 (( ・ω・`))時間5年前 (2018/12/03 15:06), 編輯推噓0(005)
留言5則, 2人參與, 5年前最新討論串1/1
如題 先附上程式碼 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要怎麼弄才會對到圖上當兩條線呢? 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 27.242.4.86 ※ 文章網址: https://www.ptt.cc/bbs/MATLAB/M.1543820789.A.136.html

12/03 19:40, 5年前 , 1F
查查 hold on 應該有用
12/03 19:40, 1F

12/03 21:53, 5年前 , 2F
her01 = errorbar(x1,y1,err1,'-o'); hold on;
12/03 21:53, 2F

12/03 21:53, 5年前 , 3F
her02 = errorbar(x2,y2,err2,'-diamond');
12/03 21:53, 3F

12/03 21:53, 5年前 , 4F
legend([her01,her02],'Group1','Group2')
12/03 21:53, 4F

12/03 21:57, 5年前 , 5F
查查legend裡的例子
12/03 21:57, 5F
文章代碼(AID): #1S1DNr4s (MATLAB)