how do i change color of the y-axes made by plotyy?
90 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Rory Staunton
el 22 de Mayo de 2011
Comentada: Sharath Nagaraju
el 14 de Feb. de 2021
I am trying to make the color of the left Y axis red and the color of the right Y axis blue. I can't figure out the right syntax.
Thanks in advance.
A snip of the code I have is below:
close;
% plot F23 vs. D in figure gcf
[AX,H1,H2]=plotyy(Dcurve,F23curve,W,V,'plot');
AX
set(gcf,'Position',[500,500,900,500]);
title('Click on all the discontinuities and then hit Return key');
set(get(AX(1),'Ylabel'),'String','Force^(2/3) [N^(2/3)]');
% ? % set(get(AX(1),'color'),'red');
set(get(AX(2),'Ylabel'),'String','Force [N]');
% ? % set(get(AX(2),'color'),'blue');
xlabel('Indentation depth [m]');
set(H1,'LineStyle','-');
set(H1,'color','red');
set(H2,'LineStyle','-');
set(H2,'color','blue');
hold on
% user double click on all discontinuities and press enter
[xm,ym]=ginput;
0 comentarios
Respuesta aceptada
Matt Fig
el 22 de Mayo de 2011
An example:
x = 0:0.01:20;
y1 = 200*exp(-0.05*x).*sin(x);
y2 = 0.8*exp(-0.5*x).*sin(10*x);
[AX,H1,H2] = plotyy(x,y1,x,y2,'plot');
set(AX,{'ycolor'},{'r';'b'}) % Left color red, right color blue...
4 comentarios
Karen Henneke
el 25 de Feb. de 2017
It sure would be nice if matlab would go back to help as they used to do it 10 or so years ago---one could find what they needed easily---now it is hard to find anything you need in matlab help
Timothy Reilly
el 10 de Jul. de 2019
I agree. Help is getting to be a bubbling swamp like Microsoft help.
Más respuestas (1)
Alejandro
el 4 de Abr. de 2015
I'm using this:
% removing ticks and everything else
% for x
set(gca,'XTickLabel',[])
set(gca,'XTick',[])
set(gca,'xcolor','w')
% for y
set(gca,'YTickLabel',[])
set(gca,'YTick',[])
set(gca,'ycolor','w')
% for z
set(gca,'ZTickLabel',[])
set(gca,'ZTick',[])
set(gca,'zcolor','w')
seems that it works pretty well, leaving just the with box in the background.
5 comentarios
Sara Anthony
el 12 de Jul. de 2019
I know this is really old, but I wanted to leave a comment that might help someone else. Alejandro's answer works the best for me. However, it's likely because I'm already using that format for the rest of my code:
yyaxis left
errorbar(Wr2IsotDateNum(1:22,1),Wr2D18O(1:22,1),ErrWr2D18O(1:22),'*--k')
ylim([-8.6 -7.5])
ytickformat('%.1f')
set(gca,'ycolor','k')
yyaxis right
plot(W2DateNum(22468:22598,1),M5Wr2C,'b')
set(gca,'ycolor','b')
ylim([0.64 0.7])
ytickformat('%.2f')
Ver también
Categorías
Más información sobre Two y-axis en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!