[Matplotlib-users] pylab collides with fmin?
I'm getting odd behavior when I try to use fmin and pylab in the same program. The issue is illustrated in the code snippet below. As written, fmin won't work: the print xopt simply returns the contents of x0 as assigned in the line before fmin. If the from pylab import * line is commented out, however, then fmin runs as expected. I'm running python 2.7.2 on a MacBook Pro with a recent install upgrade of scipy and matplotlib via macports. Any suggestions would be appreciated. - #!/opt/local/bin/python from scipy import * from scipy.optimize import fmin import matplotlib matplotlib.use('MacOSX') from pylab import * def rosen(x): # The Rosenbrock function return sum(100.0*(x[1:]-x[:-1]**2.0)**2.0 + (1-x[:-1])**2.0) x0 = [1.3, 0.7, 0.8, 1.9, 1.2] xopt = fmin(rosen, x0) print xopt -- BlackBerryreg; DevCon Americas, Oct. 18-20, San Francisco, CA Learn about the latest advances in developing for the BlackBerryreg; mobile platform with sessions, labs more. See new tools and technologies. Register for BlackBerryreg; DevCon today! http://p.sf.net/sfu/rim-devcon-copy1 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Hatching linewidth?
Hi, I am trying to create a hatched region, with a diagonal lines hatch pattern. When using the PS backend, the hatch lines come out very narrow. Is there a way to increase the thickness of the hatch lines? I am using mpl version 1.0.1. I think this question has been asked before (e.g., in 2008), but I couldn't find an answer. Thanks! -Jeff -- BlackBerryreg; DevCon Americas, Oct. 18-20, San Francisco, CA Learn about the latest advances in developing for the BlackBerryreg; mobile platform with sessions, labs more. See new tools and technologies. Register for BlackBerryreg; DevCon today! http://p.sf.net/sfu/rim-devcon-copy1 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] pylab collides with fmin?
On Wed, Sep 14, 2011 at 2:17 PM, Raymond Hawkins rhawk...@earthlink.netwrote: I'm getting odd behavior when I try to use fmin and pylab in the same program. The issue is illustrated in the code snippet below. As written, fmin won't work: the print xopt simply returns the contents of x0 as assigned in the line before fmin. If the from pylab import * line is commented out, however, then fmin runs as expected. I'm running python 2.7.2 on a MacBook Pro with a recent install upgrade of scipy and matplotlib via macports. Any suggestions would be appreciated. - #!/opt/local/bin/python from scipy import * from scipy.optimize import fmin import matplotlib matplotlib.use('MacOSX') from pylab import * def rosen(x): # The Rosenbrock function return sum(100.0*(x[1:]-x[:-1]**2.0)**2.0 + (1-x[:-1])**2.0) x0 = [1.3, 0.7, 0.8, 1.9, 1.2] xopt = fmin(rosen, x0) print xopt Because pylab brings the numpy namespace into the current namespace, numpy's fmin is imported and replaces the previously def'ed fmin from scipy.optimize. Numpy's fmin function is completely different from scipy's fmin. Try putting the from scipy.optimize import fmin after the pylab import line. Or, do something like from scipy.optimize import fmin as fminimize to avoid name collision. I hope that helps. Ben Root -- BlackBerryreg; DevCon Americas, Oct. 18-20, San Francisco, CA Learn about the latest advances in developing for the BlackBerryreg; mobile platform with sessions, labs more. See new tools and technologies. Register for BlackBerryreg; DevCon today! http://p.sf.net/sfu/rim-devcon-copy1 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] pylab collides with fmin?
On 09/14/2011 09:17 AM, Raymond Hawkins wrote: I'm getting odd behavior when I try to use fmin and pylab in the same program. The issue is illustrated in the code snippet below. As written, fmin won't work: the print xopt simply returns the contents of x0 as assigned in the line before fmin. If the from pylab import * line is commented out, however, then fmin runs as expected. This is a good illustration of why from package_x import * is so strongly discouraged; it is throwing away one of the most important features of python--the default separation of packages into their own name spaces. The only exception with respect to pylab is that for quick and dirty interactive use, particularly within ipython, it is sometimes worthwhile to sacrifice some name space separation for typing speed. But in a script that imports from more than one external package, it is best to always use explicit imports in some form. The preferred idiom is to avoid importing pylab at all in scripts; instead, do this: import numpy as np import matplotlib.pyplot as plt Eric I'm running python 2.7.2 on a MacBook Pro with a recent install upgrade of scipy and matplotlib via macports. Any suggestions would be appreciated. - #!/opt/local/bin/python from scipy import * from scipy.optimize import fmin import matplotlib matplotlib.use('MacOSX') from pylab import * def rosen(x): # The Rosenbrock function return sum(100.0*(x[1:]-x[:-1]**2.0)**2.0 + (1-x[:-1])**2.0) x0 = [1.3, 0.7, 0.8, 1.9, 1.2] xopt = fmin(rosen, x0) print xopt -- BlackBerryreg; DevCon Americas, Oct. 18-20, San Francisco, CA Learn about the latest advances in developing for the BlackBerryreg; mobile platform with sessions, labs more. See new tools and technologies. Register for BlackBerryreg; DevCon today! http://p.sf.net/sfu/rim-devcon-copy1 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- BlackBerryreg; DevCon Americas, Oct. 18-20, San Francisco, CA Learn about the latest advances in developing for the BlackBerryreg; mobile platform with sessions, labs more. See new tools and technologies. Register for BlackBerryreg; DevCon today! http://p.sf.net/sfu/rim-devcon-copy1 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Hatching linewidth?
Hi, I am trying to create a hatched region, with a diagonal lines hatch pattern. When using the PS backend, the hatch lines come out very narrow. Is there a way to increase the thickness of the hatch lines? I am using mpl version 1.0.1. I think this question has been asked before (e.g., in 2008), but I couldn't find an answer. Thanks! -Jeff P.S. I apologize if this message arrives twice. -- BlackBerryreg; DevCon Americas, Oct. 18-20, San Francisco, CA Learn about the latest advances in developing for the BlackBerryreg; mobile platform with sessions, labs more. See new tools and technologies. Register for BlackBerryreg; DevCon today! http://p.sf.net/sfu/rim-devcon-copy1 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] superimposition of Cartesian projection axis on a polar axis on the same position
Hi, I have x-y grid data with z values and want to have a pixel view and contour view at the same time on the same position. Both cases should have polar coordinate system but since contour function does not plot on the polar coordinate system, it is plotted on a rectilinear projection with converting the polar grid into x-y grid. Please let me know if this isn't true. For pixel view, pcolormesh was used. The subplot was added with specifying the projection='polar', as something like below: axp=fig.add_subplot(1,1,1,projection='polar') axr=fig.add_subplot(2,2,1) Then, I will have two independent axes shown in the figure canvas. Since I want to place the two axes on the same position, if allowed, I would like to do: axp=fig.add_subplot(1,1,1,projection='polar') axr=fig.add_subplot(1,1,1) But it only gives one axis added to 'fig.axes'. Is there any work-around? Or am I missing some other feature of matplotlib? Youngung -- BlackBerryreg; DevCon Americas, Oct. 18-20, San Francisco, CA Learn about the latest advances in developing for the BlackBerryreg; mobile platform with sessions, labs more. See new tools and technologies. Register for BlackBerryreg; DevCon today! http://p.sf.net/sfu/rim-devcon-copy1 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] superimposition of Cartesian projection axis on a polar axis on the same position
On Wed, Sep 14, 2011 at 3:08 PM, Youngung Jeong youngung.je...@gmail.comwrote: Hi, I have x-y grid data with z values and want to have a pixel view and contour view at the same time on the same position. Both cases should have polar coordinate system but since contour function does not plot on the polar coordinate system, it is plotted on a rectilinear projection with converting the polar grid into x-y grid. Please let me know if this isn't true. For pixel view, pcolormesh was used. The subplot was added with specifying the projection='polar', as something like below: axp=fig.add_subplot(1,1,1,projection='polar') axr=fig.add_subplot(2,2,1) Then, I will have two independent axes shown in the figure canvas. Since I want to place the two axes on the same position, if allowed, I would like to do: axp=fig.add_subplot(1,1,1,projection='polar') axr=fig.add_subplot(1,1,1) But it only gives one axis added to 'fig.axes'. Is there any work-around? Or am I missing some other feature of matplotlib? Youngung There are some ways to do this, but I haven't tried them myself. http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/axislines.html Ben Root -- BlackBerryreg; DevCon Americas, Oct. 18-20, San Francisco, CA Learn about the latest advances in developing for the BlackBerryreg; mobile platform with sessions, labs more. See new tools and technologies. Register for BlackBerryreg; DevCon today! http://p.sf.net/sfu/rim-devcon-copy1 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] x, y labels with varying font styles
Hey, All, I've combed the documentation ad nauseum, but I can't find a solution for this one, besides a very brute-force one. Let's say I've set my default sans-serif font as 'Arial'. Fine. Now, let's say, in a standard plot, I set the x label of this plot using something like: matplotlib.pyplot.xlabel('f(x) (widgets/quatloo)') Fine again. But now, let's say I want to italicize only the 'f' and 'x'. I can't find any easy way to do that while retaining the Arial font. And no, I don't want to use TeX. Target users' computers might not have it. I've tried using mathtext, but that uses one of mathtext's fonts, not mine (computer modern, etc., or sansserif, etc.) I've tried setting mathregular, but that won't allow me to vary italic/nonitalic text. I'm left with not labeling the axes at all, but simply putting four different text objects next to each other and hoping that it doesn't look too jury-rigged. Either that, or Photoshop the puppy. Any suggestions? Chad-- BlackBerryreg; DevCon Americas, Oct. 18-20, San Francisco, CA Learn about the latest advances in developing for the BlackBerryreg; mobile platform with sessions, labs more. See new tools and technologies. Register for BlackBerryreg; DevCon today! http://p.sf.net/sfu/rim-devcon-copy1 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] x, y labels with varying font styles
On Wed, Sep 14, 2011 at 4:34 PM, CAB cabr...@yahoo.com wrote: But now, let's say I want to italicize only the 'f' and 'x'. I can't find any easy way to do that while retaining the Arial font. And no, I don't want to use TeX. Target users' computers might not have it. That's fine, that's why matplotlib imitates TeX with mathtext... I've tried using mathtext, but that uses one of mathtext's fonts, not mine (computer modern, etc., or sansserif, etc.) I am sure there must be some way to change the font, but Arial might not be supported for this... haven't tried though. I've tried setting mathregular, but that won't allow me to vary italic/nonitalic text. Could you include some examples of what you tried? I'm left with not labeling the axes at all, but simply putting four different text objects next to each other and hoping that it doesn't look too jury-rigged. Yeah, based on your requirements (italicize individual characters) your choices are to either use the latex-like syntax that matplotlib allows for, or to individually set the characters in their own text boxes. But, really, I think if you rethink your requirements, then you will realize that mathtext is the better way to go. It looks much more aesthetically pleasing that way. Either that, or Photoshop the puppy. Let's see if we can avoid that... Cheers, Ben Root -- BlackBerryreg; DevCon Americas, Oct. 18-20, San Francisco, CA Learn about the latest advances in developing for the BlackBerryreg; mobile platform with sessions, labs more. See new tools and technologies. Register for BlackBerryreg; DevCon today! http://p.sf.net/sfu/rim-devcon-copy1 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] superimposition of Cartesian projection axis on a polar axis on the same position
On Thu, Sep 15, 2011 at 5:08 AM, Youngung Jeong youngung.je...@gmail.com wrote: But it only gives one axis added to 'fig.axes'. Is there any work-around? Or am I missing some other feature of matplotlib? Somehow, this is not clearly documented for the subplot command. You need to use label parameter to create multiple axes at a same position (for more details, http://matplotlib.sourceforge.net/api/figure_api.html#matplotlib.figure.Figure.add_axes) axr=fig.add_subplot(1,1,1, label=r) axp=fig.add_subplot(1,1,1,projection='polar', label=p) Regards, -JJ -- Doing More with Less: The Next Generation Virtual Desktop What are the key obstacles that have prevented many mid-market businesses from deploying virtual desktops? How do next-generation virtual desktops provide companies an easier-to-deploy, easier-to-manage and more affordable virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] superimposition of Cartesian projection axis on a polar axis on the same position
On Thu, Sep 15, 2011 at 6:18 AM, Benjamin Root ben.r...@ou.edu wrote: There are some ways to do this, but I haven't tried them myself. http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/axislines.html Ben Root You may better stick to the subplot with polar projection if your original data is in polar coordinate. The axislines module basically assumes that your data is in rectlinear coordinate system. It only draws the gridlines and labels in curvelinear system (although you can combine both). Regards, -JJ -- Doing More with Less: The Next Generation Virtual Desktop What are the key obstacles that have prevented many mid-market businesses from deploying virtual desktops? How do next-generation virtual desktops provide companies an easier-to-deploy, easier-to-manage and more affordable virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] superimposition of Cartesian projection axis on a polar axis on the same position
On Thu, Sep 15, 2011 at 5:08 AM, Youngung Jeong youngung.je...@gmail.com wrote: but since contour function does not plot on the polar coordinate system I think this is not True, but I may misunderstood you. Can you post an example that does not work? Here is a simple example that shows it does work. But I hardly use polar coordinate, and my example could be too simple. ax = subplot(111, polar=True) aa = np.indices((10,10)) x = np.linspace(0., np.pi*2, 10) y = np.linspace(0., 10, 10) ax.pcolormesh(x, y, aa[0], cmap=gray) ax.contour(x, y, aa[0]) Both pcolormesh and contour gives a consistent result. However, I think, while the resulting contour lines are drawn in polar coordinate system, the actual contouring is done in rectlinear cooridinate system. So there may be some caveats. Regards, -JJ -- Doing More with Less: The Next Generation Virtual Desktop What are the key obstacles that have prevented many mid-market businesses from deploying virtual desktops? How do next-generation virtual desktops provide companies an easier-to-deploy, easier-to-manage and more affordable virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Suggestion for annotation arrow clipping
On Mon, Sep 12, 2011 at 3:20 AM, Daniel Hyams dhy...@gmail.com wrote: I would suggest the following modification to Annotation.draw in text.py. All it does is set a clip box so that the annotation and arrow is still drawn, but the arrow is clipped at the axes boundary. It is a much nicer effect than the annotation disappearing. I have made this modification in my source locally, and it works very well, but I thought I would suggest here for inclusion into the main code base. Can you explain more explicitly why you think this behavior is better? For example, what is the point of annotating something if that something is not visible? Also, annotating texts are often placed outside of axes area. I don't think clipping out the arrow is a good idea in this case. Just in case, this is just a default behavior. You can override this behavior without changing the mpl source code. Regards, -JJ -- Doing More with Less: The Next Generation Virtual Desktop What are the key obstacles that have prevented many mid-market businesses from deploying virtual desktops? How do next-generation virtual desktops provide companies an easier-to-deploy, easier-to-manage and more affordable virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Suggestion for annotation arrow clipping
You are correct JJ; the annotation_clip=False attribute was exactly what I was after, but somehow missed it in the docs :(. On Wed, Sep 14, 2011 at 9:09 PM, Jae-Joon Lee lee.j.j...@gmail.com wrote: On Mon, Sep 12, 2011 at 3:20 AM, Daniel Hyams dhy...@gmail.com wrote: I would suggest the following modification to Annotation.draw in text.py. All it does is set a clip box so that the annotation and arrow is still drawn, but the arrow is clipped at the axes boundary. It is a much nicer effect than the annotation disappearing. I have made this modification in my source locally, and it works very well, but I thought I would suggest here for inclusion into the main code base. Can you explain more explicitly why you think this behavior is better? For example, what is the point of annotating something if that something is not visible? Also, annotating texts are often placed outside of axes area. I don't think clipping out the arrow is a good idea in this case. Just in case, this is just a default behavior. You can override this behavior without changing the mpl source code. Regards, -JJ -- Daniel Hyams dhy...@gmail.com -- Doing More with Less: The Next Generation Virtual Desktop What are the key obstacles that have prevented many mid-market businesses from deploying virtual desktops? How do next-generation virtual desktops provide companies an easier-to-deploy, easier-to-manage and more affordable virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users