Re: [Matplotlib-users] making minor ticks into lines instead of ticks
Eric Firing wrote: 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') Thanks, that worked (well, it did what it was supposed to...) so it'd be nice if it was in the online docs as well as the docstring of the method;-) However, this isn't quite what I want... I only want the grid for the y-axis (ie: horizontal lines in the grid, but no vertical), how would 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
Re: [Matplotlib-users] plotting with missing data?
Eric Firing wrote: 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() What I ended up doing was getting my array to look like: from numpy import nan aa = [3.4,2.5,nan,nan,nan,1.1,2.2] values = numpy.array(aa) values = numpy.ma.masked_equal(values,nan) I only wish that masked_equal didn't blow up when aa contains datetime objects :-( 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] Latex in Figures
Dear All, I think the solution to my problem must be a one-liner, but I have been unsuccessful. I am trying to use latex formulas (nothing dramatically complicated) inside a figure. I suppose everything is working correctly on my system. I tried running the example at: http://www.scipy.org/Cookbook/Matplotlib/UsingTex and it works fine. But now have a look at this: #! /usr/bin/env python import scipy as s import numpy as n import pylab as p x=s.linspace(0.,(2.*s.pi),100) y=s.sin(x) z=s.exp(-x) #Now I create my figure fig = p.figure() axes = fig.gca() axes.plot(x,y, bo,label=(r$sin(\tau)$)) axes.plot(x,z,'--r',label=(r$\rm{decay}exp(\tau) $),linewidth=2.) p.xlabel('This is $\tau$') p.ylabel('$N_\infty(\tau)$') axes.legend() p.title('My test functions') p.grid(True) p.savefig(simple_test.pdf) p.clf() The point of the example figure is to try mixing latex formulas and text. Obviously, the result is not satisfactory. If I use \sin for instance, then I get an error message as that is not recognized. I think the fix to this must be rather simple for someone knowledgeable, but so far my attempts to get some decent mixed latex/text output have been unsuccessful. Can anyone help me with this simple example code? Many thanks Lorenzo - 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
On Tuesday 18 March 2008 10:50, Chris Withers wrote: Eric Firing wrote: It sounds like what you want it the pyplot figlegend command: def figlegend(handles, labels, loc, **kwargs): This feels like what I should be wanting except: - why does it need explicit parameters? why can't it pick up its lines and labels automatically, like legend does? - I think this could be a good improvement, but i'm not sure if it is easy to expand the functionality of the axes-legend (pyplot.legend or ax.legend) to that of a figure-legend(pyplot.figlegend or fig.legend with fig as a figure instance) without missing something, because there is no axes specified and therefore it is not obvious which lines should be displayed. In that case the default behaviour might become to take all lines from all axes and that's not what one always needs, or isn't it? In this case one should do it autonomous like: ax1 = subplot(111) # some plotting commands labels = [] for line in ax1.lines: label = line.get_label() labels.append(label) # or in one line: # labels = [line.get_label() for line in ax1.lines] figlegend(ax1.lines, labels, 'upper right') - it places the legend over the top of the current chart, I want it to the right, so it doesn't obscure the information on the chart... That's true and I have no idea how to overcome that (except for example subplot_adjust(top=0.8)). or you could directly use the Figure.legend method. How does this differ from the normal legend command? How do I get hold of a figure to call its legend method? fig=figure() fig.legend( ... ) and it is wrapped by figlegend( ... ) and therefore has the same functionality / arguments and it differs from the axes-legend like explained above ... How does figure.legend interact with subplots? I'm don't know, but maybe it doesn't interact with the axes / subplots at all. I have a bout 6 subplots on the same figure(?) and they each need to have a legend which is not obscuring the data plotted and isn't obscuring any other figure... I think in that case the axes-legend is the preferred one, but I have no idea how to ensure that nothing is cover by the legend without difficult tuning of the parameters or at least ensure that all labels have the same widths. best regards Matthias - 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
Hello Chris, for only horizontal lines you can use 'ax.yaxis.grid' like: --- from pylab import * figure() ax = axes() ax.set_yticks([0.0,0.5,1.0], minor=False) ax.set_yticks(list(linspace(0.0, 1.0, 11)), minor=True) ax.yaxis.grid(which='minor') show() --- best regards, Matthias On Tuesday 18 March 2008 10:22, Chris Withers wrote: Eric Firing wrote: 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') Thanks, that worked (well, it did what it was supposed to...) so it'd be nice if it was in the online docs as well as the docstring of the method;-) However, this isn't quite what I want... I only want the grid for the y-axis (ie: horizontal lines in the grid, but no vertical), how would 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
[Matplotlib-users] from pylab import nx?
Hi All, A few of the units demos include the lines: from pylab import nx ...but this import errors for me. Why is 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
Re: [Matplotlib-users] making minor ticks into lines instead of ticks
Matthias Michler wrote: ax.yaxis.grid(which='minor') This is what I was after, thankyou :-) However, the lines show up on top of the lines plotted, not behind them as I'd expect. I tried fiddling with the zorder of the plot and the grid but nothing had any effect. What am I doing wrong? How do I get the grid to show up behind the lines? 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] default zorder for plots?
Chris Withers wrote: I tried fiddling with the zorder of the plot and the grid but nothing had any effect. What am I doing wrong? How do I get the grid to show up behind the lines? Actually, I did manage to fix this by specifying a zorder of 10 for the plots and a zorder of 1 for the grids. What's the default zorder? Ideally I'd just like to supply the zorder to the grids... 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] default zorder for plots?
Hello Chris, in examples/zorder_demo.py I found: --- The default drawing order for axes is patches, lines, text. This order is determined by the zorder attribute. The following defaults are set Artist Z-order Patch / PatchCollection 1 Line2D / LineCollection 2 Text 3 - best regards Matthias On Tuesday 18 March 2008 12:15, Chris Withers wrote: Chris Withers wrote: I tried fiddling with the zorder of the plot and the grid but nothing had any effect. What am I doing wrong? How do I get the grid to show up behind the lines? Actually, I did manage to fix this by specifying a zorder of 10 for the plots and a zorder of 1 for the grids. What's the default zorder? Ideally I'd just like to supply the zorder to the grids... 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
hi again! did you look into the eps file, do you see that the font is included, eg. i have something like that in my eps files (still in the header section): %!PS-Adobe-3.0 Resource-Font %%Title: cmmi10 %%Copyright: Copyright (C) 1994, Basil K. Malyshev. All Rights Reserved.012BaKoMa Fonts Collection, Level-B. %%Creator: Converted from TrueType by PPR did you try saving the file as pdf? does this work? check the file properties (file menu - properties) and the fonts included in the file. that would at least show that the font is at least included, or not good luck! bernhard ps: if pdf works, it would be easy to convert to eps... On Mon, Mar 17, 2008 at 5:50 PM, Mark Bakker [EMAIL PROTECTED] wrote: 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
[Matplotlib-users] Basemap: Labeling parallels in polar stereographic projections
Hi, When using north/south polar stereographic projections from basemap, how can I get labels to show up on the parallels when none of them intersect a plot edge? Thanks, 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] Basemap: Labeling parallels in polar stereographic projections
Rich Fought wrote: Hi, When using north/south polar stereographic projections from basemap, how can I get labels to show up on the parallels when none of them intersect a plot edge? Thanks, Rich Rich: You'll have to do it manually with the axes text method. The drawparallels method can only label them where they intersect the edge of the map. Something like this perhaps: x,y = map(lon, lat) # get desired location in map projection coordinates ax = pylab.gca() # get current axes instance t = ax.text(x,y,latlab) # see axes.text docstring for **kwargs where map is the basemap instance, and lat,lon is where you want the label (latlab) to go. latlab can be defined like this: if latval 0: latlab = u'%g\N{DEGREE SIGN}N% latval else latlab = u'%g\N{DEGREE SIGN}S% latval HTH, -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX: (303)497-6449 NOAA/OAR/PSD R/PSD1Email : [EMAIL PROTECTED] 325 BroadwayOffice : Skaggs Research Cntr 1D-124 Boulder, CO, USA 80303-3328 Web: http://tinyurl.com/5telg - 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] Basemap: Labeling parallels in polar stereographic projections
Rich: You'll have to do it manually with the axes text method. The drawparallels method can only label them where they intersect the edge of the map. Thanks Jeff, that's what I was afraid of. New question: when adding axis labels (xlabel, ylabel) and figure title, these overlap basemap parallel/meridian labels ... I suppose I'll have to manually offset these items from the axis as well? 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] bar chart with dates on x-axis blows up
Hi All, I'm trying to plot a bar chart something like: from pylab import * from datetime import datetime,timedelta now = datetime.now() data1 = [1,2,3] data2 = [4,5,6] labels = [now-timedelta(1),now,now+timedelta(1)] bar(labels,data1) show() However, this blows up: Traceback (most recent call last): bar(labels,data1) File matplotlib\pyplot.py, line 1402, in bar ret = gca().bar(*args, **kwargs) File matplotlib\axes.py, line 3294, in bar self.add_patch(r) File matplotlib\axes.py, line 1146, in add_patch self._update_patch_limits(p) File matplotlib\axes.py, line 1152, in _update_patch_limits xys = self._get_verts_in_data_coords( File matplotlib\patches.py, line 362, in get_verts right = self.convert_xunits(x + self.width) TypeError: unsupported operand type(s) for +: 'datetime.datetime' and 'float' What am I doing wrong? Also, how do I go about adding a second set of bars? (ie: from data2)? (Bear in mind that in the real use, there are over 600 days worth of data, so I want to take advantage of the normal tick locators, etc as much as possible...) 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] Basemap: Labeling parallels in polar stereographic projections
Rich Fought wrote: Rich: You'll have to do it manually with the axes text method. The drawparallels method can only label them where they intersect the edge of the map. Thanks Jeff, that's what I was afraid of. New question: when adding axis labels (xlabel, ylabel) and figure title, these overlap basemap parallel/meridian labels ... I suppose I'll have to manually offset these items from the axis as well? Rich: You can pass xlabel and ylabel a position keyword (an x,y tuple). Same for title. See the pylab.text docstring for details. -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX: (303)497-6449 NOAA/OAR/PSD R/PSD1Email : [EMAIL PROTECTED] 325 BroadwayOffice : Skaggs Research Cntr 1D-124 Boulder, CO, USA 80303-3328 Web: http://tinyurl.com/5telg - 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 - When I set the fonttype to 42, the eps file gets much bigger, and the fonts seem included. The file contains the same section as yours: %!PS-TrueTypeFont-1.0-2.0 %%Title: Bitstream Vera Sans %%Copyright: Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. %%Creator: Converted from TrueType to type 42 by PPR But still, my eps file doesn't contain the greek letter. Strangely enough, when I read the epa file, there is a line that says 0.00 3.703125 moveto /chi glyphshow Could it be that I have a ghostview problem? It works with the old mpl, but maybe I need to upgrade? I am using version 4.4. BTW, pdf works fine, it is only eps that gives me trouble. Mark On Tue, Mar 18, 2008 at 3:47 PM, Bernhard Voigt [EMAIL PROTECTED] wrote: hi again! did you look into the eps file, do you see that the font is included, eg. i have something like that in my eps files (still in the header section): %!PS-Adobe-3.0 Resource-Font %%Title: cmmi10 %%Copyright: Copyright (C) 1994, Basil K. Malyshev. All Rights Reserved.012BaKoMa Fonts Collection, Level-B. %%Creator: Converted from TrueType by PPR did you try saving the file as pdf? does this work? check the file properties (file menu - properties) and the fonts included in the file. that would at least show that the font is at least included, or not good luck! bernhard ps: if pdf works, it would be easy to convert to eps... On Mon, Mar 17, 2008 at 5:50 PM, Mark Bakker [EMAIL PROTECTED] wrote: 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] placing legend outside of plot area
Matthias Michler wrote: - I think this could be a good improvement, but i'm not sure if it is easy to expand the functionality of the axes-legend (pyplot.legend or ax.legend) to that of a figure-legend(pyplot.figlegend or fig.legend with fig as a figure instance) without missing something, because there is no axes specified and therefore it is not obvious which lines should be displayed. True, although if there's only one axes, it's obvious ;-) (and if there's more than one, it should take an axes as a keyword parameter) In that case the default behaviour might become to take all lines from all axes and that's not what one always needs, or isn't it? Who knows, maybe someone would want that? The joy of building generic tools ;-) ax1 = subplot(111) # some plotting commands labels = [] for line in ax1.lines: label = line.get_label() labels.append(label) # or in one line: # labels = [line.get_label() for line in ax1.lines] figlegend(ax1.lines, labels, 'upper right') Yes, you see, it just feels to me like figlegend should have this code in it as it's likely to be duplicated every time I need to call figlegend. Why not just? figlegend(axes=ax1,'upper right') - it places the legend over the top of the current chart, I want it to the right, so it doesn't obscure the information on the chart... That's true and I have no idea how to overcome that (except for example subplot_adjust(top=0.8)). Yes, I'm just making do with this for now, but it would be really nice if MPL supported legends outsite the axes properly. It would also be good if you didn't have to manually fiddle with subplot_adjust because you rotated the labels for the x-axis through 90 degrees :-( How does figure.legend interact with subplots? I'm don't know, but maybe it doesn't interact with the axes / subplots at all. 'badly' I think is the best summary of the interaction ;-) I think in that case the axes-legend is the preferred one, but I have no idea how to ensure that nothing is cover by the legend without difficult tuning of the parameters or at least ensure that all labels have the same widths. Yeah :-/ This is where I am... If anyone has any magic code or suggestions, I'd love to hear 'em ;-) 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] Repost: problem exporting mathtext to eps file in 0.91.2
Just upgraded to Ghostview 4.9 with Ghostscript 8.61, but it still doesn't work. Does anybody see greek symbols in eps files with mpl 0.92.1? Mark On Tue, Mar 18, 2008 at 5:07 PM, Mark Bakker [EMAIL PROTECTED] wrote: Hello Bernhard - When I set the fonttype to 42, the eps file gets much bigger, and the fonts seem included. The file contains the same section as yours: %!PS-TrueTypeFont-1.0-2.0 %%Title: Bitstream Vera Sans %%Copyright: Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. %%Creator: Converted from TrueType to type 42 by PPR But still, my eps file doesn't contain the greek letter. Strangely enough, when I read the epa file, there is a line that says 0.00 3.703125 moveto /chi glyphshow Could it be that I have a ghostview problem? It works with the old mpl, but maybe I need to upgrade? I am using version 4.4. BTW, pdf works fine, it is only eps that gives me trouble. Mark On Tue, Mar 18, 2008 at 3:47 PM, Bernhard Voigt [EMAIL PROTECTED] wrote: hi again! did you look into the eps file, do you see that the font is included, eg. i have something like that in my eps files (still in the header section): %!PS-Adobe-3.0 Resource-Font %%Title: cmmi10 %%Copyright: Copyright (C) 1994, Basil K. Malyshev. All Rights Reserved.012BaKoMa Fonts Collection, Level-B. %%Creator: Converted from TrueType by PPR did you try saving the file as pdf? does this work? check the file properties (file menu - properties) and the fonts included in the file. that would at least show that the font is at least included, or not good luck! bernhard ps: if pdf works, it would be easy to convert to eps... On Mon, Mar 17, 2008 at 5:50 PM, Mark Bakker [EMAIL PROTECTED] wrote: 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] from pylab import nx?
Chris Withers wrote: Hi All, A few of the units demos include the lines: from pylab import nx ...but this import errors for me. Not sure if this is relevant, but NX is a frequently used shorthand for the NetworkX graph/network analysis package from Los Alamos National Labs: https://networkx.lanl.gov/reference/networkx/networkx-module.html i.e. people do: import NetworkX as nx It has a sub-package for drawing networks in pylab (networkx.drawing.nx_pylab). Maybe at some point someone was trying to integrate NetworkX with pylab directly and some tests got left laying around? The NetworkX guys would probably know. -- Zane Selvans Amateur Human [EMAIL PROTECTED] 303/815-6866 PGP Key: 55E0815F begin:vcard fn:Zane Selvans n:Selvans;Zane org:Earthlings adr:;;200 S. Parkwood Ave.;Pasadena;CA;91107;USA email;internet:[EMAIL PROTECTED] title:Amateur Human tel;cell:(303) 815-6866 x-mozilla-html:TRUE url:https://ideotrope.org version:2.1 end:vcard - 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] from pylab import nx?
Chris Withers wrote: Hi All, A few of the units demos include the lines: from pylab import nx ...but this import errors for me. Why is that? If you are referring to scripts in the matplotlib/examples/ subdirectory then you must have a version in which some of those scripts had not been brought up to date with the rest of matplotlib. (Historically, this has often been the case--only a subset of the examples are maintained. Right now, for example, simple3d.py is broken. 3D plotting is itself unmaintained, so there is little incentive to do anything about the example.) In the svn version there are no lines importing nx. This was an abbreviation for the numerix module, which was a compatibility wrapper for the three different numeric packages (Numeric, numarray, and numpy) until numpy was fully developed, rendering Numeric and numarray obsolete. 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
[Matplotlib-users] Gappy bars when no edge specified?
Hi All, Why does the following render small gaps horizontally between the bars? import pylab data = [1,2,1,2,4,2] labels = pylab.arange(len(data1)) pylab.bar(labels,data1,width=1,linewidth=0) pylab.show() How do I make the small gaps go away? 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] plotting with missing data?
Chris Withers wrote: Eric Firing wrote: 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() What I ended up doing was getting my array to look like: from numpy import nan aa = [3.4,2.5,nan,nan,nan,1.1,2.2] values = numpy.array(aa) values = numpy.ma.masked_equal(values,nan) This is not doing what you think it is, because any logical operation with a Nan returns False: In [4]:nan == nan Out[4]:False You should use numpy.masked_where(numpy.isnan(aa), aa). In some places in mpl, nans are treated as missing values, but this is not uniformly true, so it is better not to count on it. Your values array is not actually getting masked at the nans: In [7]:aa = array([1,nan,2]) In [8]:aa Out[8]:array([ 1., NaN, 2.]) In [9]:values = ma.masked_equal(aa, nan) In [10]:values Out[10]: masked_array(data = [1.0 nan 2.0], mask = [False False False], fill_value=1e+20) Eric I only wish that masked_equal didn't blow up when aa contains datetime objects :-( 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
[Matplotlib-users] gradient fills for bar charts?
Hi All, Is there any way in MPL to do gradient filled bars like you can in Excel? (click data series - format data series - patterns - fill effects - gradient - diagonal up) 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] Gappy bars when no edge specified?
Chris Withers wrote: Hi All, Why does the following render small gaps horizontally between the bars? import pylab data = [1,2,1,2,4,2] labels = pylab.arange(len(data1)) pylab.bar(labels,data1,width=1,linewidth=0) pylab.show() How do I make the small gaps go away? With svn I don't see any gaps in the example above, either on screen or when saved to a png file. 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 - 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] Gappy bars when no edge specified?
Eric Firing wrote: How do I make the small gaps go away? With svn I don't see any gaps in the example above, either on screen or when saved to a png file. That's cool'n'all, but when is svn going to make it into a Windows binary release? ;-) cheers, Chris - not sure how to compile MPL on Windows :-( -- 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?
On Tuesday 18 March 2008 16:17:08 Eric Firing wrote: Chris Withers wrote: Eric Firing wrote: You should use numpy.masked_where(numpy.isnan(aa), aa). or use masked_invalid directly (shortcut to masked_where((isnan(aa) | isinf(aa)) I only wish that masked_equal didn't blow up when aa contains datetime objects :-( Could you send me an example of the kind of data you're using ? As it seems you're dealing with series indexed in time, you may want to try scikits.timeseries, a package Matt Knox and myself implemented for that very reason. - 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?
Pierre GM wrote: On Tuesday 18 March 2008 16:17:08 Eric Firing wrote: Chris Withers wrote: Eric Firing wrote: You should use numpy.masked_where(numpy.isnan(aa), aa). (I meant numpy.ma.masked_where(...)) or use masked_invalid directly (shortcut to masked_where((isnan(aa) | isinf(aa)) I don't see it in numpy.ma, with numpy from svn. In any case, the fastest method is masked_where(~numpy.isfinite(aa), aa): In [1]:import numpy In [2]:xx = numpy.random.rand(1) In [3]:xx[xx0.8] = numpy.nan In [6]:timeit numpy.ma.masked_where(~numpy.isfinite(xx), xx) 1 loops, best of 3: 83.9 µs per loop In [7]:timeit numpy.ma.masked_where(numpy.isnan(xx), xx) 1 loops, best of 3: 119 µs per loop In [9]:timeit numpy.ma.masked_where((numpy.isnan(xx)|numpy.isinf(xx)), xx) 1000 loops, best of 3: 260 µs per loop So, wherever you do have masked_invalid defined, you might want to use the faster implementation with ~isfinite. Eric I only wish that masked_equal didn't blow up when aa contains datetime objects :-( Could you send me an example of the kind of data you're using ? As it seems you're dealing with series indexed in time, you may want to try scikits.timeseries, a package Matt Knox and myself implemented for that very reason. - 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] Debugging: Many Multiple Plots -- Update
On Tue, 18 Mar 2008, Rich Shepard wrote: File termset-test-data.py, line 389, in testCode pylab.hold() Replacing the line above with pylab.hold(False) seems to put me in a non-stop loop. I'll run the test code in winpdb, but still want suggestions on how to get the output I need. Rich -- Richard B. Shepard, Ph.D. | IntegrityCredibility Applied Ecosystem Services, Inc.|Innovation http://www.appl-ecosys.com Voice: 503-667-4517 Fax: 503-667-8863 - 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] matplotlib threadsafe?
At least the Agg backend *looks* to be reasonably threadsafe -- there are no obvious gotchas like global variables etc. Note, though, that multithreading may not gain much in the way of performance since the global interpreter lock is never released around long-running C blocks. However, I can't speak about this from any experience -- so, maybe it needs some trying. Any patches to help with thread safety and performance are of course welcome ;) Cheers, Mike Chris Withers wrote: Hi All, I'm wondering what work people have done with matplotlib in multi-threaded environments such as your average python web framework. Is matplotlib threadsafe? How have people gone about safely using it in a multi-threaded environment? 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] Latex in Figures
Mattias' suggestion is a good one if you have a full TeX environment installed. Otherwise, it looks like you're using some features that are only available in 0.91.x (but not earlier versions), for example \sin. If you can, try upgrading. Cheers, Mike Lorenzo Isella wrote: Dear All, I think the solution to my problem must be a one-liner, but I have been unsuccessful. I am trying to use latex formulas (nothing dramatically complicated) inside a figure. I suppose everything is working correctly on my system. I tried running the example at: http://www.scipy.org/Cookbook/Matplotlib/UsingTex and it works fine. But now have a look at this: #! /usr/bin/env python import scipy as s import numpy as n import pylab as p x=s.linspace(0.,(2.*s.pi),100) y=s.sin(x) z=s.exp(-x) #Now I create my figure fig = p.figure() axes = fig.gca() axes.plot(x,y, bo,label=(r$sin(\tau)$)) axes.plot(x,z,'--r',label=(r$\rm{decay}exp(\tau) $),linewidth=2.) p.xlabel('This is $\tau$') p.ylabel('$N_\infty(\tau)$') axes.legend() p.title('My test functions') p.grid(True) p.savefig(simple_test.pdf) p.clf() The point of the example figure is to try mixing latex formulas and text. Obviously, the result is not satisfactory. If I use \sin for instance, then I get an error message as that is not recognized. I think the fix to this must be rather simple for someone knowledgeable, but so far my attempts to get some decent mixed latex/text output have been unsuccessful. Can anyone help me with this simple example code? Many thanks Lorenzo - 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] from pylab import nx?
Eric Firing wrote: Chris Withers wrote: Hi All, A few of the units demos include the lines: from pylab import nx ...but this import errors for me. Why is that? If you are referring to scripts in the matplotlib/examples/ subdirectory then you must have a version in which some of those scripts had not been brought up to date with the rest of matplotlib. (Historically, this has often been the case--only a subset of the examples are maintained. Right now, for example, simple3d.py is broken. 3D plotting is itself unmaintained, so there is little incentive to do anything about the example.) In the svn version there are no lines importing nx. This was an abbreviation for the numerix module, which was a compatibility wrapper for the three different numeric packages (Numeric, numarray, and numpy) until numpy was fully developed, rendering Numeric and numarray obsolete. Slightly OT, but if matplotlib is participating in any sort of internship projects (Google Summer of Code etc.) that would be a great student project -- to clean up all the examples, removing dead ones, editing for consistency etc. Cheers, Mike - 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] matplotlib threadsafe?
In general, I don't think mpl is threadsafe at all; it uses global variables, such as all the rc parameters, that could easily be modified by one thread while being used by another. I think that great care would be needed if one wanted to have multiple threads making plots. Having one plotting thread and any number of threads doing other things, however, should be OK. Michael Droettboom wrote: At least the Agg backend *looks* to be reasonably threadsafe -- there are no obvious gotchas like global variables etc. Note, though, that multithreading may not gain much in the way of performance since the global interpreter lock is never released around long-running C blocks. Possibly this could be changed. The danger would be accidentally modifying or deleting an array that is being used by C extension code. However, I can't speak about this from any experience -- so, maybe it needs some trying. Any patches to help with thread safety and performance are of course welcome ;) At the very least, I think we would have to take all the global state information and put it in a class instance, so there could be multiple plotting machines. Pyplot would then instantiate and use one of these; the OO API would allow one to instantiate any number of them. I have not thought about how easy or hard this would be. Eric Cheers, Mike Chris Withers wrote: Hi All, I'm wondering what work people have done with matplotlib in multi-threaded environments such as your average python web framework. Is matplotlib threadsafe? How have people gone about safely using it in a multi-threaded environment? 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 - 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