Change how this plot looks

Is there a way to modify the attached plot in MATLAB, such that it contains another y-axis on the right hand side called "ADR" (where the range is 0-100)?
I would also like to change the x-axis scale to decrease from 0.9 to 0.2 instead of running from 1 to 8... I think I should be using xlim for this, but I don't know the syntax for xlim([max min]) such that the values decrease...
Finally, I would like to add a vertical line at the point where the two curves intersect. Is this possible?
This is the code I'm using:
figure,
hold on
plot(HR_accuracy,'k-x','Color',[0 0 0],'linewidth',1.05)
plot(ADR,'k-o','Color',[0 0 0])
grid on
ylabel('HR Accuracy (%)')
xlabel('Threshold Values, t^{L} = 0.1')
l = legend('HR Accuracy (%)', 'ADR (%)',2);
set(l,'position',[0.76 0.65 0.1 0.1]);
hold off

 Risposta accettata

Sean de Wolski
Sean de Wolski il 8 Dic 2011
Sure:
  1. doc plotyy
  2. use the axes handles set the limits (doc axes (click on axes properties))
  3. To plot a vertical line, find where the curves intersect (doc interp1 and doc fzero, if you don't know the intersection point). Then just user line (doc line) do draw it.
For Q2:
h = figure;
[ax] = plotyy(1:10,1:10,1:10,1:10.^1:10); %ax is 1x2 vectpr of axes handles
set(ax(1),'xlim',[0 4]); %set the xlims
set(ax(2),'xlim',[8 10]);

5 Commenti

Philip
Philip il 8 Dic 2011
Thanks for your kind response.
plotyy seems to work well, but I can't seem to work out how I can use axis to set the limits... Would you mind giving me an example of this?
yeah, axis was the wrong idea. You actually want axes! See edit.
Philip
Philip il 8 Dic 2011
That's perfect, thanks! Now I just need to work out how to do your 3rd suggestion...
Philip
Philip il 8 Dic 2011
I have now done the third part... Is it possible to annotate the line with some text?
doc text, doc annotation, or just do it manually with the plottools (doc plottools)

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by