change appearence of 3rd plot in plotyy and plot legend
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I am trying to have 3 different plots show in the same graph. I have one plot associated with the left y-axis and 2 plots associated with the right y-axis. I am having a problem differentiating the 2 plots associated with the right axis. Can you help me get the right associated plots to show as '-.' in red and ':' in green? Here is my code:
clc;
clear;
samples = (1:100)';
theta_1 = 0 + (90)*rand(100,1);
r2v = 0 + (0.5)*rand(100,1);
r3v = 0 + (0.5)*rand(100,1);
% plot(samples, theta_1, '.r', samples, r2v, '.b', samples, r3v, '.g' );
figure
[hAx,hLine1,hLine2] = plotyy(samples,theta_1, [samples',samples'], [r2v',r3v']);
hLine1.LineStyle = '-.';
hLine2.LineStyle = ':';
0 个评论
回答(1 个)
Jacky Jo
2015-10-27
Check the following. Also, check the range of theta_1 and (r2v or r3v). If you try to plot these three in a graph you can't see r2v and r3v that much; since it have range much lesser than theta_1. Therefore I did in separate plots.
samples = (1:100)';
theta_1 = 0 + (90)*rand(100,1);
r2v = 0 + (0.5)*rand(100,1);
r3v = 0 + (0.5)*rand(100,1);
figure;
plot(samples, theta_1,'.r'); % Check the Y scale of fig1 and fig 2
figure; hold on;
plot (samples, r2v, '.b');
plot (samples, r3v, '.g' );
figure
[hAx,hLine1,hLine2] = plotyy(samples,theta_1, [samples',samples'], [r2v',r3v']);
set(hLine1,'LineStyle','--')
set(hLine2,'LineStyle',':')
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Two y-axis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!