[Matplotlib-users] Newbie help with subplots
Good morning, I'm been using matplotlib for a while but it's always been very simple plots (hey - I'm a simple person). I have a need for some fancier plots using subplots. I want to have 3 charts one above the other with a single set of x-axis labels on the bottom subplot that works for all three charts. I'd also like to put a legend outside the set of three charts - either to the top right or horizontally along the bottom. I've been reading a number of links and nothing really works. Most everything is around pylab and I'm using just straight matploblib. I hate to say it, but I need to have the solution and I'm looking for some newbie help. One of the frustrating aspects is I need to make sure it works for version 0.91 :( I'm attaching a simple example script that shows the plots as I currently have achieved them. Apologies for any bad coding. Just in case the attachment doesn't make it through the code is below. Thanks! Jeff #!/usr/bin/python # import matplotlib.pyplot as plt; if __name__ == '__main__': x=[0.0, 1.0, 2.0, 3.0, 4.0]; y1 = [11.97, 1.01, 2.97, 1.0, 1.01]; y2 = [3.55, 1.01, 3.96, 1.0, 0.0]; y3 = [0.29, 0.0, 0.0, 0.0, 0.0]; fig = plt.figure(); ax1 = fig.add_subplot(311); ax2 = fig.add_subplot(312, sharex=ax1); ax3 = fig.add_subplot(313, sharex=ax1); ax1.plot(x, y1, ro-); ax2.plot(x, y2, bo-); ax3.plot(x, y3, go-); ax1.grid(); ax2.grid(); ax3.grid(); plt.show(); # end main #!/usr/bin/python # import matplotlib.pyplot as plt; if __name__ == '__main__': x=[0.0, 1.0, 2.0, 3.0, 4.0]; y1 = [11.97, 1.01, 2.97, 1.0, 1.01]; y2 = [3.55, 1.01, 3.96, 1.0, 0.0]; y3 = [0.29, 0.0, 0.0, 0.0, 0.0]; fig = plt.figure(); ax1 = fig.add_subplot(311); ax2 = fig.add_subplot(312, sharex=ax1); ax3 = fig.add_subplot(313, sharex=ax1); ax1.plot(x, y1, ro-); ax2.plot(x, y2, bo-); ax3.plot(x, y3, go-); ax1.grid(); ax2.grid(); ax3.grid(); plt.show(); # end main -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_jan___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Newbie help with subplots
On Fri, Feb 1, 2013 at 11:04 AM, Jeff Layton layto...@att.net wrote: Good morning, I'm been using matplotlib for a while but it's always been very simple plots (hey - I'm a simple person). I have a need for some fancier plots using subplots. I want to have 3 charts one above the other with a single set of x-axis labels on the bottom subplot that works for all three charts. I'd also like to put a legend outside the set of three charts - either to the top right or horizontally along the bottom. I've been reading a number of links and nothing really works. Most everything is around pylab and I'm using just straight matploblib. I hate to say it, but I need to have the solution and I'm looking for some newbie help. One of the frustrating aspects is I need to make sure it works for version 0.91 :( I'm attaching a simple example script that shows the plots as I currently have achieved them. Apologies for any bad coding. Just in case the attachment doesn't make it through the code is below. Thanks! Jeff I don't know when it was introduced, but ax.label_outer() (called on each axes object) can help you with the axis labeling. If that works, we can then tackle legend placement. Ben Root -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_jan___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Newbie help with subplots
2013/2/1 Benjamin Root ben.r...@ou.edu On Fri, Feb 1, 2013 at 11:04 AM, Jeff Layton layto...@att.net wrote: Good morning, I'm been using matplotlib for a while but it's always been very simple plots (hey - I'm a simple person). I have a need for some fancier plots using subplots. I want to have 3 charts one above the other with a single set of x-axis labels on the bottom subplot that works for all three charts. I'd also like to put a legend outside the set of three charts - either to the top right or horizontally along the bottom. I've been reading a number of links and nothing really works. Most everything is around pylab and I'm using just straight matploblib. I hate to say it, but I need to have the solution and I'm looking for some newbie help. One of the frustrating aspects is I need to make sure it works for version 0.91 :( I'm attaching a simple example script that shows the plots as I currently have achieved them. Apologies for any bad coding. Just in case the attachment doesn't make it through the code is below. Thanks! Jeff I don't know when it was introduced, but ax.label_outer() (called on each axes object) can help you with the axis labeling. If that works, we can then tackle legend placement. if it does not work should be possible to do for ax1 and ax2 [t.set_visible(False) for t in ax.get_xticklabels()] Francesco Ben Root -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_jan ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_jan___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Running matplotlib within a Cocoa application
Dear all Has anyone attempted to use matplotlib within a mac (cocoa) application before (e.g. using PyRun_SimpleFile or PyRun_SimpleString)? I can successfully get get a plot to appear in a new window but when closing this window the entire application quits without any error. Looking at the source code, the macosx backend seems to kill the currently running NSApp. Is there a reason for this and is there any way around it? Many thanks! -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_jan___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] interactively getting z-value on a pcolormesh
Hi, I often use mpl interactively (in ipython --pylab) to plot 2d data on basemaps using pcolormesh. When moving the mouse over the map, I can see x,y coordinates being displayed in the bottom right of the plot window. What would be more interesting for me is the value of the pcolomesh'ed data variable at the point where the mouse cursor is. Any way I can get this information? Cheers, Andreas. -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_jan ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] plotting 3d function
Hi, that's true... I have been playing with maxima. I define the function F(x,y,z):=38244.74787*%pi*(x^2+y^2+z^2)^0.125 +1615.975261*%pi*z^2/(x^2+y^2+z^2)^0.875 +(-1292.78021)*%pi*z^2/((x^2+y^2+z^2)^0.875*(1+y^2/x^2)) +1292.78021*%pi*(x^2+y^2+z^2)^0.125/(1+y^2/x^2); then I factor it factor(F(x,y,z)=0); Multiply it by the denominator % * 3236590*(z^2+y^2+x^2)^(7/8); divide by pi % / %pi; So that F(x,y,z)=0 is equivalent to 1290128178785633*z^2+1237825685085633*y^2+1279667680084472*x^2=0 The only real solution is 0,0,0, But then I try to define a cube centered at the origin which contains at least a part of the surface: load(draw); n: 10$ draw3d( enhanced3d = true, implicit( F(x,y,z) = k, x,-n,n,y,-n,n,z,-n,n)); Since it's taking huge values even for small x,y,z, one has to use either very small n or very large k but even in that case I get draw3d (implicit): non real value How could I check the same in matplotlib? Am I missing something? Maybe this is a bug in maxima... Any help will be appreciated! On Tue, Jan 22, 2013 at 3:29 PM, Benjamin Root ben.r...@ou.edu wrote: On Mon, Jan 21, 2013 at 8:06 PM, Pau vim.u...@googlemail.com wrote: Hi, I am somehow new to matplotlib and I am trying to plot this function of x ,y ,z F(x,y,z)= 38244.74787*Pi*(x^2+y^2+z^2)^.125+1615.975261*Pi*z^2/(x^2+y^2+z^2)^.875-1292.780210*Pi*z^2/((x^2+y^2+z^2)^.875*(1+y^2/x^2))+1292.78*Pi*(x^2+y^2+z^2)^.125/(1+y^2/x^2) in a similar way as http://matplotlib.org/mpl_examples/mplot3d/contour3d_demo3.hires.png The code is http://matplotlib.org/mpl_examples/mplot3d/contour3d_demo3.py But I have no idea where to start... some help would be appreciated... thanks The reason you are having difficulty coming up with a way to plot this is because you have 3 input dimensions, and 1 output dimension that you wish to plot. If you were to plot this in 3D space, it would have to be done as F(x,y,z) as a colored mist in the domain of (x,y,z). While a mist can't be done in mplot3d, you could plot out scatter points to emulate this. One could also use contourf3d(..., zdir='z', offset=...) to create slices of the filled contours, similar to this example: http://matplotlib.org/examples/mplot3d/contourf3d_demo2.html Now, if the domain of (x,y,z) can be parameterized as a surface (i.e., a sphere or a cylinder), then you are looking to do an image of F(x,y,z) plotted on that surface, which is a little bit difficult, but also do-able using the plot_surface() function. Cheers! Ben Root -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_jan ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users