Two y axes in subplot
Ältere Kommentare anzeigen
Hi all,
I am trying to get a second y axis into an subplot.
figure
handle1 = subplot(3,3,1)
handle2 = axes('YAxisLocation','right','Color','none', ...
'XGrid','off','YGrid','off','Box','off');
This creates an additional axis object on the edge of the whole figure and not on the edge of the subplot. Setting the parent property of axes to handle1 is not possible. Calling axes(handle1) does not help. plotyy() works but has a strange behavior in a certain way. Therefore I want to use a own axis. I have not figured out what plotyy does to solve this problem.
Do you have an idea?
Thanx, Milan
Akzeptierte Antwort
Weitere Antworten (2)
Valentino
am 14 Jul. 2016
yyaxis(ax(1),'left')
plot(ax(1),x1,y1,'Color', Color_left)
set(ax(1),'ylim', [0,300])
set(ax(1),'YColor',Color_left);
ylabel(ax(1),('Label left '}))
yyaxis(ax(1),'right')
plot(ax(1),x2,y2,'Color', Color_right)
set(ax(1),'ylim', [-10,15])
set(ax(1),'YColor',Color_right);
ylabel(ax(1),({'Label right'}))
As yyaxis is new introduced in 2016a i figured this might help somebody.
1 Kommentar
Nachiket Wadwankar
am 19 Okt. 2018
Thanks for this solution. This is exactly what I was looking for.
Ghulam Murtaza
am 7 Mai 2014
0 Stimmen
Hi Matt,
I want to use two separate y axis in a subplot. However, another thing is that my plot types for both is different as well.
One is a scatter plot with first y axis and second is stairs plot with the second y axis. Could you kindly help me with that.
Thanks in advance, Ghulam
Kategorien
Mehr zu Two y-axis finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!