Why colororder function does not work with ylim?
이전 댓글 표시
Hello everybody,
I have a problem with my Matlab code. I would like to make a 2D plot with two y-axis with different axis limits. The created a proper function for the colors and I used them using the colororder function. However, it does not work with I wrote ylim function.
Do you know why?
I hope you can help me :)
Here my code:
figure
hold on
fontsize(12,"points");
x=[0,6,24,48,72];
xlabel('Time [h]');
yyaxis left
ylabel('Sugars [g/L]');
Glu1=[20.68,23.35,5.41,0.54,0];
errGlu1=[0.77,2.07,0.69,0.12,0];
Fru1=[5.19,5.55,2.07,0.93,0.78];
ylim([0 25])
yyaxis right
ylabel('Products [g/L]');
Et1=[0,0.16,7.51,9.37,8.20];
errEt1=[0,0.02,0.34,0.71,0.42];
Gly1=[0,0.2,0.3,0.36,0.37];
errGly1=[0,0.01,0.03,0.03,0.04];
ylim([0 12]);
plot(x,Glu1,'^-','LineWidth',2);
plot(x,Fru1,'^-','LineWidth',2);
plot(x,Et1,'v-', 'LineWidth',2);
plot(x,Gly1,'v-','LineWidth',2);
errorbar(x,Glu1,errGlu1,'LineStyle','none','Color','black');
errorbar(x,Fru1,errFru1,'LineStyle','none','Color','black');
errorbar(x,Et1,errEt1,'LineStyle','none','Color','black');
errorbar(x,Gly1,errGly1,'LineStyle','none','Color','black');
newcolors = [0.83 0.14 0.14
1.00 0.54 0.00
0.47 0.25 0.80
0.25 0.80 0.54];
colororder(newcolors)
hold off
댓글 수: 4
Dyuman Joshi
2023년 10월 9일
There is an undefined variable in your code, see above.
Also, specify which plots you want to draw with the left y-axis and which ones with the right y-axis.
Ludovica Varriale
2023년 10월 9일
Dyuman Joshi
2023년 10월 9일
Do you want to colors the individual plots according to the newcolors array?
If not, please specify the output that you want to obtain.
Ludovica Varriale
2023년 10월 9일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Errorbars에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



