choose the limit of two y axes
3 views (last 30 days)
Show older comments
I would like to do a graph with two y axes. I have found this. I have two questions that have no answer here:
1.how to have the two axes simply in black and not in blu and orange (very strange default choice).
2.How can I choose the limit of each axes? I usually use ylim([]), but now how can I choose the right or left axis?
Thank you
0 Comments
Answers (1)
KSSV
on 3 Aug 2022
Edited: KSSV
on 3 Aug 2022
x = linspace(0,25);
y = sin(x/2);
yyaxis left ;
plot(x,y,'k');
ax(1) = gca ;
r = x.^2/2;
yyaxis right
plot(x,r);
ax(2) = gca ;
% change axis colors
ax(1).YColor = 'g' ;
ax(2).YColor = 'm' ;
ax(1).YLim % set your value here
ax(2).YLim % set your value here
4 Comments
See Also
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!