Re: [Matplotlib-users] plotting with missing data?
Eric Firing wrote: Chris, Use masked arrays. See masked_demo.py in the mpl examples subdirectory. Hi Eric, I took a look at that, but it uses: import matplotlib.numerix.npyma as ma ...and matplotlib.numerix isn't listed in the API reference. Where are the docs for this? Specifically, what I have is an array like so: ['','','',1.1,2.2] I want to mask the strings out so I don't get ValueErrors raised when I call plot functions with that array. How should I do that? cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] placing legend outside of plot area
Hi All, How would I go about placing the legend outside the plot area? All the parameters to legend seem to place the legend somewhere within the plot and I'd like to place it outside the plot, either above, below or, most commonly, to the right, in the same way as the Excel legend positions allow. cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] placing legend outside of plot area
Hello Chris, I'm not sure if there was an example in matplotlib, but the following works for me: - from pylab import * figure() subplot(111) subplots_adjust(right=0.7) plot(arange(10), label='linear') plot(arange(10)**2, label='quadratic') legend(loc=(1.1,0.5)) show() I hope this is useful to you. best regards Matthias On Monday 17 March 2008 12:42, Chris Withers wrote: Hi All, How would I go about placing the legend outside the plot area? All the parameters to legend seem to place the legend somewhere within the plot and I'd like to place it outside the plot, either above, below or, most commonly, to the right, in the same way as the Excel legend positions allow. cheers, Chris - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Transforms
Rich Fought wrote: I'm plotting some grid data using pcolor, and trying to get canvas pixel locations of data points using the ax.transData.xy_tup() method. I am saving these figures to PNG files using the default Agg backend. When I open these images up in Gimp and check the pixel locations, the X pixel locations are accurate, but the Y pixel locations I am getting from matplotlib seem to be exaggerated the further away from Y=0 I go. Am I using this method incorrectly? Could this be an artifact of the rendering to PNG? I determined what is causing the exaggerated y-pixel values. I was using axes().set_aspect('equal') on the figure and this apparently does not get taken into account when using ax.transData.xy_tup() I tried setting the aspect in the original fig.add_subplot, but got the same incorrect results. ax = fig.add_subplot(111, aspect='equal') Leaving the aspect alone gives correct pixel results. Is this a bug, or expected behavior? Rich - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] placing legend outside of plot area
Hi Matthias, Matthias Michler wrote: I'm not sure if there was an example in matplotlib, but the following works for me: - from pylab import * figure() subplot(111) subplots_adjust(right=0.7) plot(arange(10), label='linear') plot(arange(10)**2, label='quadratic') legend(loc=(1.1,0.5)) show() Thanks for this. This is exactly what I was after except that the legend now appears about 25% off the right hand of the screen or whatever I save the figure to. How can I have the legend as placed above but with the whole of it showing? cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] how to remove an xlabel?
Hello Chris, you can try xlabel of an empty string: xlabel(' ') regards Matthias On Monday 17 March 2008 17:11, Chris Withers wrote: Hi All, I'm using plot_date to plot some dates, but this sets an xlabel, and I don't want the plot to have an xlabel. How do I remove it? I tried: xlabel(None) ...but that just set the xlabel to 'None'... cheers, Chris - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] placing legend outside of plot area
Hi Chris, sorry I don't understand what you are exactly looking for. Maybe you could explain it once more. In general I think all one can do is to play around with the parameters in 'subplots_adjust' and the location in 'legend' to get the best result. I'm not an expert but I think there's no default behaviour covering all needs (outside the axes and best located), because for example the legend width is influenced by the length of the labels. much effort and best regards Matthias On Monday 17 March 2008 17:13, Chris Withers wrote: Hi Matthias, Matthias Michler wrote: I'm not sure if there was an example in matplotlib, but the following works for me: - from pylab import * figure() subplot(111) subplots_adjust(right=0.7) plot(arange(10), label='linear') plot(arange(10)**2, label='quadratic') legend(loc=(1.1,0.5)) show() Thanks for this. This is exactly what I was after except that the legend now appears about 25% off the right hand of the screen or whatever I save the figure to. How can I have the legend as placed above but with the whole of it showing? cheers, Chris - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Repost: problem exporting mathtext to eps file in 0.91.2
Hello Bernhard and others - I tried all the options, but nothing works. Whenever I type a greek symbol in mathtext and save the figure as eps, the greek symbols don't show up. Confirmed on several windows machines. Python 2.4. mpl 0.91.2. (but it worked fine under 0.90.1). Does anybody else have this problem? It is starting to look like a bug. Thanks, Mark On Fri, Mar 14, 2008 at 5:06 PM, Bernhard Voigt [EMAIL PROTECTED] wrote: what are the values of pdf and ps fonttype in your rc file? try using this: ps.fonttype : 3 # Output Type 3 (Type3) or Type 42 (TrueType) pdf.fonttype : 3 # Output Type 3 (Type3) or Type 42 (TrueType) this includes the missing symbols into the ps/pdf file, if you choose type 42 the complete font will be inserted in the resulting file. in addition check the mathtext.fontset setting, try using stix or cm: mathtext.fontset: cm best wishes, bernhard On Fri, Mar 14, 2008 at 2:15 PM, Mark Bakker [EMAIL PROTECTED] wrote: Hello - I am trying this again. I recently upgraded to 0.91.2, and export of mathtext to eps files seems broken (at least with the default matplotlibrc file). Figure looks great on the screen (interactive mode). Exporting to png still works fine. But writing to eps file, the greek symbols (I tried \theta and \lambda) don't show up at all, while the latin symbols (a,b,c,etc) look very ugly (different font than used to). Any suggestions? Anybody seenig the same behavior? Thanks, Mark - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] how to remove an xlabel?
Matthias Michler wrote: you can try xlabel of an empty string: xlabel(' ') Thanks, and yes, a truly empty string xlabel(''), works :-) cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] placing legend outside of plot area
Matthias Michler wrote: sorry I don't understand what you are exactly looking for. Maybe you could explain it once more. Well, what you provided was pretty close, it's just that the legend was partly placed outside the figure... In general I think all one can do is to play around with the parameters in 'subplots_adjust' and the location in 'legend' to get the best result. I'm not an expert but I think there's no default behaviour covering all needs (outside the axes and best located), because for example the legend width is influenced by the length of the labels. Right, this is the problem. The location your example provided is perfect, except that I may have no control over the length of the legend text, and so need to find a way to make sure the figure size is such that the legend doesn't end up being half off the figure... Anyone know how to do that? (and thanks to Matthias for all his help! :-) ) cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] plotting with missing data?
Chris Withers wrote: Eric Firing wrote: Chris, Use masked arrays. See masked_demo.py in the mpl examples subdirectory. Hi Eric, I took a look at that, but it uses: import matplotlib.numerix.npyma as ma ...and matplotlib.numerix isn't listed in the API reference. Where are the docs for this? numerix is obsolete, and numerix.npyma was a temporary method to provide access to either of two masked array implementations. It is probably time for me to remove it from the examples. Substitute import numpy.ma as ma The ma module is documented as part of numpy. Specifically, what I have is an array like so: ['','','',1.1,2.2] Try something like this: import numpy.ma as ma from pylab import * aa = [3.4, 2.5, '','','',1.1,2.2] def to_num(arg): if arg == '': return .0 return arg aanum = array([to_num(arg) for arg in aa]) aamasked = ma.masked_where(aanum==.0, aanum) plot(aamasked) show() Eric I want to mask the strings out so I don't get ValueErrors raised when I call plot functions with that array. How should I do that? cheers, Chris - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] making minor ticks into lines instead of ticks
Chris Withers wrote: Hi All, How do I go about showing minor ticks as lines across the whole plot, as opposed to just little ticks at the side? I can get the major ticks to show by doing grid(True), but how do I get the same effect for minor ticks? Try grid(True, which='minor') Eric cheers, Chris - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Transforms
Rich, The transforms can be modified at drawing time, so you need to get the pixel locations after the plot has been drawn. Are you doing this? Eric Rich Fought wrote: Rich Fought wrote: I'm plotting some grid data using pcolor, and trying to get canvas pixel locations of data points using the ax.transData.xy_tup() method. I am saving these figures to PNG files using the default Agg backend. When I open these images up in Gimp and check the pixel locations, the X pixel locations are accurate, but the Y pixel locations I am getting from matplotlib seem to be exaggerated the further away from Y=0 I go. Am I using this method incorrectly? Could this be an artifact of the rendering to PNG? I determined what is causing the exaggerated y-pixel values. I was using axes().set_aspect('equal') on the figure and this apparently does not get taken into account when using ax.transData.xy_tup() I tried setting the aspect in the original fig.add_subplot, but got the same incorrect results. ax = fig.add_subplot(111, aspect='equal') Leaving the aspect alone gives correct pixel results. Is this a bug, or expected behavior? Rich - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] placing legend outside of plot area
It sounds like what you want it the pyplot figlegend command: def figlegend(handles, labels, loc, **kwargs): Place a legend in the figure. Labels are a sequence of strings, handles is a sequence of line or patch instances, and loc can be a string r an integer specifying the legend location USAGE: legend( (line1, line2, line3), ('label1', 'label2', 'label3'), 'upper right') See help(legend) for information about the location codes A matplotlib.legend.Legend instance is returned or you could directly use the Figure.legend method. The relevant part of the docstring regarding placement in the figure is here: The LOC location codes are 'best' : 0, (currently not supported for figure legends) 'upper right' : 1, 'upper left' : 2, 'lower left' : 3, 'lower right' : 4, 'right': 5, 'center left' : 6, 'center right' : 7, 'lower center' : 8, 'upper center' : 9, 'center' : 10, loc can also be an (x,y) tuple in figure coords, which specifies the lower left of the legend box. figure coords are (0,0) is the left, bottom of the figure and 1,1 is the right, top. Eric Chris Withers wrote: Matthias Michler wrote: sorry I don't understand what you are exactly looking for. Maybe you could explain it once more. Well, what you provided was pretty close, it's just that the legend was partly placed outside the figure... In general I think all one can do is to play around with the parameters in 'subplots_adjust' and the location in 'legend' to get the best result. I'm not an expert but I think there's no default behaviour covering all needs (outside the axes and best located), because for example the legend width is influenced by the length of the labels. Right, this is the problem. The location your example provided is perfect, except that I may have no control over the length of the legend text, and so need to find a way to make sure the figure size is such that the legend doesn't end up being half off the figure... Anyone know how to do that? (and thanks to Matthias for all his help! :-) ) cheers, Chris - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Transforms
Eric Firing wrote: The transforms can be modified at drawing time, so you need to get the pixel locations after the plot has been drawn. Are you doing this? Eric, Thank you! I put the transforms after savefig() and it works like a champ now. Rich - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Bogus colour gradients in imshow()
Hi, I'm plotting some 2D grid data using imshow(). However, one of my test problems involves a Gaussian peak in the center of my grid. For some strange reason this Gaussian looks like 5 distinct peaks. It looks like the values are only set at the centers of my grid cells and then the colour gradients are interpolate from this central point and a background. You can have a look at the original plot and a magnified one at http://www.maths.monash.edu.au/~clerrahn/gaussian1.png http://www.maths.monash.edu.au/~clerrahn/gaussian2.png Cheers, Christian - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Bogus colour gradients in imshow()
You can choose the kind of interpolation that gets used: * interpolation is one of: 'nearest', 'bilinear', 'bicubic', 'spline16', 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos', 'blackman' if interpolation is None, default to rc image.interpolation. See also th the filternorm and filterrad parameters If you don't want interpolation at all, just solid filled squares, then use interpolation='nearest'. Eric Christian Lerrahn wrote: Hi, I'm plotting some 2D grid data using imshow(). However, one of my test problems involves a Gaussian peak in the center of my grid. For some strange reason this Gaussian looks like 5 distinct peaks. It looks like the values are only set at the centers of my grid cells and then the colour gradients are interpolate from this central point and a background. You can have a look at the original plot and a magnified one at http://www.maths.monash.edu.au/~clerrahn/gaussian1.png http://www.maths.monash.edu.au/~clerrahn/gaussian2.png Cheers, Christian - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] dynamic_collections.py example not working in SVN?
Hi, I tried to run the dynamic_collections.py example in the source directory (SVN revision 5002) but got the following error: Traceback (most recent call last): File dynamic_collection.py, line 23, in module transOffset = ax.transData, TypeError: __init__() got multiple values for keyword argument 'numsides' I removed the numsides=5 keyword argument (line 16) from dynamic_collections.py, and while it lets the example run without error, the dynamic aspect doesn't work. That is, the initial plot with a single point appears but pressing 'a' or 'd' does nothing (when it should add or delete a point). Any ideas on how to get this working? thanks, -Ryan - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users