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
(13) |
2
(11) |
3
(2) |
4
(4) |
5
(28) |
6
(17) |
7
(28) |
8
(6) |
9
(6) |
10
|
11
|
12
(9) |
13
(13) |
14
(21) |
15
(16) |
16
(6) |
17
(3) |
18
(3) |
19
(8) |
20
(15) |
21
(33) |
22
(10) |
23
(17) |
24
(2) |
25
(5) |
26
(23) |
27
(18) |
28
(6) |
|
|
|
Darren Dale wrote: [...] > Perhaps reducing the image size to the visible elements would be a good option > for all output formats? This sounds to me like a very desirable option to have. I have not thought at all about implementation, though. Eric
"John Hunter" <jd...@gm...> writes: > On 2/5/07, Berthold H=C3=B6llmann <bhoel-lDxpuoTbsqf2eFz/2M...@pu...= ane.org> wrote: > >> I get a file 'test.eps'. Using matplotlib 0.87.7 the PS bounding box >> of the generated plot is far to wide. Is this a problem with my script >> or a Problem of FigureCanvasAgg (and FigureCanvasPS)? What can I do to >> get a tight bounding box? > > This is a problem with the way PS computes the bounding box -- it uses > the bounding box of the Figure and ignores the fact that much of your > figure is whitespace. It should compute the bounding box of the > visible figure elements, so this should be considered a bug. To > workaround, you can set the figure size to be more like the size of > the content > > fig =3D Figure((3,7)) # set the width and height in inches > canvas =3D FigureCanvas(fig) > ax =3D fig.add_subplot(111) > ax.plot([.5,.7],[1.5, 2.5]) > ax.add_artist(Rectangle((.5, 1.5), .2, 1, fill=3DFalse)) > ax.set_aspect("equal") > canvas.print_figure('test.eps') So there is no way to calculate the size occupied by the visible figure elements? In my target application I also have no easy way to figure out the size of the resulting plot, I hoped matplotlib has a way tp extract it from the plotted data. something like ----- ax.set_aspect("equal") ax.autoscale_view() w, h =3D fig.get_size_inches() xmin, xmax =3D ax.get_xlim() ymin, ymax =3D ax.get_ylim() xext =3D xmax - xmin yext =3D ymax - ymin if xext < yext: w =3D h * xext/yext else: h =3D w * yext/xext ----- gives a tighter bounding box, still having somehow too much room in the unchanged direction. >> Further, when I leave out the "ax.plot" line, the generated figure is >> missing the "Rectangle" and is showing only a pair of axes counting >> from 0 to 1. Is that a bug of matplotlib or something I have to fix in >> my script? > > Use add_patch instead of add_artist. add_artist is the most generic > method and Axes doesn't know how to query it's argument for it's data > limits, which it then feeds to the autoscaler. If you use add_line to > add lines.Line2D and add_patch to add patches.Patch instances, then > Axes will know how to introspect them and update the autoscaler. But > you will need to explicitly call "autoscale_view" before saving. > Something like I had tried "add_patch" but missed the ax.autoscale_view() call. Thanks Berthold --=20 ber...@xn... / <http://h=C3=B6llmanns.de/> bh...@we... / <http://starship.python.net/crew/bhoel/>
On Monday 05 February 2007 05:23:04 pm John Hunter wrote: > On 2/5/07, Darren Dale <dd...@co...> wrote: > > I respectfully disagree. The current behavior is consistent with other > > output formats, such as png. If we want to support tight bounding boxes, > > maybe it would be better to do so with a kwarg. > > I'm happy to be wrong (especially because then we don't have any work > to do) but I don't see the tight bounding box as inconsistent with > Agg's behavior. I agree that the *.ps output should be consistent > with the Agg png behavior since neither make a claim to clip the image > to the visible elements. But *.eps implies a bounding box, it might > make sense to offer a bounding box that is reduced to the visible > elements. Maybe I'm confusing two issues. I'm comparing png's image extent with eps's bounding box. > I certainly don't feel strongly, nor do I think it would be terribly > hard to do..... Perhaps reducing the image size to the visible elements would be a good option for all output formats?
On 2/5/07, Darren Dale <dd...@co...> wrote: > I respectfully disagree. The current behavior is consistent with other output > formats, such as png. If we want to support tight bounding boxes, maybe it > would be better to do so with a kwarg. I'm happy to be wrong (especially because then we don't have any work to do) but I don't see the tight bounding box as inconsistent with Agg's behavior. I agree that the *.ps output should be consistent with the Agg png behavior since neither make a claim to clip the image to the visible elements. But *.eps implies a bounding box, it might make sense to offer a bounding box that is reduced to the visible elements. I certainly don't feel strongly, nor do I think it would be terribly hard to do..... JDH
On 2/5/07, JJ <jos...@ya...> wrote: > I am just learning and do have a couple of questions. > Why is the lock on lasso needed in the original demo. > For my revised version, it works better without it (a > right click without dragging caused an infinite lock). The locking is designed to prevent conflict with other resources that may be competing with you to draw to the screen. Ie, if you enable zoom to rect mode and the matplotlib backend is drawing a zoom rectangle and you are drawing a lasso. In this case you'll get an exception which should remind you that the resources are already taken. There may be a better way to enable resource sharing, though.. I'm not sure about the lock you experienced right now..... > > Also, I would have expected the callback function to > be executed directly on execution of the self.lasso = > Lasso(...) line in the onpress function, but instead > it is executed after the last line of the onpress > function. Why is this? > Well, the callback is triggered after the mouse us released, ie after the lasso is complete. The onpress sets up the lasso widget, which in turn connects to the mouse move and mouse release events. When you are done with the lasso and release the mouse, it triggers your callback. You could change this behavior by subclassing Lasso -- it's a pretty small class that lives in matplotlib.widgets. One could do everything on mouse motion, which could be computationally expensive but might be what you are looking for. I'm not quite sure what you are expecting to happen. JDH
On Monday 05 February 2007 04:57:40 pm John Hunter wrote: > On 2/5/07, Berthold H=F6llmann <bh...@de...> wrote: > > I get a file 'test.eps'. Using matplotlib 0.87.7 the PS bounding box > > of the generated plot is far to wide. Is this a problem with my script > > or a Problem of FigureCanvasAgg (and FigureCanvasPS)? What can I do to > > get a tight bounding box? > > This is a problem with the way PS computes the bounding box -- it uses > the bounding box of the Figure and ignores the fact that much of your > figure is whitespace. It should compute the bounding box of the > visible figure elements, so this should be considered a bug. =20 I respectfully disagree. The current behavior is consistent with other outp= ut=20 formats, such as png. If we want to support tight bounding boxes, maybe it= =20 would be better to do so with a kwarg. Darren
On 2/5/07, Michael Lerner <mgl...@gm...> wrote: > Hi, > > I have some data where I'd like almost all of it to be plotted with a > LinearSegmentedColormap that I've made, but I have a few special > values that I'd like to set to specific colors (white, in this case). > So, I made a LinearSegmentedColormap that works pretty well, but I'm > having trouble with the rest. I found a nice-looking example at > > http://www.scipy.org/Cookbook/Matplotlib/Plotting_Images_with_Special_Values > > But, it doesn't work for me. In particular, it complains a lot about > _lut. I'm using matplotlib 0.87.7 on an intel Mac running OS X and > python 2.4. On a very quick read, it appears that the sentinel map in that example forgot to initialize the baseclass. Eg, you need class SentinelMap(Colormap): def __init__(self, cmap, sentinels={}): Colormap.__init__(self) # init the base class # boilerplate stuff - rest of init function here See if that helps, and let us know. If you get it working, please fix the wiki (you may have to sign up) and post your example along with it. Otherwise, please post a complete code example and we'll see what we can do. JDH > > Can someone show me how to make a sentinel'd version of a > LinearSegmentedColormap? > > Thank you, > > -Michael Lerner > > -- > Biophysics Graduate Student > Carlson Lab, University of Michigan > http://www.umich.edu/~mlerner http://lernerclan.net > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier. > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >
On 2/5/07, Berthold H=F6llmann <bh...@de...> wrote: > I get a file 'test.eps'. Using matplotlib 0.87.7 the PS bounding box > of the generated plot is far to wide. Is this a problem with my script > or a Problem of FigureCanvasAgg (and FigureCanvasPS)? What can I do to > get a tight bounding box? This is a problem with the way PS computes the bounding box -- it uses the bounding box of the Figure and ignores the fact that much of your figure is whitespace. It should compute the bounding box of the visible figure elements, so this should be considered a bug. To workaround, you can set the figure size to be more like the size of the content fig =3D Figure((3,7)) # set the width and height in inches canvas =3D FigureCanvas(fig) ax =3D fig.add_subplot(111) ax.plot([.5,.7],[1.5, 2.5]) ax.add_artist(Rectangle((.5, 1.5), .2, 1, fill=3DFalse)) ax.set_aspect("equal") canvas.print_figure('test.eps') > Further, when I leave out the "ax.plot" line, the generated figure is > missing the "Rectangle" and is showing only a pair of axes counting > from 0 to 1. Is that a bug of matplotlib or something I have to fix in > my script? Use add_patch instead of add_artist. add_artist is the most generic method and Axes doesn't know how to query it's argument for it's data limits, which it then feeds to the autoscaler. If you use add_line to add lines.Line2D and add_patch to add patches.Patch instances, then Axes will know how to introspect them and update the autoscaler. But you will need to explicitly call "autoscale_view" before saving. Something like ax =3D fig.add_subplot(111) ax.add_patch(Rectangle((.5, 1.5), .2, 1, edgecolor=3D'red', fill=3DFalse)= ) ax.set_aspect("equal") ax.autoscale_view() canvas.print_figure('test.eps') Note if all you are doing is creating postscript, you don't need to import Agg at all. Just do from matplotlib.backends.backend_ps import FigureCanvasPS as FigureCanvas JDH
Hi, I have some data where I'd like almost all of it to be plotted with a LinearSegmentedColormap that I've made, but I have a few special values that I'd like to set to specific colors (white, in this case). So, I made a LinearSegmentedColormap that works pretty well, but I'm having trouble with the rest. I found a nice-looking example at http://www.scipy.org/Cookbook/Matplotlib/Plotting_Images_with_Special_Values But, it doesn't work for me. In particular, it complains a lot about _lut. I'm using matplotlib 0.87.7 on an intel Mac running OS X and python 2.4. Can someone show me how to make a sentinel'd version of a LinearSegmentedColormap? Thank you, -Michael Lerner -- Biophysics Graduate Student Carlson Lab, University of Michigan http://www.umich.edu/~mlerner http://lernerclan.net
On 2/5/07, Martin Wilson <mp...@bh...> wrote: > Hi, > > I'm using matplotlib in a GTK gui canvas with the GTKAgg backend. I'm > connecting a mouse click 'button_press_event' to the click function. If > I choose print event.x everything works fine. However I'm after the x > value in terms of the x-axis not pixels. When I try print event.xdata I > get an error message. Am I making a stupid mistake or is this a bug? > self.canvas.connect('button_press_event',self.click) > > def click(self,widget,event): > print 'you clicked', event.xdata, event.ydata > #print 'you clicked', event.x, event.y > > > Traceback (most recent call last): > File "./dangerplotpy", line 120, in click > print 'you clicked', event.xdata, event.ydata > AttributeError: xdata The matplotlib GTKAgg canvas inherits from the gtk drawing area and thus inherit's its connect method. You are connecting to GTK's event handler, not matplotlib's. Use canvas.mpl_connect instead, as in this example from pylab import figure, show fig = figure() ax = fig.add_subplot(111) ax.plot([1,2,3]) def click(event): if event.inaxes is not None: print 'you clicked', event.xdata, event.ydata fig.canvas.mpl_connect('button_press_event', click) show()
On Monday 05 February 2007 04:06:45 pm Berthold H=C3=B6llmann wrote: > With the script > > ---- > from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanv= as > from matplotlib.figure import Figure > from matplotlib.patches import Rectangle > fig =3D Figure() > canvas =3D FigureCanvas(fig) > ax =3D fig.add_subplot(111) > ax.plot([.5,.7],[1.5, 2.5]) > ax.add_artist(Rectangle((.5, 1.5), .2, 1, fill=3DFalse)) > ax.set_aspect("equal") > canvas.print_figure('test.eps') > ---- > > I get a file 'test.eps'. Using matplotlib 0.87.7 the PS bounding box > of the generated plot is far to wide. Is this a problem with my script > or a Problem of FigureCanvasAgg (and FigureCanvasPS)? What can I do to > get a tight bounding box? The bounding box is determined by the size of your figure window. Try=20 something like: fig=3DFigure(figsize=3D(2,4)) > Further, when I leave out the "ax.plot" line, the generated figure is > missing the "Rectangle" and is showing only a pair of axes counting > from 0 to 1. Is that a bug of matplotlib or something I have to fix in > my script? It looks like a bug to me, but right now I don't have time to look into it= =20 further. Maybe someone else could comment, or you could file a bug report a= t=20 sourceforge. Darren
With the script ---- from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas from matplotlib.figure import Figure from matplotlib.patches import Rectangle fig =3D Figure() canvas =3D FigureCanvas(fig) ax =3D fig.add_subplot(111) ax.plot([.5,.7],[1.5, 2.5]) ax.add_artist(Rectangle((.5, 1.5), .2, 1, fill=3DFalse)) ax.set_aspect("equal") canvas.print_figure('test.eps') ---- I get a file 'test.eps'. Using matplotlib 0.87.7 the PS bounding box of the generated plot is far to wide. Is this a problem with my script or a Problem of FigureCanvasAgg (and FigureCanvasPS)? What can I do to get a tight bounding box? Further, when I leave out the "ax.plot" line, the generated figure is missing the "Rectangle" and is showing only a pair of axes counting from 0 to 1. Is that a bug of matplotlib or something I have to fix in my script? Thanks Berthold --=20 ber...@xn... / <http://h=C3=B6llmanns.de/> bh...@we... / <http://starship.python.net/crew/bhoel/>
Hello. In case it is of use to anyone, here is a revised lasso_demo.py that draws a polygon around selected points, deletes points with a click of the middle mouse button, and adds points with a right click. Thanks John H for the help getting started. I am just learning and do have a couple of questions. Why is the lock on lasso needed in the original demo. For my revised version, it works better without it (a right click without dragging caused an infinite lock). Also, I would have expected the callback function to be executed directly on execution of the self.lasso = Lasso(...) line in the onpress function, but instead it is executed after the last line of the onpress function. Why is this? """ draws a polygon around points selected with the mouse deletes points selected with a middle click adds points selected with a right click """ import os from numpy import * import glob from matplotlib.widgets import Lasso import matplotlib.mlab from matplotlib.nxutils import points_inside_poly from matplotlib.colors import colorConverter from matplotlib.collections import RegularPolyCollection from matplotlib.patches import Polygon from pylab import figure, show, nx import pdb class Datum: colorin = colorConverter.to_rgba('red') colorout = colorConverter.to_rgba('green') def __init__(self, x, y, include=False): self.x = x self.y = y if include: self.color = self.colorin else: self.color = self.colorout class LassoManager: def __init__(self, ax, data): #self.flag = flag self.axes = ax self.canvas = ax.figure.canvas self.data = data self.Nxy = len(data) self.facecolors = [d.color for d in data] self.xys = [(d.x, d.y) for d in data] self.collection = RegularPolyCollection( fig.dpi, 6, sizes=(100,), facecolors=self.facecolors, offsets = self.xys, transOffset = ax.transData) ax.add_collection(self.collection) self.cid = self.canvas.mpl_connect('button_press_event', self.onpress) def callback(self, verts): ind = nx.nonzero(points_inside_poly(self.xys, verts)) if len(ind) == 0: return for i in range(self.Nxy): if i in ind: self.facecolors[i] = Datum.colorin else: self.facecolors[i] = Datum.colorout self.canvas.draw_idle() self.canvas.widgetlock.release(self.lasso) # draw polygon if len(self.axes.patches) > 0: self.axes.patches.pop() xyo=list() for i in ind: xyo.append(self.xys[i]) rect = Polygon(xyo, facecolor='red', alpha=0.5) self.axes.add_patch(rect) self.canvas.draw_idle() del self.lasso def onpress(self, event): if self.canvas.widgetlock.locked(): return if event.inaxes is None: return if event.button == 3: ax.collections[0]._offsets.append((event.xdata,event.ydata)) ax.collections[0]._facecolors.append(colorConverter.to_rgba('blue')) self.canvas.draw_idle() return if event.button == 2: d = list() for i in ax.collections[0]._offsets: dis = sqrt( (event.xdata - i[0])**2 + (event.ydata - i[1])**2 ) d.append(dis) minn = min(d) minID = d.index(minn) ax.collections[0]._offsets.pop(minID) ax.collections[0]._facecolors.pop(minID) self.canvas.draw_idle() self.Nxy = self.Nxy-1 return self.lasso = Lasso(event.inaxes,(event.xdata, event.ydata), self.callback) # acquire a lock on the widget drawing # self.canvas.widgetlock(self.lasso) data = [Datum(*xy) for xy in nx.mlab.rand(100,2)] fig = figure() ax = fig.add_subplot(111, xlim=(0,1), ylim=(0,1), autoscale_on=False) flag = 0 lman = LassoManager(ax, data) ax.grid('on') show() ____________________________________________________________________________________ Bored stiff? Loosen up... Download and play hundreds of games for free on Yahoo! Games. http://games.yahoo.com/games/front
Hi, I'm using matplotlib in a GTK gui canvas with the GTKAgg backend. I'm connecting a mouse click 'button_press_event' to the click function. If I choose print event.x everything works fine. However I'm after the x value in terms of the x-axis not pixels. When I try print event.xdata I get an error message. Am I making a stupid mistake or is this a bug? Thanks Martin self.canvas.connect('button_press_event',self.click) def click(self,widget,event): print 'you clicked', event.xdata, event.ydata #print 'you clicked', event.x, event.y Traceback (most recent call last): File "./dangerplotpy", line 120, in click print 'you clicked', event.xdata, event.ydata AttributeError: xdata
In article <45C...@es...>, Chiara Caronna <chi...@es...> wrote: > I, > I have a problem with showing plot. When I run this code: > > figure(1) > semilogx(data[:,0],data[:,1]) > savefig('try.png') > show() > > > It save the plot properly, but it doesn't show it. I tried to run it > with "--verbose-helpful" and this is the output: > > > matplotlib data path > /usr/local/lib/python2.4/site-packages/matplotlib/mpl-data > $HOME=/users/caronna > CONFIGDIR=/users/caronna/.matplotlib > loaded rc file > /usr/local/lib/python2.4/site-packages/matplotlib/mpl-data/matplotlibrc > matplotlib version 0.87.7 > verbose.level helpful > interactive is False > platform is linux2 > numerix numpy 1.0.1 > font search path > ['/usr/local/lib/python2.4/site-packages/matplotlib/mpl-data'] > loaded ttfcache file /users/caronna/.matplotlib/ttffont.cache > backend Agg version v2.2 > > Does anyone know what's the problem? I'm not familiar with the "Agg" back end but I suspect it does not support output on a display. Try TkAgg, WXAgg or GTKAgg instead (depending what matplotlib was built to support) e.g. by editing ~/.matplotlib/matplotlibrc -- Russell
On 2/4/07, David Levitan <da...@dl...> wrote: > I'm trying to create an application that, among other things, will allow > me to view an image, zoom into it, and move it around. Essentially what > I can do by using imshow and show in ipython. However, I've noticed that > in both interactive usage and my application the image comes up in a > small set of axes that do not fill up the screen 100% (the image is > rectangular). Zooming or dragging the image around then causes part of > it to go off the axes, which is not desirable. > > What I would like to do is increase the size of the area where the image > can be displayed to the area given to the canvas in my application. > Then, if I drag the image around, part of it won't disappear. However, > I'm not really sure how to do this. What is the best way to accomplish > this goal (preferably for non-interactive usage - I'm using the QT4 back > end)? You can set the size of the axes you want using ax = fig.add_axes([left, bottom, width, height]) where all numbers are fractions of figure size, eg ax = fig.add_axes([0.1, 0.1, 0.8, 0.8]) My guess is what you are experiencing may result from the image aspect handling. Try setting the aspect to 'auto' when you create your image ax.imshow(X, aspect=' auto') JDH
Stephen Uhlhorn wrote: > If what I want is simply a stable scipy/matplotlib > installation (OS X), what is the best (most stable and predictable) > method? I'm very sorry to say that I don't know that there is a best. I, and others, have tried to keep the archive at pythonmac up to date, but building SciPy is still a pain in the %$$%^%, and there is no easy solution unless (until) Apple of someone puts out a Fortran compiler that makes Universal binaries. However, if you like (or don't mind) fink or darwinports, that may be the easiest way to go -- you should be able to use them to build stuff yourself if the package you want is not up to date. They don't support Universal binaries either, but that only matters if you want to re-distribute them. > BTW- What is wrong with the ActiveState python installation? It was > recommended on the scipy site. I have no idea. At one point, it didn't support Universal binaries -- that may not be true anymore, and may not matter for you anyway. There are WAY too many ways to install Python on OS-X. A while back, the MacPython community (that is, the folks on the pythonmac mailing list) decided that the Universal Framework Build, as found on pythonmac.org and python.org should be advocated as "the" way to do Python on OS-X, and the one that we would try as best we could to support with binary packages, and support on the mailing list. Fink and darwinports are other beasts altogether, and take care of themselves. I don't know what ActiveState's goal are with their build. At one point they had a package repository of some kind -- do they now? -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chr...@no...
On 2/1/07, Nicolas <nic...@ya...> wrote: > I tried to use some affine transformations, but it didn't match to get it > works. > I use matplotlib 0.87.5 with python 2.4.3 and Numeric 24.2 on winXP. > > I tried for example : > plot([1,0,1],[0,1,0], transform = matplotlib.transforms.Affine(0,1,1,0,0,0)) You cannot pass scalars to the Affine constructor -- matplotlib uses value reference semantics in the transform, as explained at http://matplotlib.sf.net/matplotlib.transforms.html and so you need to construct your transformation like so: import matplotlib.transforms as t def make_affine(a,b,c,d,tx,ty): return t.Affine(*[t.Value(val) for val in (a,b,c,d,tx,ty)]) a = make_affine(0,1,1,0,0,0) >>> print a.xy_tup((1,1)) (1.0, 1.0) >>> print a.xy_tup((-1,1)) (1.0, -1.0) Note there was a bug in older versions of mpl in the affine class that was fixed, specifically in the sign of b and c. I am not sure which version that was off the top of my head, so if you see any problems consider upgrading.
On 2/4/07, JJ <jos...@ya...> wrote: > Hello. > I am new at matplotlib and am trying to modify the > lasso demo so that a line is drawn aound the polygon > made of selected points, and so that this polygon area > is shaded. Ive added the following code to the > callback function but receive the error: CXX : Error > creating object of type N2Py7SeqBaseINS_6ObjectEEE. > Im sure this is a simple modification. Can anyone > offer suggestions? If I understand your post correctly, you only need to create a single polygon, the one around the lasso region, and thus you should use a matplotlib.patch.Polygon, not a RegularPolyCollection, which as the name suggests is for multiple regular polygons. The RegPolygonCollection in the lasso demo code is used to draw the many polygons you are selecting but is not the right way to construct a single polygon. Also, in the future, it will help us if you post complete examples that we can run, rather than snippets. The following code does what I think you want:: from matplotlib.widgets import Lasso import matplotlib.mlab from matplotlib.nxutils import points_inside_poly from matplotlib.colors import colorConverter from matplotlib.collections import RegularPolyCollection from matplotlib.patches import Polygon from pylab import figure, show, nx class Datum: colorin = colorConverter.to_rgba('red') colorout = colorConverter.to_rgba('green') def __init__(self, x, y, include=False): self.x = x self.y = y if include: self.color = self.colorin else: self.color = self.colorout class LassoManager: def __init__(self, ax, data): self.axes = ax self.canvas = ax.figure.canvas self.data = data self.Nxy = len(data) self.facecolors = [d.color for d in data] self.xys = [(d.x, d.y) for d in data] self.collection = RegularPolyCollection( fig.dpi, 6, sizes=(100,), facecolors=self.facecolors, offsets = self.xys, transOffset = ax.transData) ax.add_collection(self.collection) self.cid = self.canvas.mpl_connect('button_press_event', self.onpress) def callback(self, verts): #print 'all done', verts #ind = matplotlib.mlab._inside_poly_deprecated(self.xys, verts) ind = nx.nonzero(points_inside_poly(self.xys, verts)) for i in range(self.Nxy): if i in ind: self.facecolors[i] = Datum.colorin else: self.facecolors[i] = Datum.colorout self.canvas.draw_idle() self.canvas.widgetlock.release(self.lasso) rect = Polygon(verts, facecolor='red', alpha=0.5) self.axes.add_patch(rect) self.canvas.draw_idle() del self.lasso def onpress(self, event): if self.canvas.widgetlock.locked(): return if event.inaxes is None: return self.lasso = Lasso(event.inaxes, (event.xdata, event.ydata), self.callback) # acquire a lock on the widget drawing self.canvas.widgetlock(self.lasso) data = [Datum(*xy) for xy in nx.mlab.rand(100, 2)] fig = figure() ax = fig.add_subplot(111, xlim=(0,1), ylim=(0,1), autoscale_on=False) lman = LassoManager(ax, data) show() JDH Reply Forward Reply Reply to all Reply to allForward Forward Print Add JJ to Contacts list Delete this message Report phishing Show original Message text garbled? JJ to me show details 1:28 pm (2 minutes ago) Hello John Thanks much for the help. It was just what I needed. I do have another question for you though, if you have a moment. When using the demo, if you click on the plot but do not drag the mouse, the callback function does not get called and a lock stays on the lasso. Can you explain why the callback function does not execute? (see code below) Secondly, the callback function executes after the last line of code in the onpress function. I would have expected it to execute directly after being called in the self.lasso = Lasso(...) line. Can you explain why this is so? (see code below) Thanks again for your assistance. John import os from numpy import * import glob from matplotlib.widgets import Lasso import matplotlib.mlab from matplotlib.nxutils import points_inside_poly from matplotlib.colors import colorConverter from matplotlib.collections import RegularPolyCollection from matplotlib.patches import Polygon import pdb - Show quoted text - class Datum: colorin = colorConverter.to_rgba('red') colorout = colorConverter.to_rgba('green') def __init__(self, x, y, include=False): self.x = x self.y = y if include: self.color = self.colorin else: self.color = self.colorout class LassoManager: def __init__(self, ax, data): self.axes = ax self.canvas = ax.figure.canvas self.data = data self.Nxy = len(data) self.facecolors = [d.color for d in data] self.xys = [(d.x, d.y) for d in data] self.collection = RegularPolyCollection( fig.dpi, 6, sizes=(100,), facecolors=self.facecolors, offsets = self.xys, transOffset = ax.transData) ax.add_collection(self.collection) self.cid = self.canvas.mpl_connect('button_press_event', self.onpress) def callback(self, verts): print "in callback A: ",self.canvas.widgetlock.locked() ind = nx.nonzero(points_inside_poly(self.xys, verts)) for i in range(self.Nxy): if i in ind: self.facecolors[i] = Datum.colorin else: self.facecolors[i] = Datum.colorout self.canvas.draw_idle() self.canvas.widgetlock.release(self.lasso) print "in callback B: ",self.canvas.widgetlock.locked() # draw polygon xyo=list() for i in ind: xyo.append(self.xys[i]) rect = Polygon(xyo, facecolor='red', alpha=0.5) self.axes.add_patch(rect) self.canvas.draw_idle() del self.lasso def onpress(self, event): print "\n in onpress",self.canvas.widgetlock.locked() #pdb.set_trace() if (event.button == 3) & self.canvas.widgetlock.locked(): print "button 3:", event.button self.canvas.widgetlock.release(self.lasso) print self.canvas.widgetlock.locked() if self.canvas.widgetlock.locked(): print "widget locked" return if event.inaxes is None: print "inaxes is none" return print event.inaxes, (event.xdata, event.ydata) self.lasso = Lasso(event.inaxes,(event.xdata, event.ydata), self.callback) # acquire a lock on the widget drawing print "A: ",self.canvas.widgetlock.locked() self.canvas.widgetlock(self.lasso) print "B: ",self.canvas.widgetlock.locked() data = [Datum(*xy) for xy in nx.mlab.rand(100,2)] fig = figure() ax = fig.add_subplot(111, xlim=(0,1), ylim=(0,1), autoscale_on=False) lman = LassoManager(ax, data) show()
Hmm... After the long discussion I'm trying to decide what the best route is. If what I want is simply a stable scipy/matplotlib installation (OS X), what is the best (most stable and predictable) method? BTW- What is wrong with the ActiveState python installation? It was recommended on the scipy site. -stephen On 2/5/07, Christopher Barker <Chr...@no...> wrote: > Stephen: > > Russell E Owen wrote: > > It's up. Bob Ippolito put it up shortly after he got back from vacation. > > So this should work, with the Python, numpy, wxPython2.6.3 that are also > there: > > http://pythonmac.org/packages/py24-fat/index.html > > -Chris
Stephen: Russell E Owen wrote: > It's up. Bob Ippolito put it up shortly after he got back from vacation. So this should work, with the Python, numpy, wxPython2.6.3 that are also there: http://pythonmac.org/packages/py24-fat/index.html -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chr...@no...
At 9:42 AM -0800 2007年02月05日, Christopher Barker wrote: >Stephen Uhlhorn wrote: >>My python is from ActiveState (Framework) which >>was recommended by the scipy people. > >>Here's the real saga. I had a working Fink installaiton of >>python/numpy/scipy/matplotlib until an update to scipy broke critical >>functions (fopen). The fix is in cvs, so this whole mess started in an >>attempt to use a cvs version of scipy. > >You could (should) have re-built scipy inside your fink distro. I would like to add that I used to keep a unix/X11 build of python on my Mac in parallel with a framework build so I could test a GUI app on X11 and Aqua. (I build the stuff myself instead of using fink; I never could get comfortable with fink). In any case, I eventually gave up. Installing packages that had a GUI interface took extra work -- for the X11 python I had to temporarily hide the Aqua GUI stuff. Eventually I gave up and ditched the X11 version. But if you *only* use fink then this comment is irrelevant--they've handled it for you. >>I tried wxpython2.6 first, but figure windows never got drawn on my >>display, even when I used pythonw. > >wxPython 2.6.3, as distributed on the wxPython site and pythonmac, >should work with MPL. I've lost track of whether there is a properly >built binary of MPL on pythonmac at this point. Search these >archives, and you'll see discussion of how to do it, or send a note >to me if this one fails: > >http://pythonmac.org/packages/py24-fat/index.html > >Russell, if you're listening -- did you ever post your binary for >Python2.4, wxPython2.6.3 ? It's up. Bob Ippolito put it up shortly after he got back from vacation. -- Russell
Stephen Uhlhorn wrote: > My python is from ActiveState (Framework) which > was recommended by the scipy people. I wonder why, I don't what the advantages of it are over the pythonmac version -- last I heard it did NOT support Universal binaries, but maybe that makes things a bit easier, particularly for scipy, and there is no easy way to build universal binaries from Fortran. > Here's the real saga. I had a working Fink installaiton of > python/numpy/scipy/matplotlib until an update to scipy broke critical > functions (fopen). The fix is in cvs, so this whole mess started in an > attempt to use a cvs version of scipy. You could (should) have re-built scipy inside your fink distro. > I tried wxpython2.6 first, but figure windows never got drawn on my > display, even when I used pythonw. wxPython 2.6.3, as distributed on the wxPython site and pythonmac, should work with MPL. I've lost track of whether there is a properly built binary of MPL on pythonmac at this point. Search these archives, and you'll see discussion of how to do it, or send a note to me if this one fails: http://pythonmac.org/packages/py24-fat/index.html Russell, if you're listening -- did you ever post your binary for Python2.4, wxPython2.6.3 ? > So I tried pygtk because it worked > fine for me under fink and on my linux box. I thought I could build a > binary pygtk with darwinports and use it in my installation... I guess > not. nope, PYGTK is a good option IF you want to stick with darwinports or Fink, but not if you want the more "mac native" setup. > 1) Build a mpkg of pygtk using darwinports and install it under my > python. Is this possible? not easily -- I don't think it's been done --someone correct me if I'm wrong. > 2) Get wx working somehow. Where do I begin? with the package above, the notes that should be on this list, and if you're lucky with Russell Owens' binary. If all that fails, drop me a note, either Russell or I should be able to get you going. Note that there are some yet-unresolved issues with the wx back-end with wxPython2.8, at least on OS-X, so I'd stick with 2.6.3. OH, and I've lost track, are you using Python 2.4 or 2.5? It should all work with 2.5, but I (and I think Russell) are using wxPython2.8 with Python 2.5 and wxPython2.6 with Python 2.4. > 3) Cocoa backend? I didn't know there was one. It may not have ever matured -- anyone know? > 4) Go back to fink or darwinports and fight these problems on the scipy > side. If you had Fink all working, it might be easiest to start there -- you just need to re-build scipy with all the fink tools -- that should be much like building it on Linux. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chr...@no...
>>> I want to import binary files generated from C/FORTRAN into matplotlib for >>> plotting. if it's just a block of bytes in a standard type from and n-d array, you can use numpy.fromfile() If not, then you may have to read through the file in chunks, with various calls to file.read(), to get to the right point, then use numpy.fromfile(). If the data is in records with mixed types, then you'll need to use the struct module to read them, or possibly numpy record arrays and fromfile. Note that FORTRAN "unformatted" records pad the data with 4 bytes before and after (at least with the compiler that produces some recent data I needed). -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chr...@no...
Kumar Appaiah wrote: > On Fri, Feb 02, 2007 at 05:14:37AM -0800, Vijay Kumar wrote: >> Hi, >> >> I want to import binary files generated from C/FORTRAN into matplotlib for >> plotting. >> Can this be done using 'load'? > > If you are using SciPy, scipy.io has a few functions which may > help. scipy.io.fromfile, for example. > Or, if you have to pay attention to endianess, you could use something like this. import numpy as N def load_binary_data(filename, dtype=float): """ We assume that the data was written with write_binary_data() (little endian). """ f = open(filename, "rb") data = f.read() f.close() _data = N.fromstring(data, dtype) # data has been written by write_binary_data() in little endian if sys.byteorder == 'big': _data = _data.byteswap() return _data def write_binary_data(filename, data, dtype=float): """ Write binary data to a file and make sure it is always in little endian format. """ f = open(filename, "wb") _data = N.asarray(data, dtype) # check byteorder of the system, convert to little endian if needed if sys.byteorder == 'big': _data = _data.byteswap() f.write(_data) f.close() hth -- cheers, steve Random number generation is the art of producing pure gibberish as quickly as possible.