how to change the numbers in plots into percentage?

Discussion in 'MATLAB' started by Yi, Aug 25, 2009.

  1. Yi

    Yi Guest

    Dear Matlab friends:

    clear all; clc; close all;
    x = [1 2 3 4 5 6]
    y = [1 1.2 1.25 1.35 1.36 1.37]
    yy = [0 0.2 0.25 0.35 0.36 0.37]
    [AX,H1,H2] = plotyy(x,y,x,yy)
    delete(H2)
    How to show the second y axis in %, like 0%, 20%...37%, without changing the input value into(x = [0%, 20%...]). Because I will get data from another source which is show in the previous way.

    I wondering if there is some command, like set...

    Thanks

    Yi
     
    Yi, Aug 25, 2009
    #1
    1. Advertisements

  2. Yi

    someone Guest

    % What was wrong with the first suggestion I gave you?

    % In your specific case above, something like:
    set(AX(2),'YTickLabel',{'0%';'20%';...})
     
    someone, Aug 25, 2009
    #2
    1. Advertisements

  3. Try:
    x = [1 2 3 4 5 6]
    y = [1 1.2 1.25 1.35 1.36 1.37]
    yy = [0 0.2 0.25 0.35 0.36 0.37]
    [AX,H1,H2] = plotyy(x,y,x,yy)

    yAxesStr = num2str(get(AX(2),'YTick')'*100,'%2.0f%%'); %make a column vector get the strings seperate

    set(AX(2),'YTickLabel',yAxesStr);

    Hope this helps
    Matt
     
    Matthew Whitaker, Aug 25, 2009
    #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.