how to create a plot with 2 different y tickmarks on both sides

Discussion in 'MATLAB' started by wei feng, Jun 26, 2009.

  1. wei feng

    wei feng Guest


    Basically, I have two sets of data in different ranges (say one in [0,1] and the other [100,200]). They are not the same measurements. For example, one can be length and the other can be density. The simple way of plotting them is to generate two figures. But in my case it would be much more interesting to plot them in one, which can show how they compare much better.

    Direct plotting does not work because the data set with a small range will be compressed so badly that it would be unreadable. So I would like to scale the data differently such that they show up comparably but with a different unit system, i.e., with two different sets of the tickmarks on both left and right.

    I have seen this kind of figures in some magazines. But matlab figures only has one property that dictates the tickmark labels. Does anyone know of any way to do this in matlab?

    wei feng, Jun 26, 2009
    1. Advertisements

  2. wei feng

    Alan B Guest

    You can do it manually by creating two axes with identical position property, and fiddling with the colors and other display properties. plotyy() can do most of that work for you.
    Alan B, Jun 26, 2009
    1. Advertisements

  3. wei feng

    wei feng Guest

    Thanks a lot. I did not know matlab has this plotyy function. Now it's looking easy.

    wei feng, Jun 26, 2009
    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.