Re: [Matplotlib-users] colorbar+log+latex
Ok, great, it works ! However, I do not understand why latex mode is disabled by default... Anyway, thanks a lot, yves Jae-Joon Lee wrote: I'm not sure if the default formatter needs to be changed. However, you may try import matplotlib.ticker as ticker formatter=ticker.LogFormatterMathtext() colorbar(format=formatter) which will render colorbar ticklabels with mathtext mode. Regards, -JJ On Fri, Apr 16, 2010 at 3:56 AM, Yves Revaz yves.re...@epfl.ch wrote: Dear list, I want to plot colored points using scatter, with the color of points corresponding to the log of the z value of the points. the corresponding scatter command is : scatter(x,y,c=z,norm=colors.LogNorm()) unfortunately, then I then draw a colorbar simply calling colorbar() the fonts used for the color bar is no longer in latex mode, as it was if I use a lin scale in scatter(), i.e., norm=None. Is it a bug ? Any solution ? Thanks, yves -- (o o) oOO--(_)--OOo--- Dr. Yves Revaz Laboratory of Astrophysics EPFL Observatoire de Sauverny Tel : ++ 41 22 379 24 28 51. Ch. des Maillettes Fax : ++ 41 22 379 22 05 1290 Sauverny e-mail : yves.re...@epfl.ch SWITZERLAND Web : http://www.lunix.ch/revaz/ -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- (o o) oOO--(_)--OOo--- Dr. Yves Revaz Laboratory of Astrophysics EPFL Observatoire de Sauverny Tel : ++ 41 22 379 24 28 51. Ch. des Maillettes Fax : ++ 41 22 379 22 05 1290 Sauverny e-mail : yves.re...@epfl.ch SWITZERLAND Web : http://www.lunix.ch/revaz/ -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Turning off minor grids on log scaled plot
On Monday 19 April 2010 20:36:15 Gökhan Sever wrote: On Mon, Apr 19, 2010 at 1:31 AM, Matthias Michler matthiasmich...@gmx.netwrote: On Sunday 18 April 2010 00:52:57 Gökhan Sever wrote: Hello, Let say we have a figure created by: plt.plot(range(100)) On WX backend plt.grid(1) or key G responds finely for turning on/off the grid lines. However when I log-scale both axes then plt.grid(1 or 0) or G doesn't respond on minor grid lines. Is there a way to control this behavior? Thanks. Hi Gökhan, I can confirm your findings and I hope my attached patch (against current svn) solves this problem. In the axes.grid the boolean 'b' was set to 'True' if the kwarg 'which' was suplied, because it was part of the **kwargs and so always b was True in the axis (e.g. ax.xaxis). Now I get a grid on the minor-ticks by calling: ax.grid(True, which=majorminor) and remove the the minortick-grid lines / all grid lines by calling ax.grid(False, which=minor) ax.grid(False, which=majorminor) Kind regards, Matthias Works great both majorminor and minormajor works as a which keyword. One minor thing. When I updated backend_bases.py as it doesn't function correctly when I toggle G if event.key in grid_keys: event.inaxes.grid(which='majorminor') self.canvas.draw() Could you take a look this one as well? Thanks. This change should go into the svn. Hi Gökhan, thanks for testing this small patch. Maybe one of the developers could submit it or should I place it on the patch-tracker? About the toggling of all grid-lines using event.inaxes.grid(which='majorminor') I not sure this is intended, because this means that you will allways toggling major and minor tick - grid lines using key 'g' instead of only toggling major tick grid lines. Maybe a developer or other users could comment on the preferred behavior. Kind regards, Matthias -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] skipping mpl-axes-interaction during key_press_event's
On Wednesday 17 March 2010 15:58:11 Matthias Michler wrote: On Wednesday 17 March 2010 15:05:32 John Hunter wrote: On Wed, Mar 17, 2010 at 4:10 AM, Matthias Michler matthiasmich...@gmx.net wrote: once more I'd like to ask for comments about my feature request and proposed patch. Should I post it at the 'feature request' or 'patch' tracker? Thanks in advance for any comments. Hey Matthias -- This should be placed on the patch tracker, and you can respond back to this list with a link to the patch. I'll review it when I get a minute. Thanks for following up and for making patches against branch and HEAD. JDH Hi John, thanks for taking the time and the offer to review the patch. The new tracker is skipping mpl-axes-interaction during key_press_event\'s - ID: 2971996 (http://sourceforge.net/tracker/?func=detailaid=2971996group_id=80706atid=560722) Hi John, Hello list, this is the one month reminder of my patch, which allows to switch off key events that e.g. scale the y-axis via 'l' etc. . Please let me now, if there is anything I can do to improve the patch. Kind regards, Matthias -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] about linux install
Hi: I install matplotlib under Red hat Linux .But I can't find Tkinter, can't use TkAgg.I install python is ActivePython6.5. please tell me how to do! Thank you! -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] How to show interactive plot window from program
Hello, When I'm calling the pyplot.plot function from ipython, I get a nice dialog in which I can zoom, pan save. How can I achieve the same thing from a non-interactive program? I tried fig = plt.figure() ax = fig.add_subplot(111) ax.contourf(stuff) fig.show() but this program terminates without showing anything. Is there a function that I can call that shows up the interactive window and only returns once I close the window? Thanks, -Nikolaus -- »Time flies like an arrow, fruit flies like a Banana.« PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to show interactive plot window from program
On Tue, Apr 20, 2010 at 8:56 AM, Nikolaus Rath nikol...@rath.org wrote: Hello, When I'm calling the pyplot.plot function from ipython, I get a nice dialog in which I can zoom, pan save. How can I achieve the same thing from a non-interactive program? I tried fig = plt.figure() ax = fig.add_subplot(111) ax.contourf(stuff) fig.show() Use plt.show() instead of fig.show() Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] ticks at 0 and 2pi
Hello, I'm trying to plot something from 0 to 2pi: fig = plt.figure() ax = fig.add_subplot(111) ax.set_title('Radial Magnetic Field') ax.set_ylabel(r'Poloidal Angle $\theta$') ax.set_xlabel(r'Toroidal Angle $\phi$') ax.set_xticks([0, 2 * math.pi]) ax.set_xticklabels(['0', r'$2\pi$']) ax.set_yticklabels([r'$-\pi$', r'$\pi$']) ax.set_yticks([-math.pi, math.pi]) ax.set_xlim(xmin=0, xmax=2 * math.pi) ax.set_ylim(ymin= -math.pi, ymax=math.pi) But unfortunately the ticks for x=2pi and y=pi are not shown. They do show up if I move them a tiny bit: ax.set_xticks([0, 2 * math.pi * 0.98]) ax.set_yticks([-math.pi, math.pi * 0.98]) But obviously this is ugly. Is there a way to show the labels without moving the to the wrong position and without extending the axis limits (since that introduces a white border)? Best, -Nikolaus -- »Time flies like an arrow, fruit flies like a Banana.« PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] ticks at 0 and 2pi
On Tue, Apr 20, 2010 at 8:58 AM, Nikolaus Rath nikol...@rath.org wrote: Hello, I'm trying to plot something from 0 to 2pi: fig = plt.figure() ax = fig.add_subplot(111) ax.set_title('Radial Magnetic Field') ax.set_ylabel(r'Poloidal Angle $\theta$') ax.set_xlabel(r'Toroidal Angle $\phi$') ax.set_xticks([0, 2 * math.pi]) ax.set_xticklabels(['0', r'$2\pi$']) ax.set_yticklabels([r'$-\pi$', r'$\pi$']) ax.set_yticks([-math.pi, math.pi]) ax.set_xlim(xmin=0, xmax=2 * math.pi) ax.set_ylim(ymin= -math.pi, ymax=math.pi) I don't see the problem here, I get the ticks as specified. What version of matplotlib are you using? What backend are you using? Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Question about mathtext
That's great news -- glad we got to the bottom of it, though I'm not sure how your system may have become wedged like that in the first place. I should have thought of this earlier, but if it happens again, can you send me your fontList.cache file so I can inspect it? There may be a bug in the font lookup code there. Cheers, Mike william ratcliff wrote: Progress: c:\python25\lib\site-packages\matplotlib\mathtext.py:848: MathTextWarning: Font 'rm' does not have a glyph for '\perp' MathTextWarning) c:\python25\lib\site-packages\matplotlib\mathtext.py:849: MathTextWarning: Substituting with a dummy symbol. warn(Substituting with a dummy symbol., MathTextWarning) Next, I followed your suggestion and deleted the fontlist.cache file and that solved everything. Thanks!!! So, that's where the dummy symbol is coming from. On Mon, Apr 19, 2010 at 3:42 PM, Michael Droettboom md...@stsci.edu wrote: Hmm... I'm a bit stumped. Can you print out the values of these from your script, i.e. put the following at the top: from matplotlib import rcParams print rcParams['mathtext.fontset'] print rcParams['mathtext.default'] Can you try deleting your fontList.cache file? Mike william ratcliff wrote: From my mpl-data directory, here's what's in the mathtext section of my matplotlibrc file: # The following settings allow you to select the fonts in math mode. # They map from a TeX font name to a fontconfig font pattern. # These settings are only used if mathtext.fontset is 'custom'. # Note that this custom mode is unsupported and may go away in the # future. #mathtext.cal : cursive #mathtext.rm : serif #mathtext.tt : monospace #mathtext.it : serif:italic #mathtext.bf : serif:bold #mathtext.sf : sans #mathtext.fontset : cm # Should be 'cm' (Computer Modern), 'stix', # 'stixsans' or 'custom' mathtext.fallback_to_cm : True # When True, use symbols from the Computer Modern # fonts when a symbol can not be found in one of # the custom math fonts. #mathtext.default : it # The default font to use for math. # Can be any of the LaTeX font names, including # the special name regular for the same font On Mon, Apr 19, 2010 at 2:40 PM, Michael Droettboom md...@stsci.edu wrote: The puzzling thing is this: u'C:\\WINDOWS\\Fonts\\HTOWERTI.TTF' It's using a custom font in mathtext. Are you setting the rcParams mathtext.fontset or mathtext.default? That may the culprit, and if not, it's a bug that it's trying to use that font. Mike william ratcliff wrote: On the plus side, there is no longer an error when I apply the patch. On the downside, it generates a rather strange symbol instead of a perpendicular symbolLet me try to quickly upgrade to 0.99.1. I did that and I seem to get the same error... On Mon, Apr 19, 2010 at 10:49 AM, Michael Droettboom md...@stsci.edu wrote: Does forcibly casting the path to a string resolve the problem? i.e. applying this patch: Index: mathtext.py === --- mathtext.py (revision 8216) +++ mathtext.py (working copy) @@ -597,7 +597,7 @@ cached_font = self._fonts.get(basename) if cached_font is None: -font = FT2Font(basename) +font = FT2Font(str(basename)) cached_font = self.CachedFont(font) self._fonts[basename] = cached_font self._fonts[font.postscript_name] = cached_font Mike william ratcliff wrote: Mike, The basename is: u'C:\\WINDOWS\\Fonts\\HTOWERTI.TTF' Let me try to find where my matplotlibrc file is located... Thanks, William On Mon, Apr 19, 2010 at 10:22 AM, Michael Droettboom md...@stsci.edu mailto: md...@stsci.edu wrote: One might see that error if the path to the font being used contains non-ascii characters (the basename variable in the last frame of the stack in the stacktrace). Is that possible? We may need to implement the same workaround we use for image files for loading fonts (which is to open the file with Python and pass a file handle to C++ rather than passing a string that may contain Unicode, which is difficult to handle in cross-platform way from C/C++). Mike william ratcliff wrote: I think the actual error was: TypeError: cannot return std::string from Unicode object It was the error returned when I walked through with a debugger... On Mon, Apr 19, 2010 at 8:51 AM, Michael Droettboom md...@stsci.edu mailto:md...@stsci.edu mailto:md...@stsci.edu mailto:md...@stsci.edu wrote: It looks like the end of the traceback -- where the actual exception is named -- is missing. Can you repost it in its entirety? Mike william ratcliff wrote: Hi! I am
Re: [Matplotlib-users] ticks at 0 and 2pi
On 04/20/2010 10:29 AM, Ryan May wrote: On Tue, Apr 20, 2010 at 8:58 AM, Nikolaus Rath nikol...@rath.org wrote: Hello, I'm trying to plot something from 0 to 2pi: fig = plt.figure() ax = fig.add_subplot(111) ax.set_title('Radial Magnetic Field') ax.set_ylabel(r'Poloidal Angle $\theta$') ax.set_xlabel(r'Toroidal Angle $\phi$') ax.set_xticks([0, 2 * math.pi]) ax.set_xticklabels(['0', r'$2\pi$']) ax.set_yticklabels([r'$-\pi$', r'$\pi$']) ax.set_yticks([-math.pi, math.pi]) ax.set_xlim(xmin=0, xmax=2 * math.pi) ax.set_ylim(ymin= -math.pi, ymax=math.pi) I don't see the problem here, I get the ticks as specified. What version of matplotlib are you using? What backend are you using? Actually, now that I tried it again, it suddenly works. Strange... Sorry for the pointless mail. Best, -Nikolaus -- »Time flies like an arrow, fruit flies like a Banana.« PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Turning off minor grids on log scaled plot
On Tue, Apr 20, 2010 at 2:42 AM, Matthias Michler matthiasmich...@gmx.netwrote: Hi Gökhan, thanks for testing this small patch. Maybe one of the developers could submit it or should I place it on the patch-tracker? Usually after some pinging someone picks up the code and commits in to the svn. About the toggling of all grid-lines using event.inaxes.grid(which='majorminor') I not sure this is intended, because this means that you will allways toggling major and minor tick - grid lines using key 'g' instead of only toggling major tick grid lines. Maybe a developer or other users could comment on the preferred behavior. Just create a simple plot and log-log x,y-axes and try hitting g. Both minor and major gridlines must be visible to get a clear view. In some cases grids clutter the figure instead of helping. In my previous post, the main point was change in event.inaxes.grid(which='majorminor') doesn't really work as expected. Could you at least check that behavior? Kind regards, Matthias -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Gökhan -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] How to make colormaps
Hello, Maybe my googling skills are deficient, but I wasn't able to find any information on how to define my own colormap. Can someone give me a pointer, or a basic example how to create a simple map that e.g. maps -1 to Red, 0 to White, and 1 to Blue? Thanks, -Nikolaus -- »Time flies like an arrow, fruit flies like a Banana.« PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] show() at the end of each function of an ensemble of scripts
Hello, I'm currently writing a specialized image processing package using Matplotlib. The goal would be to let users use it interactively from an ipython console. So I have some functions for selecting points on plots (via button_press_event), and others for data plotting (and also for data processing, of course). When the user calls a plotting or a point-selecting function, I have to call plt.show() at the end of it... but then this seems to do something irreversible which cannot be cancelled e.g. by plt.ioff(). But at the same time I can't stay in show() mode forever, because if I did so, the program would fail when the user calls another point-selecting function (as the call to the point-selecting function becomes non-blocking, Python raises an error when the yet undefined coordinates are read in a following part of the enclosing function). (For the same reason, trying to use ipython -pylab leads to failure starting from the *first* call to a point-selecting function (instead of the second when using ipython).) (And I can't use plt.ginput as I sometimes want to update the plot using some home-made functions while the user selects data on it). So I have to find a way of showing the plot(s) to the user, and still come back to pre- plt.show() mode after (of course, if there was a way to show the plots without calling plt.show(), that would work too)... I believe this is a classic question, but I haven't found an answer to it. So does anyone have an idea about it? Thanks in advance, Antony -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to make colormaps
Nikolaus Rath wrote: Hello, Maybe my googling skills are deficient, but I wasn't able to find any information on how to define my own colormap. Can someone give me a pointer, or a basic example how to create a simple map that e.g. maps -1 to Red, 0 to White, and 1 to Blue? Thanks, -Nikolaus http://lmgtfy.com/?q=matplotlib+colormaps -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] show() at the end of each function of an ensemble of scripts
On Tue, Apr 20, 2010 at 11:38 AM, Antony Lee antony@ensmp.fr wrote: Hello, I'm currently writing a specialized image processing package using Matplotlib. The goal would be to let users use it interactively from an ipython console. So I have some functions for selecting points on plots (via button_press_event), and others for data plotting (and also for data processing, of course). When the user calls a plotting or a point-selecting function, I have to call plt.show() at the end of it... but then this seems to do something irreversible which cannot be cancelled e.g. by plt.ioff(). But at the same time I can't stay in show() mode forever, because if I did so, the program would fail when the user calls another point-selecting function (as the call to the point-selecting function becomes non-blocking, Python raises an error when the yet undefined coordinates are read in a following part of the enclosing function). (For the same reason, trying to use ipython -pylab leads to failure starting from the *first* call to a point-selecting function (instead of the second when using ipython).) (And I can't use plt.ginput as I sometimes want to update the plot using some home-made functions while the user selects data on it). So I have to find a way of showing the plot(s) to the user, and still come back to pre- plt.show() mode after (of course, if there was a way to show the plots without calling plt.show(), that would work too)... I believe this is a classic question, but I haven't found an answer to it. So does anyone have an idea about it? What you really need is to have ipython integrated into your GUI's event loop (which is started with show). You might want to look at http://code.google.com/p/spyderlib/ or Google around for some other packages that integrate IPython into a GUI. Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to make colormaps
On Tue, Apr 20, 2010 at 11:40 AM, Jim Vickroy jim.vick...@noaa.gov wrote: Nikolaus Rath wrote: Hello, Maybe my googling skills are deficient, but I wasn't able to find any information on how to define my own colormap. Can someone give me a pointer, or a basic example how to create a simple map that e.g. maps -1 to Red, 0 to White, and 1 to Blue? Thanks, -Nikolaus http://lmgtfy.com/?q=matplotlib+colormaps That was a tad harsh, given that the first page of google results didn't really answer the question. (If you're going to be snarky, at least make sure you're right.) Nick, this is a pretty good example: http://matplotlib.sourceforge.net/examples/api/colorbar_only.html Now, since it seems like you're learning right now, a good place to look which is better than google is searching matplotlib's docs directly: http://matplotlib.sourceforge.net/search.html I was able to find that example with: codex ListedColormap (codex tells it to search examples) but that's because I knew the name of the class I was looking for. Good luck and don't get discouraged. Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to make colormaps
Ryan May wrote: On Tue, Apr 20, 2010 at 11:40 AM, Jim Vickroy jim.vick...@noaa.gov wrote: Nikolaus Rath wrote: Hello, Maybe my googling skills are deficient, but I wasn't able to find any information on how to define my own colormap. Can someone give me a pointer, or a basic example how to create a simple map that e.g. maps -1 to Red, 0 to White, and 1 to Blue? Thanks, -Nikolaus http://lmgtfy.com/?q=matplotlib+colormaps That was a tad harsh, given that the first page of google results didn't really answer the question. (If you're going to be snarky, at least make sure you're right.) Nick, this is a pretty good example: http://matplotlib.sourceforge.net/examples/api/colorbar_only.html Now, since it seems like you're learning right now, a good place to look which is better than google is searching matplotlib's docs directly: http://matplotlib.sourceforge.net/search.html I was able to find that example with: codex ListedColormap (codex tells it to search examples) but that's because I knew the name of the class I was looking for. Good luck and don't get discouraged. Ryan I don't know what your Google search results page presented, but the the _*second entry *_on the _*first*_ search results page, for me, was the following: Cookbook/Matplotlib - Feb 12, 2010 ... Show colormaps - Small script to display all of the Matplotlib colormaps, and _*an exampleshowing how to create a new one*_. ... www.scipy.org/Cookbook/Matplotlib - Cached -- jv -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] plotting in a loop
Hello everyone, if I read a column file like this (simplified to integers): 0 1 2 3 1 2 3 4 2 3 4 5 3 4 5 6 with: data = np.loadtxt(fileName), why can't I use a for loop inside ipython (started with -pylab option) to plot each of the Line2D objects and then draw them on the plot? I am using matplotlib to debug a computational geometry code and I would like these lines to plot paused by the user input so that I can identify when (where) exactly the wrong calculations happen: import numpy as np import matplotlib.pyplot as plt fig1 = plt.figure() ax1 = fig1.add_subplot(111) ax1.set_aspect(equal) for line in data: raw_input(press enter to plot the line) ax1.plot([line[0],line[2]],[line[1],line[3]],'b') plt.draw() This way I could see with pressing e.g. the return key when my calculations go wrong any advice? -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to make colormaps
On 04/20/2010 01:06 PM, Ryan May wrote: On Tue, Apr 20, 2010 at 11:40 AM, Jim Vickroy jim.vick...@noaa.gov wrote: Nikolaus Rath wrote: Hello, Maybe my googling skills are deficient, but I wasn't able to find any information on how to define my own colormap. Can someone give me a pointer, or a basic example how to create a simple map that e.g. maps -1 to Red, 0 to White, and 1 to Blue? http://lmgtfy.com/?q=matplotlib+colormaps That was a tad harsh, given that the first page of google results didn't really answer the question. (If you're going to be snarky, at least make sure you're right.) Don't worry, I'm usually worse myself. And his answer did help me. I actually googled the same query, but I skipped over the first two matches after reading the title since I thought they'd just lead me to examples/pylab_examples/show_colormaps.html (which I already found and deemed to be not helpful). Nick, this is a pretty good example: http://matplotlib.sourceforge.net/examples/api/colorbar_only.html If I understand correctly, this explains how to create a discrete colormap, which isn't quite what I want. But with the two links I can figure it out the rest, thanks to both of you! Best, -Nikolaus -- »Time flies like an arrow, fruit flies like a Banana.« PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to make colormaps
I don't know what your Google search results page presented, but the the second entry on the first search results page, for me, was the following: Cookbook/Matplotlib - Feb 12, 2010 ... Show colormaps - Small script to display all of the Matplotlib colormaps, and an exampleshowing how to create a new one. ... www.scipy.org/Cookbook/Matplotlib - Cached The way he worded it to me meant colormaps mapping certain values to distinct colors, which was not (as far as I saw) covered by the first two links. It turns out I was wrong, but the point still stands: if we have new users asking sensible questions and actually making a good effort, we don't want to discourage them. Now for those who want there hands held every step of the way I'm all for snarking at. Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] show() at the end of each function of an ensemble of scripts
That would be a solution, indeed. However, is there really no way of coming back to a pre-plt.show() state once all windows are closed? What kind of irreversible things does plt.show() do? Thanks, Antony 2010/4/20 Ryan May rma...@gmail.com On Tue, Apr 20, 2010 at 11:38 AM, Antony Lee antony@ensmp.fr wrote: Hello, I'm currently writing a specialized image processing package using Matplotlib. The goal would be to let users use it interactively from an ipython console. So I have some functions for selecting points on plots (via button_press_event), and others for data plotting (and also for data processing, of course). When the user calls a plotting or a point-selecting function, I have to call plt.show() at the end of it... but then this seems to do something irreversible which cannot be cancelled e.g. by plt.ioff(). But at the same time I can't stay in show() mode forever, because if I did so, the program would fail when the user calls another point-selecting function (as the call to the point-selecting function becomes non-blocking, Python raises an error when the yet undefined coordinates are read in a following part of the enclosing function). (For the same reason, trying to use ipython -pylab leads to failure starting from the *first* call to a point-selecting function (instead of the second when using ipython).) (And I can't use plt.ginput as I sometimes want to update the plot using some home-made functions while the user selects data on it). So I have to find a way of showing the plot(s) to the user, and still come back to pre- plt.show() mode after (of course, if there was a way to show the plots without calling plt.show(), that would work too)... I believe this is a classic question, but I haven't found an answer to it. So does anyone have an idea about it? What you really need is to have ipython integrated into your GUI's event loop (which is started with show). You might want to look at http://code.google.com/p/spyderlib/ or Google around for some other packages that integrate IPython into a GUI. Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] show() at the end of each function of an ensemble of scripts
2010/4/20 Ryan May rma...@gmail.com On Tue, Apr 20, 2010 at 4:44 PM, Antony Lee antony@ensmp.fr wrote: That would be a solution, indeed. However, is there really no way of coming back to a pre-plt.show() state once all windows are closed? What kind of irreversible things does plt.show() do? It starts the GUI toolkit event loop, which starts to make things messy if you try to call show() again. It often works, but calling show() more than once is most-definitely not supported. OK, I can understand this... Now, depending on what exactly you're trying to do, you can set everything up to work off of events from the GUI so that once you call show(), the user can click on various things and trigger actions. Have you looked at the examples in: examples/event_handling? Well, the problem isn't there (I believe). The workflow I'd like to implement is that, for example the user does some data processing (in ipython), plots some data (I need a show() here), closes the plot window, does some other data processing (in ipython), plots other data (no show() needed here, as we're still in show() mode) *and selects some data by clicking on the plot* (I use fig.canvas.mpl_connect, as in the examples/event_handling). The last part works if it's the first time I'm show()ing a plot, but not the second time, and, looking at the tracebacks, it seems that this is because the first time, the program waits for the window to be closed to continue (so it can access the data it retrieves from the button_press_events), but the second time, it doesn't -- so of course it tries to access undefined variables. So basically, what I want (if I am not mistaken about the origin of the problem) is to have blocking calls again for my second plot. Buf ioff() isn't sufficient for this, either (which is not a surprise as show() does more than ion()). Probably at some point I'll have to rewrite the whole lot for a specific backend, but I'd like to stick to a pure matplotlib solution as for now. Thanks in advance, Antony Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] show() at the end of each function of an ensemble of scripts
Antony Lee wrote: Well, the problem isn't there (I believe). The workflow I'd like to implement is that, for example the user does some data processing (in ipython), plots some data (I need a show() here), closes the plot window, does some other data processing (in ipython), I'm bit confused -- does ipython pylab mode not work for this? That's what it's for. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/ORR(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception chris.bar...@noaa.gov -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] show() at the end of each function of an ensemble of scripts
--- On Tue, 4/20/10, Ryan May rma...@gmail.com wrote: Antony Lee antony@ensmp.fr wrote: That would be a solution, indeed. However, is there really no way of coming back to a pre-plt.show() state once all windows are closed? What kind of irreversible things does plt.show() do? It starts the GUI toolkit event loop, which starts to make things messy if you try to call show() again. It often works, but calling show() more than once is most-definitely not supported. But what exactly does show() do that prevents it from being called again? At least for the Mac OS X and the gtkcairo backends, calling show() multiple times doesn't seem to cause any problems. Can you give an example where calling show() multiple times breaks things? If there is such a case, it may reveal a lurking bug in show() itself. --Michiel. -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] plotting in a loop
Hi, Sorry haven't used ipython, so not sure if there is another/better ipython way. Attached is how I solved it in normal python. I added a next line button to the graph, and set the ydata for the line each time the button is pushed. There is a couple of set_ylim lines commented out, depending on the nature of your data, it might be appropriate to uncomment one of those, however the set_aspect line may might mean the graph is very tall and skinny with the supplied data. Hope that gives you some ideas for your own code. Steve On 21/04/2010 3:35 AM, tomislav_ma...@gmx.com wrote: Hello everyone, if I read a column file like this (simplified to integers): 0 1 2 3 1 2 3 4 2 3 4 5 3 4 5 6 with: data = np.loadtxt(fileName), why can't I use a for loop inside ipython (started with -pylab option) to plot each of the Line2D objects and then draw them on the plot? I am using matplotlib to debug a computational geometry code and I would like these lines to plot paused by the user input so that I can identify when (where) exactly the wrong calculations happen: import numpy as np import matplotlib.pyplot as plt fig1 = plt.figure() ax1 = fig1.add_subplot(111) ax1.set_aspect(equal) for line in data: raw_input(press enter to plot the line) ax1.plot([line[0],line[2]],[line[1],line[3]],'b') plt.draw() This way I could see with pressing e.g. the return key when my calculations go wrong any advice? -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users import numpy as np import matplotlib.pyplot as plt from matplotlib.widgets import Button imin = imax = 0 displayline = 0 data = np.loadtxt(fileName) for line in data: imin = min(imin, min(line)) imax = max(imax, max(line)) fig1 = plt.figure() ax1 = fig1.add_subplot(111) ax1.set_aspect(equal) r, = ax1.plot(data[displayline],'b') #ax1.set_ylim(imin , imax) #where rect=[left, bottom, width, height] in normalized (0,1) units controlax = fig1.add_axes([0.85, 0.1, 0.1, 0.04]) button = Button(controlax, 'Next Line') def nextline(event): global displayline displayline += 1 if displayline = len(data): displayline = 0 #start cycle again r.set_ydata(data[displayline]) #ax1.set_ylim(min(data[displayline]) , max(data[displayline])) plt.draw() button.on_clicked(nextline) plt.show()-- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] show() at the end of each function of an ensemble of scripts
http://matplotlib.sourceforge.net/faq/howto_faq.html#use-show hth, Alan Isaac -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] show() at the end of each function of an ensemble of scripts
Well, the example with the comment WARNING : illustrating how NOT to use show: for i in range(10): # make figure i show() works perfectly fine with the Mac OS X backend, and I doubt that there is some fundamental reason why this can work with the Mac OS X backend but not with other backends. --Michiel --- On Tue, 4/20/10, Alan G Isaac alan.is...@gmail.com wrote: From: Alan G Isaac alan.is...@gmail.com Subject: Re: [Matplotlib-users] show() at the end of each function of an ensemble of scripts To: matplotlib-users@lists.sourceforge.net Date: Tuesday, April 20, 2010, 9:51 PM http://matplotlib.sourceforge.net/faq/howto_faq.html#use-show hth, Alan Isaac -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users