change appearence of 3rd plot in plotyy and plot legend

1 visualización (últimos 30 días)
monkey_matlab
monkey_matlab el 27 de Oct. de 2015
Editada: monkey_matlab el 27 de Oct. de 2015
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 = ':';

Respuestas (1)

Jacky Jo
Jacky Jo el 27 de Oct. de 2015
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',':')
  1 comentario
monkey_matlab
monkey_matlab el 27 de Oct. de 2015
Editada: monkey_matlab el 27 de Oct. de 2015
Hello, but since we are plotting r2v and r3v with reference to the right y-axis, show it not also be able to show up properly on the same figure? theta_1 is referenced to the left y-axis and should be independent of r2v and r3v?

Iniciar sesión para comentar.

Categorías

Más información sobre Two y-axis en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by