From: Ryan K. <rya...@co...> - 2005-09-28 01:05:30
Attachments:
secondary_axis.jpg
|
If it helps clarify what I mean, attached is a plot I made in excel (I really don't want to use excel). The y-xis on the left goes from -60 to 80. The one on the right goes from 0-1. Ryan Ryan Krauss wrote: > Is it possible to overlay two plots with different y-axis limit? I > think excel calls this plotting a data set with a secondary y-axis. I > want to overlay a bode plot with its coherence and the y-axis limits for > the two will be very different. I don't want to plot one above the > other with a subplot, but actually overlay them on the same plot. > (and I want to do it on a semilogx). > > Thanks, > > Ryan > > > ------------------------------------------------------- > This SF.Net email is sponsored by: > Power Architecture Resource Center: Free content, downloads, discussions, > and more. http://solutions.newsforge.com/ibmarch.tmpl > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |
From: Ryan K. <rya...@co...> - 2005-09-28 01:48:35
|
It appears that this feature is available through the twinx() function according to: http://matplotlib.sourceforge.net/faq.html#TWOSCALES (the link on this page is broken, but I have the file in some examples I downloaded from somewhere else on the matplotlib page.) I created the second plot using: figure(1) subplot(211) ax2=pylab.twinx() pylab.semilogx(freq,iobode.coh,'k') It seems like once I called the twinx function, the x-axis settings that where on the original axis are ignored and I can't seem to change the axis settings. pylab.axes([0.1,30,0,1]) returned an error: RuntimeError: Transformation is not invertible I tried calling the ax2.set_xlim((0.1,30)) function but it doesn't seem to do anything. Ryan Ryan Krauss wrote: > If it helps clarify what I mean, attached is a plot I made in excel (I > really don't want to use excel). The y-xis on the left goes from -60 to > 80. The one on the right goes from 0-1. > > Ryan > > Ryan Krauss wrote: > >> Is it possible to overlay two plots with different y-axis limit? I >> think excel calls this plotting a data set with a secondary y-axis. I >> want to overlay a bode plot with its coherence and the y-axis limits >> for the two will be very different. I don't want to plot one above >> the other with a subplot, but actually overlay them on the same plot. >> (and I want to do it on a semilogx). >> >> Thanks, >> >> Ryan >> >> >> ------------------------------------------------------- >> This SF.Net email is sponsored by: >> Power Architecture Resource Center: Free content, downloads, discussions, >> and more. http://solutions.newsforge.com/ibmarch.tmpl >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> > > > ------------------------------------------------------------------------ > |
From: John H. <jdh...@ac...> - 2005-09-28 02:05:56
|
>>>>> "Ryan" == Ryan Krauss <rya...@co...> writes: Ryan> It appears that this feature is available through the Ryan> twinx() function according to: Right -- see also examples/two_scales.py Ryan> It seems like once I called the twinx function, the x-axis Ryan> settings that where on the original axis are ignored and I Ryan> can't seem to change the axis settings. Ryan> pylab.axes([0.1,30,0,1]) returned an error: RuntimeError: Ryan> Transformation is not invertible Please post a free-standing, complete example which replicates the bug. Thanks, JDH |
From: Ryan K. <rya...@co...> - 2005-09-28 13:59:22
|
This morning on my office computer I don't seem to have the same problem. (I will see if I can recreate my problem on my laptop at home later.) I do have one new problem though. After adding the second plot, I need to refresh the legend of the first plot because the plot on twinx wrote over it. Any calls to legend seem to be working with the lines that are drawn on twinx. I could avoid this problem and make a slightly nicer looking plot if I could first draw on the twinx axis (with the y-axis ticks on the right) and then draw on the "normal" axis (with the y-axis ticks and label on the left). Is this possible? And can I make one legend that includes the plots from both axes? Thanks for your help John. I think I am getting close to a really nice graph with a lot of useful information on it. Ryan John Hunter wrote: >>>>>>"Ryan" == Ryan Krauss <rya...@co...> writes: > > > > Ryan> It appears that this feature is available through the > Ryan> twinx() function according to: > > Right -- see also examples/two_scales.py > > Ryan> It seems like once I called the twinx function, the x-axis > Ryan> settings that where on the original axis are ignored and I > Ryan> can't seem to change the axis settings. > Ryan> pylab.axes([0.1,30,0,1]) returned an error: RuntimeError: > Ryan> Transformation is not invertible > > Please post a free-standing, complete example which replicates the > bug. > > Thanks, > JDH > > > ------------------------------------------------------- > This SF.Net email is sponsored by: > Power Architecture Resource Center: Free content, downloads, discussions, > and more. http://solutions.newsforge.com/ibmarch.tmpl > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |
From: Ryan K. <rya...@co...> - 2005-09-28 22:36:30
|
I am on my computer at home and can't recreate my problem. I don't know what I did wrong last night. I could still use help though on the legend refresh stuff in my other message. Ryan Krauss wrote: > This morning on my office computer I don't seem to have the same > problem. (I will see if I can recreate my problem on my laptop at home > later.) > > I do have one new problem though. After adding the second plot, I need > to refresh the legend of the first plot because the plot on twinx wrote > over it. Any calls to legend seem to be working with the lines that are > drawn on twinx. I could avoid this problem and make a slightly nicer > looking plot if I could first draw on the twinx axis (with the y-axis > ticks on the right) and then draw on the "normal" axis (with the y-axis > ticks and label on the left). Is this possible? > > And can I make one legend that includes the plots from both axes? > > Thanks for your help John. I think I am getting close to a really nice > graph with a lot of useful information on it. > > Ryan > > > > John Hunter wrote: > >>>>>>> "Ryan" == Ryan Krauss <rya...@co...> writes: >> >> >> >> >> Ryan> It appears that this feature is available through the >> Ryan> twinx() function according to: >> >> Right -- see also examples/two_scales.py >> >> Ryan> It seems like once I called the twinx function, the x-axis >> Ryan> settings that where on the original axis are ignored and I >> Ryan> can't seem to change the axis settings. >> Ryan> pylab.axes([0.1,30,0,1]) returned an error: RuntimeError: >> Ryan> Transformation is not invertible >> >> Please post a free-standing, complete example which replicates the >> bug. >> >> Thanks, >> JDH >> >> >> ------------------------------------------------------- >> This SF.Net email is sponsored by: >> Power Architecture Resource Center: Free content, downloads, discussions, >> and more. http://solutions.newsforge.com/ibmarch.tmpl >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> > > > ------------------------------------------------------- > This SF.Net email is sponsored by: > Power Architecture Resource Center: Free content, downloads, discussions, > and more. http://solutions.newsforge.com/ibmarch.tmpl > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |
From: John H. <jdh...@ac...> - 2005-09-30 13:41:35
|
>>>>> "Ryan" == Ryan Krauss <rya...@co...> writes: Ryan> And can I make one legend that includes the plots from both Ryan> axes? Save a list of lines and a list of labels and then call ax.legend(lines, labels) lines and labels can be from different axes; eg, lines = [] lines.extend( ax1.plot(something)) lines.extend( ax2.plot(something_else)) See also the figure legend capability in http://matplotlib.sf.net/matplotlib.figure.html Ryan> Thanks for your help John. I think I am getting close to a Ryan> really nice graph with a lot of useful information on it. Your welcome -- good luck. JDH |