You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
(12) |
Sep
(12) |
Oct
(56) |
Nov
(65) |
Dec
(37) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(59) |
Feb
(78) |
Mar
(153) |
Apr
(205) |
May
(184) |
Jun
(123) |
Jul
(171) |
Aug
(156) |
Sep
(190) |
Oct
(120) |
Nov
(154) |
Dec
(223) |
2005 |
Jan
(184) |
Feb
(267) |
Mar
(214) |
Apr
(286) |
May
(320) |
Jun
(299) |
Jul
(348) |
Aug
(283) |
Sep
(355) |
Oct
(293) |
Nov
(232) |
Dec
(203) |
2006 |
Jan
(352) |
Feb
(358) |
Mar
(403) |
Apr
(313) |
May
(165) |
Jun
(281) |
Jul
(316) |
Aug
(228) |
Sep
(279) |
Oct
(243) |
Nov
(315) |
Dec
(345) |
2007 |
Jan
(260) |
Feb
(323) |
Mar
(340) |
Apr
(319) |
May
(290) |
Jun
(296) |
Jul
(221) |
Aug
(292) |
Sep
(242) |
Oct
(248) |
Nov
(242) |
Dec
(332) |
2008 |
Jan
(312) |
Feb
(359) |
Mar
(454) |
Apr
(287) |
May
(340) |
Jun
(450) |
Jul
(403) |
Aug
(324) |
Sep
(349) |
Oct
(385) |
Nov
(363) |
Dec
(437) |
2009 |
Jan
(500) |
Feb
(301) |
Mar
(409) |
Apr
(486) |
May
(545) |
Jun
(391) |
Jul
(518) |
Aug
(497) |
Sep
(492) |
Oct
(429) |
Nov
(357) |
Dec
(310) |
2010 |
Jan
(371) |
Feb
(657) |
Mar
(519) |
Apr
(432) |
May
(312) |
Jun
(416) |
Jul
(477) |
Aug
(386) |
Sep
(419) |
Oct
(435) |
Nov
(320) |
Dec
(202) |
2011 |
Jan
(321) |
Feb
(413) |
Mar
(299) |
Apr
(215) |
May
(284) |
Jun
(203) |
Jul
(207) |
Aug
(314) |
Sep
(321) |
Oct
(259) |
Nov
(347) |
Dec
(209) |
2012 |
Jan
(322) |
Feb
(414) |
Mar
(377) |
Apr
(179) |
May
(173) |
Jun
(234) |
Jul
(295) |
Aug
(239) |
Sep
(276) |
Oct
(355) |
Nov
(144) |
Dec
(108) |
2013 |
Jan
(170) |
Feb
(89) |
Mar
(204) |
Apr
(133) |
May
(142) |
Jun
(89) |
Jul
(160) |
Aug
(180) |
Sep
(69) |
Oct
(136) |
Nov
(83) |
Dec
(32) |
2014 |
Jan
(71) |
Feb
(90) |
Mar
(161) |
Apr
(117) |
May
(78) |
Jun
(94) |
Jul
(60) |
Aug
(83) |
Sep
(102) |
Oct
(132) |
Nov
(154) |
Dec
(96) |
2015 |
Jan
(45) |
Feb
(138) |
Mar
(176) |
Apr
(132) |
May
(119) |
Jun
(124) |
Jul
(77) |
Aug
(31) |
Sep
(34) |
Oct
(22) |
Nov
(23) |
Dec
(9) |
2016 |
Jan
(26) |
Feb
(17) |
Mar
(10) |
Apr
(8) |
May
(4) |
Jun
(8) |
Jul
(6) |
Aug
(5) |
Sep
(9) |
Oct
(4) |
Nov
|
Dec
|
2017 |
Jan
(5) |
Feb
(7) |
Mar
(1) |
Apr
(5) |
May
|
Jun
(3) |
Jul
(6) |
Aug
(1) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
|
2018 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2025 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
|
|
|
|
1
(28) |
2
(11) |
3
(15) |
4
(11) |
5
(13) |
6
(33) |
7
(13) |
8
(9) |
9
(2) |
10
(9) |
11
(27) |
12
(5) |
13
(10) |
14
(6) |
15
(9) |
16
(4) |
17
(2) |
18
(19) |
19
(11) |
20
(9) |
21
(16) |
22
(16) |
23
(5) |
24
(2) |
25
(8) |
26
(2) |
27
(11) |
28
(10) |
29
(5) |
30
(1) |
31
(2) |
|
|
|
|
|
|
Eric Firing wrote: > Jeff Whitaker wrote: >> Michael Roettger wrote: >>> Hi all, >>> >>> maybe I've misunderstood something concerning masking or quiver plots: >>> I want to exclude some data from a quiver plot. Here's an example: >>> >>> --------------------8<---- >>> import numpy as N >>> import pylab as pl >>> import matplotlib.numerix.ma as ma >>> >>> # prepare data >>> X,Y = pl.meshgrid(range(5),range(5)) >>> angles = pl.rand(5,5) >>> U = N.cos(angles) >>> V = N.sin(angles) >>> >>> # prepare mask >>> M = N.zeros((5,5), dtype='bool') >>> M[2,2] = True >>> >>> # apply mask >>> Um = ma.masked_array(U,mask=M) >>> Vm = ma.masked_array(V,mask=M) >>> >>> # plot >>> pl.quiver(X,Y,Um,Vm) >>> # pl.plot(range(5),Um[2],'x') >>> >>> pl.show() >>> ---------------------->8---- >>> >>> Using the commented 'plot' command works as expected, but 'quiver' >>> results in >>> empty axes. If I take U,V instead of Um,Vm, the arrows are drawn .. >>> What am I doing wrong or is there another way to exclude arrows from >>> being >>> plotted? >>> >>> Thank you in advance, >>> >>> Michael >>> >>> >> >> Michael: I've fixed this now in svn. If you don't want to update to >> svn trunk, you can make this simple change in quiver.py > > Jeff, > > Thanks for the quick fix--it will help for now, and will work in most > use cases, but it is not actually correct in general. The problem is > that quiver supports input of changed values of U, V, and C on the > existing X, Y grid, and these changed values can be masked arrays with > different points masked. (See Quiver.set_UVC().) That is why I did not > use delete_masked_points in the first place. Masked values used to be > handled correctly; I suspect the bug is actually in collections, not > in quiver itself. I can't track it down right now, but may be able to > look at it over the weekend. > > Eric OK Eric - I figured you'd chime in when you got a chance. Let's consider it a temporary workaround then. BTW: I updated the quiver_demo.py example to test the masking. -Jeff > >> >> --- lib/matplotlib/quiver.py (revision 6046) >> +++ lib/matplotlib/quiver.py (working copy) >> @@ -334,6 +334,12 @@ >> def __init__(self, ax, *args, **kw): >> self.ax = ax >> X, Y, U, V, C = self._parse_args(*args) >> + if C is not None: >> + X, Y, U, V, C = >> delete_masked_points(X.ravel(),Y.ravel(),U.ravel(), >> + V.ravel(),C.ravel()) >> + else: >> + X, Y, U, V = >> delete_masked_points(X.ravel(),Y.ravel(),U.ravel(), >> + V.ravel()) >> self.X = X >> self.Y = Y >> self.XY = np.hstack((X[:,np.newaxis], Y[:,np.newaxis])) >> >> >> -Jeff >> > -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/PSD R/PSD1 Email : Jef...@no... 325 Broadway Office : Skaggs Research Cntr 1D-113 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
Jeff Whitaker wrote: > Michael Roettger wrote: >> Hi all, >> >> maybe I've misunderstood something concerning masking or quiver plots: >> I want to exclude some data from a quiver plot. Here's an example: >> >> --------------------8<---- >> import numpy as N >> import pylab as pl >> import matplotlib.numerix.ma as ma >> >> # prepare data >> X,Y = pl.meshgrid(range(5),range(5)) >> angles = pl.rand(5,5) >> U = N.cos(angles) >> V = N.sin(angles) >> >> # prepare mask >> M = N.zeros((5,5), dtype='bool') >> M[2,2] = True >> >> # apply mask >> Um = ma.masked_array(U,mask=M) >> Vm = ma.masked_array(V,mask=M) >> >> # plot >> pl.quiver(X,Y,Um,Vm) >> # pl.plot(range(5),Um[2],'x') >> >> pl.show() >> ---------------------->8---- >> >> Using the commented 'plot' command works as expected, but 'quiver' results in >> empty axes. If I take U,V instead of Um,Vm, the arrows are drawn .. >> What am I doing wrong or is there another way to exclude arrows from being >> plotted? >> >> Thank you in advance, >> >> Michael >> >> > > Michael: I've fixed this now in svn. If you don't want to update to > svn trunk, you can make this simple change in quiver.py Jeff, Thanks for the quick fix--it will help for now, and will work in most use cases, but it is not actually correct in general. The problem is that quiver supports input of changed values of U, V, and C on the existing X, Y grid, and these changed values can be masked arrays with different points masked. (See Quiver.set_UVC().) That is why I did not use delete_masked_points in the first place. Masked values used to be handled correctly; I suspect the bug is actually in collections, not in quiver itself. I can't track it down right now, but may be able to look at it over the weekend. Eric > > --- lib/matplotlib/quiver.py (revision 6046) > +++ lib/matplotlib/quiver.py (working copy) > @@ -334,6 +334,12 @@ > def __init__(self, ax, *args, **kw): > self.ax = ax > X, Y, U, V, C = self._parse_args(*args) > + if C is not None: > + X, Y, U, V, C = > delete_masked_points(X.ravel(),Y.ravel(),U.ravel(), > + V.ravel(),C.ravel()) > + else: > + X, Y, U, V = > delete_masked_points(X.ravel(),Y.ravel(),U.ravel(), > + V.ravel()) > self.X = X > self.Y = Y > self.XY = np.hstack((X[:,np.newaxis], Y[:,np.newaxis])) > > > -Jeff >
Michael Roettger wrote: > Hi all, > > maybe I've misunderstood something concerning masking or quiver plots: > I want to exclude some data from a quiver plot. Here's an example: > > --------------------8<---- > import numpy as N > import pylab as pl > import matplotlib.numerix.ma as ma > > # prepare data > X,Y = pl.meshgrid(range(5),range(5)) > angles = pl.rand(5,5) > U = N.cos(angles) > V = N.sin(angles) > > # prepare mask > M = N.zeros((5,5), dtype='bool') > M[2,2] = True > > # apply mask > Um = ma.masked_array(U,mask=M) > Vm = ma.masked_array(V,mask=M) > > # plot > pl.quiver(X,Y,Um,Vm) > # pl.plot(range(5),Um[2],'x') > > pl.show() > ---------------------->8---- > > Using the commented 'plot' command works as expected, but 'quiver' results in > empty axes. If I take U,V instead of Um,Vm, the arrows are drawn .. > What am I doing wrong or is there another way to exclude arrows from being > plotted? > > Thank you in advance, > > Michael > > Michael: I've fixed this now in svn. If you don't want to update to svn trunk, you can make this simple change in quiver.py --- lib/matplotlib/quiver.py (revision 6046) +++ lib/matplotlib/quiver.py (working copy) @@ -334,6 +334,12 @@ def __init__(self, ax, *args, **kw): self.ax = ax X, Y, U, V, C = self._parse_args(*args) + if C is not None: + X, Y, U, V, C = delete_masked_points(X.ravel(),Y.ravel(),U.ravel(), + V.ravel(),C.ravel()) + else: + X, Y, U, V = delete_masked_points(X.ravel(),Y.ravel(),U.ravel(), + V.ravel()) self.X = X self.Y = Y self.XY = np.hstack((X[:,np.newaxis], Y[:,np.newaxis])) -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/PSD R/PSD1 Email : Jef...@no... 325 Broadway Office : Skaggs Research Cntr 1D-113 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
Jason Grout wrote: > The other problem is a more serious problem for me: how do > I shorten the line so that it goes between the boundaries > of the circle instead of the centers, especially when the > circles are constructed in a scatter plot. Some years back I briefly tried to think about arrows and I found it trickier than expected. Note that some famous software clearly does arrows wrong. (E.g., gnuplot, at least last I checked.) Example: you have decided that you want to draw to the edge of a point, but a) is that right and b) can it be reasonably implemented? a) One might well argue in many applications that the arrow tip should go to the center of the circle. b) I'm not sure. But surely somebody out there will offer some great clues. Perhaps along the line of graphviz: http://www.graphviz.org/Gallery/directed/fsm.html Really this is not an answer to your questions ... Cheers, Alan Isaac
Alan G Isaac wrote: > Jason Grout wrote: >> Another related issue is that width of the path used to draw the >> arrowhead makes the arrow tip go beyond the endpoint; is there a way to >> shorten a line by a certain number of points so that we >> can account for that? > > For this problem, what you want is to fill the arrowhead > without stroking it. > Brilliant! Thanks for the suggestion. The other problem is a more serious problem for me: how do I shorten the line so that it goes between the boundaries of the circle instead of the centers, especially when the circles are constructed in a scatter plot. If I knew how big the circles were in plot coordinates, it wouldn't be a problem. But the circle size isn't specified in plot coordinates, but in scale-independent coordinates, I believe. Is there a way I could somehow compute the intersections of the paths? Maybe while I draw the line, I could also construct a circle of the right size at the endpoint, ask for the intersection, and shorten my line to go there? Thanks again! Jason
Jason Grout wrote: > Another related issue is that width of the path used to draw the > arrowhead makes the arrow tip go beyond the endpoint; is there a way to > shorten a line by a certain number of points so that we > can account for that? For this problem, what you want is to fill the arrowhead without stroking it. Cheers, Alan Isaac
Zane Selvans wrote: > I'm drawing several hundred lines at a time, each consisting of 10-100 > points, and it takes a couple of minutes for them all to display, > which makes me think I must be doing something stupid. > > The function that does the drawing looks like this: > > def plotlinmap(lins, map=None): > if map is None: > map = Basemap() > > map.drawmapboundary(fill_color="white") > map.drawmeridians(range(-180,181,30)), labels=[1,0,0,1]) > map.drawparallels(range(-90,91,30)), labels=[1,0,0,1]) > > for lin in lins: > x,y = map(degrees(lin.longitudes()),degrees(lin.latitudes())) > map.plot(x,y) > > return(map) > > It displays one line at a time, whenever map.plot() is called. Really > I'd like it to just do all the drawing at the end (assuming that would > make the whole process much faster). Is there some way to cleanly > pass map.plot() a big list of lines to draw? I'm sure there is and > I'm just being dense. Argh. > > -- > Zane Selvans > Amateur Earthling > http://zaneselvans.org > za...@id... > 303/815-6866 > PGP Key: 55E0815F > > Zane: You can set up a LineCollection like this lcoll = LineCollection(segments) then add it to the current axes ax = pylab.gca() ax.add_collection(lcoll) (instead of using the Basemap plot method). To make sure the map axes are rescaled properly, you may need to do map.set_axes_limits() afterwards. See the line_collection.py pylab example for more details. -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449 325 Broadway Boulder, CO, USA 80305-3328
Michael Roettger wrote: > Hi all, > > maybe I've misunderstood something concerning masking or quiver plots: > I want to exclude some data from a quiver plot. Here's an example: > > --------------------8<---- > import numpy as N > import pylab as pl > import matplotlib.numerix.ma as ma > > # prepare data > X,Y = pl.meshgrid(range(5),range(5)) > angles = pl.rand(5,5) > U = N.cos(angles) > V = N.sin(angles) > > # prepare mask > M = N.zeros((5,5), dtype='bool') > M[2,2] = True > > # apply mask > Um = ma.masked_array(U,mask=M) > Vm = ma.masked_array(V,mask=M) > > # plot > pl.quiver(X,Y,Um,Vm) > # pl.plot(range(5),Um[2],'x') > > pl.show() > ---------------------->8---- > > Using the commented 'plot' command works as expected, but 'quiver' results in > empty axes. If I take U,V instead of Um,Vm, the arrows are drawn .. > What am I doing wrong or is there another way to exclude arrows from being > plotted? > > Thank you in advance, > > Michael > Michael: With 0.98.3, all the arrows are drawn - I don't see empty axes. However, the masked elements are not excluded, so I do think it's a bug. -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449 325 Broadway Boulder, CO, USA 80305-3328
I'm trying to get some "pretty" arrows for graphs and other uses in Sage. One of the problems we've been having with the FancyArrow and YAArrow is that the arrow is skewed when the aspect ratio is not 1:1 and it is scaled along with the plot. I've written the attached ArrowLine class which basically modifies the marker drawing code to draw an arrowhead at the end of a Line2D. It doesn't suffer either of these problems; it works beautifully. However, in drawing (vertex and line) graphs, we have another problem. The vertices of the graph are drawn using scatterplot, and I know the corresponding vertex size (in whatever units scatterplot uses). I'd like to draw an arrow between the boundaries of the vertices. Is there a way to shorten a line that originally goes between the centers of two circles so that the line instead goes between the two boundaries of the circles? Note that clipping the line isn't an option since I want to keep the arrowhead on the line instead of clipping it off. I presume this shortening will have to be done in the drawing routine since it needs to be independent of zooming since the circles are drawn the same independent of zooming. Another related issue is that width of the path used to draw the arrowhead makes the arrow tip go beyond the endpoint; is there a way to shorten a line by a certain number of points so that we can account for that? Also, in drawing the arrowhead, the line pokes through the arrowhead; I'd like to shorten the shaft to the beginning of the arrowhead. I think all three of these shortening questions are similar; I'd like to shorten an arrow in a scale-independent way (i.e., by a certain number of points or something). The code I have for the ArrowLine class is below. If people are interested, I could (eventually, as I have time) incorporate this functionality into the Line2D class (i.e., putting arrowheads on the ends of lines). r""" A matplotlib subclass to draw an arrowhead on a line. AUTHORS: -- Jason Grout (2008年08月19日): initial version """ ############################################################################ # Copyright (C) 2008 Jason Grout <jas...@cr...> # Released under the terms of the modified BSD License ############################################################################ import matplotlib from matplotlib.path import Path from matplotlib.lines import Line2D import math import matplotlib.cbook class ArrowLine(Line2D): """ A matplotlib subclass to draw an arrowhead on a line. EXAMPLE: sage: import pylab sage: fig = pylab.figure() sage: ax = fig.add_subplot(111, autoscale_on=False) sage: t = [-1,2] sage: s = [0,-1] sage: line = ArrowLine(t, s, color='b', ls='-', lw=2, arrow='>', arrowsize=20) sage: ax.add_line(line) sage: ax.set_xlim(-3,3) (-3, 3) sage: ax.set_ylim(-3,3) (-3, 3) sage: pylab.show() """ arrows = {'>' : '_draw_triangle_arrow'} def __init__(self, *args, **kwargs): """Initialize the line and arrow.""" self._arrow = kwargs.pop('arrow', None) self._arrowsize = kwargs.pop('arrowsize', 2*4) self._arrowedgecolor = kwargs.pop('arrowedgecolor', 'b') self._arrowfacecolor = kwargs.pop('arrowfacecolor', 'b') self._arrowedgewidth = kwargs.pop('arrowedgewidth', 4) self._arrowheadwidth = kwargs.pop('arrowheadwidth', self._arrowsize) self._arrowheadlength = kwargs.pop('arrowheadlength', self._arrowsize) Line2D.__init__(self, *args, **kwargs) def draw(self, renderer): """Draw the line and arrowhead using the passed renderer.""" if self._invalid: self.recache() renderer.open_group('arrowline2d') if not self._visible: return Line2D.draw(self, renderer) if self._arrow is not None: gc = renderer.new_gc() self._set_gc_clip(gc) gc.set_foreground(self._arrowedgecolor) gc.set_linewidth(self._arrowedgewidth) gc.set_alpha(self._alpha) funcname = self.arrows.get(self._arrow, '_draw_nothing') if funcname != '_draw_nothing': tpath, affine = self._transformed_path.get_transformed_points_and_affine() arrowFunc = getattr(self, funcname) arrowFunc(renderer, gc, tpath, affine.frozen()) renderer.close_group('arrowline2d') _arrow_path = Path([[0.0, 0.0], [-1.0, 1.0], [-1.0, -1.0], [0.0, 0.0]], codes=[Path.MOVETO, Path.LINETO,Path.LINETO, Path.CLOSEPOLY]) def _draw_triangle_arrow(self, renderer, gc, path, path_trans): """Draw a triangular arrow.""" segment = [i[0] for i in path.iter_segments()][-2:] startx,starty = path_trans.transform_point(segment[0]) endx,endy = path_trans.transform_point(segment[1]) angle = math.atan2(endy-starty, endx-startx) halfwidth = 0.5*renderer.points_to_pixels(self._arrowheadwidth) length = renderer.points_to_pixels(self._arrowheadlength) transform = matplotlib.transforms.Affine2D().scale(length,halfwidth).rotate(angle).translate(endx,endy) rgbFace = self._get_rgb_arrowface() renderer.draw_path(gc, self._arrow_path, transform, rgbFace) def _get_rgb_arrowface(self): facecolor = self._arrowfacecolor if matplotlib.cbook.is_string_like(facecolor) and facecolor.lower()=='none': rgbFace = None else: rgbFace = matplotlib.colors.colorConverter.to_rgb(facecolor) return rgbFace
Hi all, maybe I've misunderstood something concerning masking or quiver plots: I want to exclude some data from a quiver plot. Here's an example: --------------------8<---- import numpy as N import pylab as pl import matplotlib.numerix.ma as ma # prepare data X,Y = pl.meshgrid(range(5),range(5)) angles = pl.rand(5,5) U = N.cos(angles) V = N.sin(angles) # prepare mask M = N.zeros((5,5), dtype='bool') M[2,2] = True # apply mask Um = ma.masked_array(U,mask=M) Vm = ma.masked_array(V,mask=M) # plot pl.quiver(X,Y,Um,Vm) # pl.plot(range(5),Um[2],'x') pl.show() ---------------------->8---- Using the commented 'plot' command works as expected, but 'quiver' results in empty axes. If I take U,V instead of Um,Vm, the arrows are drawn .. What am I doing wrong or is there another way to exclude arrows from being plotted? Thank you in advance, Michael
well it hasn't caused me any crashes yet so far as I can tell. Other naughty things I do cause crashes, though. On Thu, Aug 21, 2008 at 8:03 PM, Ryan May <rm...@gm...> wrote: > On Thu, Aug 21, 2008 at 4:58 PM, Darren Dale <dsd...@gm...> wrote: > >> On Thursday 21 August 2008 17:36:50 Eric Firing wrote:> Jack Sankey wrote: >> > > pylab.gcf().clear(); pylab.show() # nothing happens >> > >> > With interactive mode off, in a script, show() should never be called >> > more than once; it should be the last plot-related line of the script. >> >> I thought we supported repeated calls to show. Some people use multiple >> show >> calls in order to step through a number of plots in a script. > > > My impression has always been that calling show() more than once is *bad* > and not supported. > > Ryan > > -- > Ryan May > Graduate Research Assistant > School of Meteorology > University of Oklahoma >
On Thu, Aug 21, 2008 at 4:58 PM, Darren Dale <dsd...@gm...> wrote: > On Thursday 21 August 2008 17:36:50 Eric Firing wrote:> Jack Sankey wrote: > > > pylab.gcf().clear(); pylab.show() # nothing happens > > > > With interactive mode off, in a script, show() should never be called > > more than once; it should be the last plot-related line of the script. > > I thought we supported repeated calls to show. Some people use multiple > show > calls in order to step through a number of plots in a script. My impression has always been that calling show() more than once is *bad* and not supported. Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma
On Thursday 21 August 2008 17:36:50 Eric Firing wrote: > Jack Sankey wrote: > > pylab.gcf().clear(); pylab.show() # nothing happens > > With interactive mode off, in a script, show() should never be called > more than once; it should be the last plot-related line of the script. I thought we supported repeated calls to show. Some people use multiple show calls in order to step through a number of plots in a script.
While I don't know much about how callbacks work in matplotlib, looking at the source code of figure.draw() method, it seems that call_back functions connected with the "draw_event" are called after a figure is drawn. Therefore, you need a second draw. My guess is that this second draw is somehow automagically done in gui backends. So, a quick and easy solution would be to save the same figure twice. First one will have a figure before the adjustment, but the second one will have a figure after the adjustment. Or, you may create a custom figure class which overrides the draw() method to adjust the margins before you draw the actual figure. Attached is an example of such custom figure class. I slightly modified the original example. -JJ On Thu, Aug 21, 2008 at 12:53 PM, Mathieu Leplatre <lep...@gm...> wrote: > Hi all, > I am trying to automatically adjust margins with the SVG backend. > > The FAQ example : > http://matplotlib.sourceforge.net/doc/html/faq/howto_faq.html#how-do-i-automatically-make-room-for-my-tick-labels > only works with GUI backends. > May it come from get_window_extent() call ? > > How could I modify this snipplet so that it works with SVG (or PDF) backends ? > > Thank you for your support. > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >
I want to draw some text and have it clipped by another rectangle I draw. The text should only display inside the box. I have some sample code that seems like it should work, but obviously there is something wrong because the text does not display at all. Any help? import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(111) mybar, = ax.bar(0,1) mytext = ax.text(0.5, 0.5, 'text inside box') mytext2 = ax.text(-0.3, 0.2, 'text outside box') ax.set_xlim(-1.5, 2.0) ax.set_ylim(-1.0, 2.5) fig.canvas.draw() # comment out these lines to see text mytext.set_clip_on(True) mytext.set_clip_box(mybar.get_bbox()) mytext2.set_clip_on(True) mytext2.set_clip_box(mybar.get_bbox()) plt.show() Thanks, -Ben
On Thu, Aug 21, 2008 at 2:36 PM, Scott Collis <S.C...@bo...> wrote: > Morning all! > I have some data (basically weather data) that I want to create some nice > graphics (mainly PR type images) out of. My initial idea is to generate > meshes from the data and import them into povray (ray tracing utility). Now > matplotlib easily generates contours, is there a utility out there for > generating meshes. > > eg L=isosurface(X,Y,Z,V, level) > L: list/array of triangles where a triangle is len 3 list/array of len 3 > tuples (x,y,z) > X: array or meshcube of the x oridnate > Y:... > Z:... > V: array/list where len(V.shape)=3 > level: float, level of isosurface > > I can kind of envisage a way it could be done by generating contours on > constant Z slices of the cube and then searching for the closest vertices of > the contour below it to make meshes... > I have played with MayaVI but have run into a few issues with it. (happy to > receive recommendations of other 3D Vis environments compatible with > Scipy/Numpy or that can read in NetCDF easily) > > I'd still recommend Mayavi. I know that the mayavi developers would be very interested in hearing what issues exactly you've had. I'd suggest posting about them on the enthought-dev mailing list. Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma
Thanks Eric, I may be doing things a little bit weird since I've been with matplotlib for many years. I did two things that fixed my problem: I wiped python25 out completely and install enthought (with an older pylab). During the wipe I noticed an extra pythonw running in the task manager that I had to kill. It may be that this thing was a corrupted version of wx running in the background, messing everything up. I may try reinstalling at a later date to see. I'm not familiar with pyshell, but evidently it is turning interactive mode > on, correct? > I am turning interactive mode on. import pylab >> pylab.plot([1,2,1]) # figure pops up >> pylab.gca().clear(); pylab.show() # nothing happens >> > Why are you doing this? In interactive mode, you should not be calling > show() at all. And, you are mixing pylab and OO interfaces in a strange > way; if you want to work interactively via the pylab interface, you should > use pylab.cla() and pylab.clf(). If you want to work interactively but > *mostly* with the OO interface, then you can call axes methods like clear(), > but you need to put in pylab.draw() when you want the figure redrawn. hmm. I know at one point I was doing a window Refresh() which was slow. Then I discovered pylab.show() which drastically sped up my plotting (I made a program that modifies colorbars in real time and this really helped). Maybe the next and final step is "pylab.draw()"? :) Sorry if my code is hacky. I figure most of my stuff out using pyshell's autocomplete to play. Incidentally, since these commands work fine. Thanks again! (now back to work for me) -Jack
Jack Sankey wrote: > I'm not sure if this is a matplotlib issue or what, but all of a sudden > I was not able to do gca() or gcf() correctly. > > A simple command-line on pyshell (using wxAgg backend) went like this: I'm not familiar with pyshell, but evidently it is turning interactive mode on, correct? > > import pylab > pylab.plot([1,2,1]) # figure pops up > pylab.gca().clear(); pylab.show() # nothing happens Why are you doing this? In interactive mode, you should not be calling show() at all. And, you are mixing pylab and OO interfaces in a strange way; if you want to work interactively via the pylab interface, you should use pylab.cla() and pylab.clf(). If you want to work interactively but *mostly* with the OO interface, then you can call axes methods like clear(), but you need to put in pylab.draw() when you want the figure redrawn. > pylab.gcf().clear(); pylab.show() # nothing happens With interactive mode off, in a script, show() should never be called more than once; it should be the last plot-related line of the script. > pylab.clf() # works fine because it is internally calling pylab.draw_if_interactive(). Eric > > I've played with getting the current figure, storing it in a temporary > variable a, trying "a.clear()" trying any manipulations and they don't > work. It's like the figures/axes returned by gca() and gcf() no longer > correspond to the only open figure I can see. > > I don't have time to figure it out (I have a paper due and I've already > thrown 3 hours at figuring out why my scripts aren't working), and I > know there's an outside chance it's all my fault. I've uninstalled > everything and I'm putting enthought on (older matplotlib). Anyway, I'm > sorry if this turns out to be my fault, but can anyone test/confirm/deny > this behavior? I was using the latest mpl 0.98.3 and python 2.5. > > Thanks, > -Jack > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > > > ------------------------------------------------------------------------ > > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Morning all! I have some data (basically weather data) that I want to create some nice graphics (mainly PR type images) out of. My initial idea is to generate meshes from the data and import them into povray (ray tracing utility). Now matplotlib easily generates contours, is there a utility out there for generating meshes. eg L=isosurface(X,Y,Z,V, level) L: list/array of triangles where a triangle is len 3 list/array of len 3 tuples (x,y,z) X: array or meshcube of the x oridnate Y:... Z:... V: array/list where len(V.shape)=3 level: float, level of isosurface I can kind of envisage a way it could be done by generating contours on constant Z slices of the cube and then searching for the closest vertices of the contour below it to make meshes... I have played with MayaVI but have run into a few issues with it. (happy to receive recommendations of other 3D Vis environments compatible with Scipy/Numpy or that can read in NetCDF easily) Cheers, Scott
I'm not sure if this is a matplotlib issue or what, but all of a sudden I was not able to do gca() or gcf() correctly. A simple command-line on pyshell (using wxAgg backend) went like this: import pylab pylab.plot([1,2,1]) # figure pops up pylab.gca().clear(); pylab.show() # nothing happens pylab.gcf().clear(); pylab.show() # nothing happens pylab.clf() # works fine I've played with getting the current figure, storing it in a temporary variable a, trying "a.clear()" trying any manipulations and they don't work. It's like the figures/axes returned by gca() and gcf() no longer correspond to the only open figure I can see. I don't have time to figure it out (I have a paper due and I've already thrown 3 hours at figuring out why my scripts aren't working), and I know there's an outside chance it's all my fault. I've uninstalled everything and I'm putting enthought on (older matplotlib). Anyway, I'm sorry if this turns out to be my fault, but can anyone test/confirm/deny this behavior? I was using the latest mpl 0.98.3 and python 2.5. Thanks, -Jack
Hi, I guess the extent of the rendered text is not known until the figure is drawn. The link below would be helpful. http://matplotlib.sourceforge.net/doc/html/faq/howto_faq.html#how-do-i-automatically-make-room-for-my-tick-labels So. it is possible to know the text length, but you need to wait until the drawing time. I guess the legend class might be helpful, as it adjust its position at the drawing time according to the text size. But wrapping a text (in general way) seems not easy to me. Anyhow, the easiest way I can think of is to rely on LaTeX for wrapping. text(0.5, 2.5, r"\parbox[b]{2 in}{really really really really really really long line}", va="top") It may be a bit tricky to get the right vertical alignment though. Regards, -JJ On Thu, Aug 21, 2008 at 12:55 PM, Ben Axelrod <bax...@co...> wrote: > I am trying to draw some text inside of a rectangle. The text can be longer > than the rectangle, so I would like to wrap the text. I doubt MPL has this > kind of functionality built in, so I am expecting to write it myself. > > > > I think I read somewhere that it is not possible to get the length of text > in MPL. Is this true? This would be the basic mechanism needed to > implement this. > > > > I just want to know if this is possible or not, and any pointers if anyone > has some. > > > > Thanks, > > -Ben > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great > prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > >
I am trying to draw some text inside of a rectangle. The text can be longer than the rectangle, so I would like to wrap the text. I doubt MPL has this kind of functionality built in, so I am expecting to write it myself. I think I read somewhere that it is not possible to get the length of text in MPL. Is this true? This would be the basic mechanism needed to implement this. I just want to know if this is possible or not, and any pointers if anyone has some. Thanks, -Ben
Hi all, I am trying to automatically adjust margins with the SVG backend. The FAQ example : http://matplotlib.sourceforge.net/doc/html/faq/howto_faq.html#how-do-i-automatically-make-room-for-my-tick-labels only works with GUI backends. May it come from get_window_extent() call ? How could I modify this snipplet so that it works with SVG (or PDF) backends ? Thank you for your support.
I'm having trouble using picker on a scatter plots with various markers (e.g. + and x). It works with the plot command fine. What am I missing? Sample code below. import numpy import pylab def onpick(event): print 'Pick:',event.ind fig = pylab.figure() ax = fig.add_subplot(111) x1,y1 = numpy.random.random((2,100)) series1=ax.plot(x1,y1,marker='x',color='b',linestyle='',label='plot',picker=5) x2,y2 = numpy.random.random((2,100)) series2=ax.scatter(x2,y2,marker='x',color='g',label='scatter-X',picker=5) x3,y3 = numpy.random.random((2,100)) series3=ax.scatter(x3,y3,marker='o',color='r',label='scatter-O',picker=5) fig.canvas.mpl_connect('pick_event',onpick) pylab.legend() pylab.show()
Dear list - David Kaplan added a very cool new feature to add labels to a contour plots manually. Check out the ginput_manual_clabel.py example. I posted a question about this before, because I couldn't figure out how to end the manual selection of label positions. The doc string (and the example) says to press the middle mouse button or potentially both mouse buttons together. Many laptops don't have a middle mouse button. I have read that pushing both buttons together mimics the middle button on some machines. Not on mine or any others I have seen. The trick (at least on my machine) is to configure the touchpad such that some corner acts as the middle button. You can do that in the settings of the touchpad (on my XP laptop, under settings, control panel, mouse, then select device settings and settings; select tap zones and check to enable tap zones; then select which corner you want and select the action 'middle mouse button') I hope this works for everybody. Great new feature! Mark ps. I have asked David whether ending manual positions of labels could be done with the right mouse button instead. He's on vacation now, so we'll see what he says when he gets back.