A PLOT WITH Y-TICK LABELS ON BOTH SIDES?

Discussion in 'MATLAB' started by ryan, Jun 28, 2007.

  1. ryan

    ryan Guest

    Anyone know hows I can put the yticklabels on both sides of a plot. I
    think I've seen something around in the file exchange but I can't
    find it at the moment or if anyone knows how to does this. Thanks!

    Ryan
     
    ryan, Jun 28, 2007
    #1
    1. Advertisements

  2. plotyy(x,y,x,y)
     
    Gautam Vallabha, Jun 28, 2007
    #2
    1. Advertisements

  3. ryan

    Trevor Guest

    plotyy(x,y,x,y)

    This actually plots the thing twice. If efficiency is a problem for
    you, you might want to try something like this (note that I say
    something LIKE this, because this is very ugly):

    subplot(2,1,2); plot(NaN); h2 = gca;
    subplot(2,1,1); plot(x,y); h1 = gca;

    pos = [.1 .1 .8 .8];
    set(h1,'Position',pos);
    set(h2,'Position',pos, ...
    'XTick',[], ...
    'YAxisLocation','right', ...
    'YLim',get(h1,'YLim'), ...
    'YTick',get(h1,'YTick'), ...
    'YTickLabel',get(h1,'YTickLabel'));

    On my system, with x=1:2000 and y=2*rand(2000), this took 0.4 seconds
    in comparison to plotyy's 1.1 seconds and produced the same output as
    far as I can tell.
     
    Trevor, Jun 28, 2007
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.