Tags: axis, everybody, graph, guess, matlab, plotted, plotyy, programming, touse, vectors

plotyy, 2 set of data on 1 axis

On Programmer » Matlab

3,417 words with 4 Comments; publish: Tue, 06 May 2008 23:25:00 GMT; (20064.45, « »)

hello everybody,

I'd like to have a graph with right and left axis, I guess I have to

use plotyy.

But I'd like also have 2 vectors plotted on the Right axis and one on

the left axis.

How can I do that'

here what I did, I have only y1 versus x who is displayed, and only

the legend of the left axis.

--

x = res.Tempext(:,1);

y1 = res.crankNichol(:,35);

y2 = res.crankNichol(:,24);

y3 = res.crankNichol(:,36);

plotyy(x,y1,x,y2,'plot');

hold on

plot(x,y3);

set(get(AX(1),'Ylabel'),'P & Pheat (kw/m2)','Left Y-axis');

set(get(AX(2),'Ylabel'),'Interior Temperature(C)','Right Y-axis');

grid on;

--

does anybody have an idea as to proceed with it'

thanks for reading

All Comments

Leave a comment...

  • 4 Comments
    • Max wrote:

      >

      > hello everybody,

      > I'd like to have a graph with right and left axis, I guess I have

      > to

      > use plotyy.

      > But I'd like also have 2 vectors plotted on the Right axis and one

      > on

      > the left axis.

      > How can I do that'

      > here what I did, I have only y1 versus x who is displayed, and only

      > the legend of the left axis.

      > --

      > x = res.Tempext(:,1);

      > y1 = res.crankNichol(:,35);

      > y2 = res.crankNichol(:,24);

      > y3 = res.crankNichol(:,36);

      Try this:

      [ax, h1, h2] = plotyy([x,x],[y1,y2],x,y3,.matlab.todaysummary.com.line,.matlab.todaysummary.com.line);

      set(get(ax(1), 'ylabel'), 'string', 'P & Phead (kw/m2)');

      set(get(ax(2), 'ylabel'), 'string', 'Interior Temperature(C)');

      set(h1, 'color', get(ax(1), 'ycolor'));

      set(h1, {'linestyle'}, {'-'; ':'});

      legend([h1;h2], 'y1', 'y2', 'y3');

      grid on;

      jiro

      #3; Tue, 06 May 2008 23:29:00 GMT
    • hello jiro!

      I finally find a solution thanks to "plt" function, but this one also

      works perfectly.

      Thank you very much

      regards

      max

      > [ax, h1, h2] = plotyy([x,x],[y1,y2],x,y3,.matlab.todaysummary.com.line,.matlab.todaysummary.com.line);

      > set(get(ax(1), 'ylabel'), 'string', 'P & Phead (kw/m2)');

      > set(get(ax(2), 'ylabel'), 'string', 'Interior Temperature(C)');

      > set(h1, 'color', get(ax(1), 'ycolor'));

      > set(h1, {'linestyle'}, {'-'; ':'});

      > legend([h1;h2], 'y1', 'y2', 'y3');

      > grid on;

      > jiro

      #4; Tue, 06 May 2008 23:30:00 GMT