看板 MATLAB 關於我們 聯絡資訊
如題 先附上程式碼 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
book5601: 查查 hold on 應該有用 12/03 19:40
sblk: her01 = errorbar(x1,y1,err1,'-o'); hold on; 12/03 21:53
sblk: her02 = errorbar(x2,y2,err2,'-diamond'); 12/03 21:53
sblk: legend([her01,her02],'Group1','Group2') 12/03 21:53
sblk: 查查legend裡的例子 12/03 21:57