How to change the color of a plot with two y-axes on the same graph in Matlab

1 次查看(过去 30 天)
dear all
for the following program
how i can change the color of each plot
x = 0:0.01:20;
y1 = sin(x);
y2 = x;
figure % new figure
plotyy(x,y1,x,y2)
[hAx,hLine1,hLine2] = plotyy(x,y1,x,y2);
xlabel('Time (\musec)')
ylabel(hAx(1),'Slow Decay')
ylabel(hAx(2),'Fast Decay')

采纳的回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2019-9-27
编辑:KALYAN ACHARJYA 2019-9-27
x = 0:0.01:20;
y1 = sin(x);
y2 = x;
figure % new figure
plotyy(x,y1,x,y2)
[hAx,hLine1,hLine2] = plotyy(x,y1,x,y2);
set(hAx(1),'ycolor','r'); % Change the color accordingly
set(hAx(2),'ycolor','c'); % Change the color accordingly
xlabel('Time (\musec)')
ylabel(hAx(1),'Slow Decay') ;
ylabel(hAx(2),'Fast Decay') ;
Or
x = 0:0.01:20;
y1 = sin(x);
y2 = x;
figure % new figure
plotyy(x,y1,x,y2)
[hAx,hLine1,hLine2] = plotyy(x,y1,x,y2);
set(hAx,{'ycolor'},{'r';'c'});
%..........x or y axex color, if x, use xcolor and change the colors accordingly
xlabel('Time (\musec)')
ylabel(hAx(1),'Slow Decay')
ylabel(hAx(2),'Fast Decay')
  4 个评论
Fuad Nammas
Fuad Nammas 2019-9-27
thanks alot dear brother..
but would you pease help me to make the axis "black'
while the curves one is "solid black"
and the other is "dashe black"
i will be greatful for you
KALYAN ACHARJYA
KALYAN ACHARJYA 2019-9-27
This way?
x = 0:0.01:20;
y1 = sin(x);
y2 = x;
figure % new figure
yyaxis left
plot(x,y1,'c');
yyaxis right;
plot(x,y2,'b');

请先登录,再进行评论。

更多回答(2 个)

Fuad Nammas
Fuad Nammas 2019-9-27
for the fist part of my question i used your codes but it changes the axis color and the curves color it dont work

Fuad Nammas
Fuad Nammas 2019-9-27
编辑:Fuad Nammas 2019-9-27
thanks alot dear brother..
but would you please help me to make
1- the axis "black'
2 while the curves one is "solid black"
3-and the other is "dashe black"
i will be greatful for you

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by