[Matplotlib-users] Multiple y-axis
Hi all, I am new to matplotlib. I like to know how to create a plot that contains several y-axis (up to say, 6) with only 1 x-axis (similar to the two_scales.py type plot but with all of the y-axis on one side). I know you can create multiple single curve plots on the same page but that's not what I want: I want one plot with multiple curves and one y-axis for each of the curves. Any help is greatly appreciated. Regards, -- John Henry - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Multiple Y-axis
Hello, We use Matplotlib for the generation of graphs. This library seems very complete and powerful. Nevertheless we have difficulty making a graph that represents multiple curves with multiple Y-Axis. We don't find how to add a new Y-Axis: - on the left Y-axis and on the left of the axis - or on the left Y-axis and on the right of the axis - or on the right of the Y-axis and on the left of the axis - or on the right of the Y-axis and on the right of the axis. We want to be able to plot a curve using one Y-axis or the other Did some of you already implement such a graph ? Is there any documentation or example presenting similar graphs ? We are looking for general indications and directions to follow to implement such complex visualization, and would be pleased to receive any advice. We are ready to precise our problem as well as possible. Thanks in advance -- Pierre-André Le Ny Chef de produit SIG Makina Corpus -- View this message in context: http://www.nabble.com/Multiple-Y-axis-tf3795273.html#a10734643 Sent from the matplotlib - users mailing list archive at Nabble.com. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Multiple y axis plotting
Hi new to Matplotlib and struggling to make a plot that has three lines plotted on it: two are supposed to plot on the LH y axis and the third on the RH y axis. The code so far is import os import math import wx import wxmpl import numpy # === # Define plot data window # === class ForecastData: # Constructor def __init__(self, d): # Transfer parameters self.dt = d['dt'] # time step size self.tmax = d['tmax'] # maximum forecast time # Set up arrays (filled with zeroes) self.nstep=int(self.tmax/self.dt) self.xtim=numpy.zeros((self.nstep,)) self.xoil=numpy.zeros((self.nstep,)) self.xwat=numpy.zeros((self.nstep,)) self.xgas=numpy.zeros((self.nstep,)) # == # Define main window # == class PlotFrame(wxmpl.PlotFrame): # Constructor for main window def __init__(self, data): # Create a wxmpl PlotFrame instance wxmpl.PlotFrame.__init__(self, None, wx.ID_ANY, title='Production profile') fig = self.get_figure() # Create an Axes on the Figure to plot in. ax1 = fig.add_axes([0.1, 0.1, 0.8, 0.8]) ax2 = fig.add_axes([0.9, 0.1, -0.8, 0.8]) # Plot the data ax1.plot(data.xtim, data.xoil, '-g', label='oil rate') ax1.plot(data.xtim, data.xwat, '-b', label='water rate') ax2.plot(data.xtim, data.xgas, '-r', label='gas rate') # Add a legend ax1.legend() ax2.legend() # Set axis titles ax1.set_xlabel('time (years)', family='sans-serif') ax1.set_ylabel('liquid rate (m3/d)', family='sans-serif') ax2.set_ylabel('gas rate (m3/d)', family='sans-serif') # # Define application class # class App(wx.App): def OnInit(self): # Define data parameters for test model d={} d['dt']=0.1 # time step size d['tmax']=10.0 # maximum forecast time # Define data object fcst_data = ForecastData(d) # Fill data arrays with dummy data tnow = 0.0 for n in range(fcst_data.nstep): fcst_data.xtim[n]=tnow fcst_data.xoil[n]=5000*math.exp(-0.1*tnow) fcst_data.xgas[n]=600*math.sin(tnow) fcst_data.xwat[n]=3000*math.exp(1.0-0.2*tnow) tnow = tnow + fcst_data.dt # Display top level window self.frame = PlotFrame(fcst_data) self.frame.Show() self.SetTopWindow(self.frame) return True def main(): app = App(False) app.MainLoop() if __name__ == '__main__': main() About the only successful thing here is getting the RH y axis scale on the RH of the plot :-(. The lines on ax1 don't show up so I guess ax2 is obscuring it somehow (though I thought axisbg=None by default), the x axis for axis 2 runs in the wrong direction (presumably because width is negative) and the labels are all over the place. Hopefully, the labels problem should be fairly easy to sort out once I can see the lines but until then I'm a bit stuck. Tried to find an example of what I want to do, but most of them seem to use subplots whereas I just want all my plots on the same graph. Can somebody please point me in the right direction? Thanks in advance Alun Griffiths - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Multiple Y-axis
Hi, to the best of my knowledge, you have only the opportunity to use the left Y-axis and the right Y-axis (use twinx()) Benoit Le 22-mai-07 à 11:44, PA a écrit : > > Hello, > > We use Matplotlib for the generation of graphs. > This library seems very complete and powerful. > > Nevertheless we have difficulty making a graph that represents > multiple > curves with multiple Y-Axis. > We don't find how to add a new Y-Axis: > >- on the left Y-axis and on the left of the axis >- or on the left Y-axis and on the right of the axis >- or on the right of the Y-axis and on the left of the axis >- or on the right of the Y-axis and on the right of the axis. > > We want to be able to plot a curve using one Y-axis or the other > > Did some of you already implement such a graph ? > Is there any documentation or example presenting similar graphs ? > > We are looking for general indications and directions to follow to > implement > such complex visualization, and would be pleased to receive any > advice. > We are ready to precise our problem as well as possible. > > Thanks in advance > > -- > Pierre-André Le Ny > Chef de produit SIG > Makina Corpus > -- > View this message in context: http://www.nabble.com/Multiple-Y-axis- > tf3795273.html#a10734643 > Sent from the matplotlib - users mailing list archive at Nabble.com. > > > -- > --- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Dr. Benoit Donnet Université Catholique de Louvain (UCL) Faculté des Sciences Appliquées - Département d'Ingénierie Informatique (INGI) Place Sainte Barbe, 2 1348 Louvain-la-Neuve Belgium Phone: +32 10 47 87 18 Home page: http://www.info.ucl.ac.be/~donnet - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Multiple Y-axis
Is there any documentation or example presenting similar graphs ? Take a look at two_scales.py from the examples ( http://matplotlib.sourceforge.net/matplotlib_examples_0.90.0.zip) Bernhard - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Multiple y axis plotting
> "Etrade" == Etrade Griffiths <[EMAIL PROTECTED]> writes: Etrade> Hi new to Matplotlib and struggling to make a plot that Etrade> has three lines plotted on it: two are supposed to plot on Etrade> the LH y axis and the third on the RH y axis. The code so Etrade> far is ax1 = fig.add_axes([0.1, 0.1, 0.8, 0.8]) ax2 = fig.add_axes([0.9, 0.1, -0.8, 0.8]) ^ [left, bottom, width, height] negative numbers are not supported. I don't know what kind of layout you want, but start with something like ax1 = fig.add_axes([0.1, 0.1, 0.4, 0.8]) ax2 = fig.add_axes([0.55, 0.1, 0.4, 0.8]) and once you have a working plot tweak from there. JDH - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Multiple y axis plotting
John am trying to make a plot something along the lines of the attached. This has a single plot area with separate y-axes on either side of the plot, rather than two plot areas, each with their own axis Best regards Alun Griffiths At 14:24 06/11/2006, John Hunter wrote: > "Etrade" == Etrade Griffiths <[EMAIL PROTECTED]> writes: Etrade> Hi new to Matplotlib and struggling to make a plot that Etrade> has three lines plotted on it: two are supposed to plot on Etrade> the LH y axis and the third on the RH y axis. The code so Etrade> far is ax1 = fig.add_axes([0.1, 0.1, 0.8, 0.8]) ax2 = fig.add_axes([0.9, 0.1, -0.8, 0.8]) ^ [left, bottom, width, height] negative numbers are not supported. I don't know what kind of layout you want, but start with something like ax1 = fig.add_axes([0.1, 0.1, 0.4, 0.8]) ax2 = fig.add_axes([0.55, 0.1, 0.4, 0.8]) and once you have a working plot tweak from there. JDH example_plot.pdf Description: Adobe PDF document - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Multiple y axis plotting
After poking around in the Pylab source, managed to sort the multiple line plotting using fig = self.get_figure() ax1 = fig.gca() ax2 = fig.add_axes(ax1.get_position(), sharex=ax1, frameon=False) so issue closed for the moment - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Multiple y axis plotting
> "Etrade" == Etrade Griffiths <[EMAIL PROTECTED]> writes: Etrade> After poking around in the Pylab source, managed to sort Etrade> the multiple line plotting using Etrade> fig = self.get_figure() ax1 = fig.gca() ax2 = Etrade> fig.add_axes(ax1.get_position(), sharex=ax1, Etrade> frameon=False) Isn't this what the twinx function does - heave you seen http://matplotlib.sourceforge.net/examples/shared_axis_demo.py ? - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Multiple y axis plotting
John thanks - twinx was indeed where I "borrowed" some of the lines from. They're in the code explicitly 'cos it's a lot clearer to me than using twinx which is buried somewhere in the pylab interface Alun Griffiths At 15:32 07/11/2006, you wrote: > > "Etrade" == Etrade Griffiths <[EMAIL PROTECTED]> writes: > > Etrade> After poking around in the Pylab source, managed to sort > Etrade> the multiple line plotting using > > Etrade> fig = self.get_figure() ax1 = fig.gca() ax2 = > Etrade> fig.add_axes(ax1.get_position(), sharex=ax1, > Etrade> frameon=False) > >Isn't this what the twinx function does - heave you seen >http://matplotlib.sourceforge.net/examples/shared_axis_demo.py ? - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users