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
(20) |
2
(8) |
3
(2) |
4
(7) |
5
(17) |
6
(20) |
7
(17) |
8
(18) |
9
(7) |
10
(4) |
11
(9) |
12
(20) |
13
(20) |
14
(17) |
15
(8) |
16
(2) |
17
(4) |
18
(4) |
19
(13) |
20
(4) |
21
(16) |
22
(9) |
23
(1) |
24
(5) |
25
(8) |
26
(13) |
27
(25) |
28
(25) |
29
(14) |
30
(10) |
31
(1) |
|
|
|
|
|
|
Hi Eric, Eric Firing wrote: > Again, the problem is that automatic masking of nans would be easy with > numarray but not at all easy with Numeric. Given that mpl is designed > to work the same with numarray and Numeric, it is not easy to build good > nan support into mpl. This will change when the successor to Numeric > becomes common enough that support for old Numeric can be dropped, but > not soon. In the meantime, if you want to use nans, you can do > something like this: > > >>> import numarray as N > >>> from numarray.ieeespecial import isnan, nan > >>> import numarray.ma as ma > >>> a = N.array([1, 2, nan, 3, 4]) > >>> b = ma.masked_where(isnan(a), a) > > Now you can plot b and it will have a gap in the middle. > I tried it as described above but plotting with pylab.plot results in an error message: MAError: Cannot automatically convert masked array to Numeric because data is masked in one or more locations. Am I missing something? Regards, Christian
Graeme O'Keefe wrote: > Hi, > > I know this really belongs on the sourceforge.net:numarray list, but it > is a very inactive list. It's still the right place to ask. Your question would get answered in a timely manner. We're quiet; we're not gone. :-) Followup-to has been reset. > I have noted the following with numarray: > > >>> x = numarray.zeros([3,3], numarray.Int16) > >>> i = [0,1,2,0,1,2] > >>> j = [0,1,2,0,1,2] > >>> x[i, j] += 1 > >>> print x > [[1, 0, 0] > [0, 1, 0] > [0, 0, 1]] > I was expecting (hoping) > [[2, 0, 0] > [0, 2, 0] > [0, 0, 2]] > > which is what you obviously get if you: > > for n in range(len(i)) : x[i[n], j[n]] += 1 > > This is the sort of operation one does all the time when histogramming > data-streams. Is there a way to achieve this without looping over i/j. This has been discussed recently on the numpy-discussion list (Subject: vectorizing histogram-like computation). The semantics of array indexing aren't anything like that for loop. I doubt that the two kinds of semantics could be merged consistently. x[i,j] += 1 is closer to x[i,j] = x[i,j] + 1 which amounts, in this case, to x[i,j] = array([1, 1, 1, 1, 1, 1]) There's nothing in this last operation to suggest that the numbers ought to be added together (and if the initial values weren't zero, a more complicated operation would have to considered). In short, I consider it cleaner to keep specialized histogram code tucked away in a function which you can eventually optimize to C as required. -- Robert Kern rk...@uc... "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter
Hi, I know this really belongs on the sourceforge.net:numarray list, but it is a very inactive list. I have noted the following with numarray: >>> x = numarray.zeros([3,3], numarray.Int16) >>> i = [0,1,2,0,1,2] >>> j = [0,1,2,0,1,2] >>> x[i, j] += 1 >>> print x [[1, 0, 0] [0, 1, 0] [0, 0, 1]] I was expecting (hoping) [[2, 0, 0] [0, 2, 0] [0, 0, 2]] which is what you obviously get if you: for n in range(len(i)) : x[i[n], j[n]] += 1 This is the sort of operation one does all the time when histogramming data-streams. Is there a way to achieve this without looping over i/j. cheers, Graeme
I have been using matplotlib as a replacement for MatLab and have had a great deal of success repicating basic plots. I was now trying to replicate some of the more value added functionality like the normplot and cdfplot. The normplot is particularly tricky because you need to scale the axises by the inverse normal cdf. There seems to be functionality to write scalers but the only ones that come with matplotlib out of the box are linear and log. Does anyone know how I might be able to achieve this functionality? --Tom
matplotlib list: I've moved this thread over to the ipython list. f
This is a bit bizarre. It took me a couple looks to figure out what was happening. I am using the 'run' command under IPython. Error tracebacks print the correct line number of the current file but *list* (and therefore highlight) that line from an *earlier* version of the file. This is particularly obvious when deleted lines appear in the traceback printout. After a bit of exploration, it seems that the lines printed corrrespond to the file as first run. Changes to the file are correctly run and traced, but the lines printed appear to be from a cached (and obsolete) version of the file. Has anyone else seen this? Any thoughts on how to fix it? Cheers, Alan Isaac
Great thank you. One more question. I also want to change the tick mark attributes like color, fontsize, rotation etc. I used these lines of code: # set x-axes tick label attributes axesA.set_yticklabels(axesA.get_xticklabels(), rotation=0, fontsize=5, color='k') axesD.set_yticklabels(axesD.get_xticklabels(), rotation=0, fontsize=5, color='k') # set y-axes tick label attributes axesA.set_yticklabels(axesA.get_yticklabels(), rotation=0, fontsize=5, color='k') axesD.set_yticklabels(axesD.get_yticklabels(), rotation=0, fontsize=5, color='k') I get an error because get_ticklabels() returns an instance of label strings, not the strings themselves. How can I convert these into a useful string so the above code works? Or is there a better way to do this? Thanks again! -----Original Message----- From: John Hunter [mailto:jdh...@ni...] Sent: Wednesday, July 13, 2005 10:41 AM To: Jeff Peery Cc: mat...@li... Subject: Re: [Matplotlib-users] transparent symbols >>>>> "Jeff" == Jeff Peery <jef...@se...> writes: Jeff> Hello, I attached a sample. I'm trying to plot a line using Jeff> markers and I would like those markers to be transparent. I Jeff> use the keyword 'alpha=0.2' to set the transparency although Jeff> the marker are not transparent? Does anyone know how to make Jeff> this work? Thanks for the help! See the recent thread "transparent markerfacecolors" http://sourceforge.net/mailarchive/message.php?msg_id=12261949 Basically, this is a bug but you can work around it with scatter. Jeff> Also, is it possible to set autoscale for just x-axis or Jeff> just y-axis? I haven't found a way to do this. Thanks again. You can do this by setting a custom ticker.locator for the axis that you don't want autoscaled, following the examples major_minor_demo*.py and Chapter 5 of the user's guide. JDH
>>>>> "Jeff" == Jeff Peery <jef...@se...> writes: Jeff> Hello, I attached a sample. I'm trying to plot a line using Jeff> markers and I would like those markers to be transparent. I Jeff> use the keyword 'alpha=0.2' to set the transparency although Jeff> the marker are not transparent? Does anyone know how to make Jeff> this work? Thanks for the help! See the recent thread "transparent markerfacecolors" http://sourceforge.net/mailarchive/message.php?msg_id=12261949 Basically, this is a bug but you can work around it with scatter. Jeff> Also, is it possible to set autoscale for just x-axis or Jeff> just y-axis? I haven't found a way to do this. Thanks again. You can do this by setting a custom ticker.locator for the axis that you don't want autoscaled, following the examples major_minor_demo*.py and Chapter 5 of the user's guide. JDH
John Hunter wrote: >>>>>>"Eugen" == Eugen Wintersberger <eug...@jk...> writes: > > > Eugen> Hi there I have a problem with matplotlib (0.8) and IPython > Eugen> (0.6.15) on a Debian 3.1 system together with the GTK > Eugen> interface. Ipython crashes when one tries to make a simple > Eugen> plot. This is quite strange since I changes from a former > Eugen> setup with ipython (0.6.13) to iptyon (0.6.15) to use the > Eugen> GTK interface and it worked quite well. It seems that > Eugen> maybe changing from Debian testing to stable maybe messed > Eugen> up the setup. Has anyone an idea where the problem > Eugen> described below comes from. > > I took a quick look over your strace and didn't see anything obviou. > You might want to bring this up with the debian maintainer, because I > have never seen this error before and so it may not be a matplotlib > problem per se. I also had a look, and on first guess I'd venture it's a GTK bug. All the internal errors seem to be related to GTK font handling and interactions with X11. It certainly doesn't look like anything caused by matplotlib (and since ipython is pure python, it can't cause segfaults by itself). Cheers, f
Hello, I attached a sample. I'm trying to plot a line using markers and I would like those markers to be transparent. I use the keyword 'alpha=0.2' to set the transparency although the marker are not transparent? Does anyone know how to make this work? Thanks for the help! Also, is it possible to set autoscale for just x-axis or just y-axis? I haven't found a way to do this. Thanks again. Jeff
>>>>>> "Alan" == Alan G Isaac <ai...@am...> writes: > Alan> Not a big deal but ... Would it not be natural for date2num > Alan> to accept an rrule as an argument? I.e., why force us to > Alan> make a list of an rrule? On 2005年7月13日, John Hunter apparently wrote: > But rrules need a before and after to define their endpoints. What > would this interface to date2num look like? > I have no problem with this suggestions, but it might be more natural > to define > def rrule2num(after, before, rrule): > return date2num(rrule.between(after, before)) > where after and before are datetime instances... > return date2num(rrule.between(after, before)) I had in mind only rrules that specified the sample exactly, so that they were already a finite iterable. E.g., x = rrule(MONTHLY,dtstart=date(1990,1,1),until=date(2005,1,1),inc=True) Unfortunately rrule.count() will count forever, so I'm not sure how best to check for finitude. I do *not* want to propose a new function. It just seemed obvious that date2num could easily handle such rrules, but I was thinking only of fully delimited rrules. Thanks, Alan
On 2005年7月12日, Eric Firing apparently wrote: >>> import numarray as N >>> from numarray.ieeespecial import isnan, nan >>> import numarray.ma as ma >>> a = N.array([1, 2, nan, 3, 4]) >>> b = ma.masked_where(isnan(a), a) > Now you can plot b and it will have a gap in the middle. Thanks. Alan
>I don't think that "plot" has the "set_data" attribute that I need in or= der >to interact with every single point of the plot, but I may be wrong. > >Andrea. Sorry, I have said something stupid. Of course I can use plot, now it's working. However, I have another (probably basic) question. In order to reverse the y-axis, for example, the only way I found is to get the minim= um and the maximum of my data and then do something like: myaxes.set_ylim(mymax, mymin) Is there a more intelligent way? I mean, in this way I have to calculate the minimum and maximum values for every series of point I have, then low= er the minimum and increase the maximum by a small quantity in order to make= the plot looking better (and not tighten to the data) and then use set_yl= im. In the standard case (no axis reverse), is matplotlib that does all the job and it presents me the plot, nice scaled. What I usually do in Matlab= , is something like set(myaxes, 'ydir', 'reverse'), and it does the job... does anything similar exists for matplotlib? Sorry if it is a very basic question. Andrea.
>can't you use plot() instead of Line2D? something like: > >b =3D fig.subplot >b.plot(your_data, marker=3D'0', linestyle=3DNone) I don't think that "plot" has the "set_data" attribute that I need in ord= er to interact with every single point of the plot, but I may be wrong. Andrea.
On Jul 13, 2005, at 9:57 AM, and...@ti... wrote: >> Have you seen examples/poly_editor.py? It plots a polygon and at each >> vertex plots a marker. You can click on the marker and drag it and >> move the vertex around, as well as insert and delete vertices. It >> would be easy to modify the callback to change the marker color, size >> etc, to indicate that it is selected. The example doesn't do what you >> are want precisely, but does provide a lot of code illustrating how to >> do these things with mpl event handling. > > Thanks John for the pointer! You gave me a lot of new ideas... > Just another (probably stupid) question, but I'm becoming crazy to > solve > it. In my plot, I would like to have the points plotted as dots and > *without* > the line that connects them. I am using Line2D from > matplotlib.lines.Line2D > as: > > axdata = self.fig.add_subplot(111) > self.line = Line2D(pressure, depths, marker='o', markerfacecolor='r', > linestyle=None) > axdata.add_line(self.line) > > But whatever option I use, the connecting line is still there... is > there > a way to have only the dots? > > Thank you a lot. > > Andrea. > > can't you use plot() instead of Line2D? something like: b = fig.subplot b.plot(your_data, marker='0', linestyle=None) donour |Donour Sizemore do...@cs...| |Technical Programmer & Numerical Analyst | |Economics Research Center Ph: 773-834-4399 | |University of Chicago Office: Walker 303-a |
>Have you seen examples/poly_editor.py? It plots a polygon and at each >vertex plots a marker. You can click on the marker and drag it and >move the vertex around, as well as insert and delete vertices. It >would be easy to modify the callback to change the marker color, size >etc, to indicate that it is selected. The example doesn't do what you >are want precisely, but does provide a lot of code illustrating how to >do these things with mpl event handling. Thanks John for the pointer! You gave me a lot of new ideas... Just another (probably stupid) question, but I'm becoming crazy to solve it. In my plot, I would like to have the points plotted as dots and *with= out* the line that connects them. I am using Line2D from matplotlib.lines.Line= 2D as: axdata =3D self.fig.add_subplot(111) self.line =3D Line2D(pressure, depths, marker=3D'o', markerfacecolor=3D'r= ', linestyle=3DNone) axdata.add_line(self.line) But whatever option I use, the connecting line is still there... is there= a way to have only the dots? Thank you a lot. Andrea.
>>>>> "Eugen" == Eugen Wintersberger <eug...@jk...> writes: Eugen> Hi there I have a problem with matplotlib (0.8) and IPython Eugen> (0.6.15) on a Debian 3.1 system together with the GTK Eugen> interface. Ipython crashes when one tries to make a simple Eugen> plot. This is quite strange since I changes from a former Eugen> setup with ipython (0.6.13) to iptyon (0.6.15) to use the Eugen> GTK interface and it worked quite well. It seems that Eugen> maybe changing from Debian testing to stable maybe messed Eugen> up the setup. Has anyone an idea where the problem Eugen> described below comes from. I took a quick look over your strace and didn't see anything obviou. You might want to bring this up with the debian maintainer, because I have never seen this error before and so it may not be a matplotlib problem per se. JDH
>>>>> "Alan" == Alan G Isaac <ai...@am...> writes: Alan> Not a big deal but ... Would it not be natural for date2num Alan> to accept an rrule as an argument? I.e., why force us to Alan> make a list of an rrule? But rrules need a before and after to define their endpoints. What would this interface to date2num look like? I have no problem with this suggestions, but it might be more natural to define def rrule2num(after, before, rrule): return date2num(rrule.between(after, before)) where after and before are datetime instances... JDH
>>>>> "andrea" == andrea gavana <and...@ti...> writes: andrea> Now, the question: Which is the best approach with andrea> Matplotlib for this kind of interaction? Should I plot andrea> every point using plot(x1, y1), plot(x2, y2) etc...? Or andrea> should I use Collections (i have no idea on what to do andrea> with collections)? Scattered plots? Does anyone have any andrea> suggestion/pointer for me? Some examples of andrea> editing/interacting with plots? Have you seen examples/poly_editor.py? It plots a polygon and at each vertex plots a marker. You can click on the marker and drag it and move the vertex around, as well as insert and delete vertices. It would be easy to modify the callback to change the marker color, size etc, to indicate that it is selected. The example doesn't do what you are want precisely, but does provide a lot of code illustrating how to do these things with mpl event handling. Note particularly the "i" functionality for inserting a vertex. To insert a vertex your cursor must be over a line segment connecting two vertices. From your description of needing to interact with the line between two points, it should like this lass might be helpful. class PolygonInteractor: """ An polygon editor. Key-bindings 't' toggle vertex markers on and off. When vertex markers are on, you can move them, delete them 'd' delete the vertex under point 'i' insert a vertex at point. You must be within epsilon of the line connecting two existing vertices You might want to define your own "interactor" classes similar to PolygonInteractor (eg a LineSegmentInteractor). Then the line segment will encompass all the intelligence you need and can easily be plugged into your graph. If you come up with useful widgets like these, please send them our way. Also feel free to post partially working code if you get stuck, On a related note, to make something like this work efficiently it helps to be able to redraw just part of a figure. The current release of mpl has support for this with GTKAgg only, but only a few new backend methods that need to be defined to support this. This makes things like moving objects around the canvas much more efficiently. It would be nice to have them for the various *Agg backends The required methods are: region = canvas.copy_from_bbox(bbox) canvas.restore_region(region) canvas.blit(bbox) region can be any backend dependent object -- the front end doesn't use it, only passes it around. bbox is a transforms.BBox instance. If anyone is interested in animation and knows something about Tk, WX, Qt, FLTK, you may want to take a crack at implementing these methods. Below is another interaction/widget which provides a Rectangle widget that can be resized or moved around (GTKAgg only). When you click on the edge of the rectangle the edgecolor turns red and when you release it the color is restored. There are some bugs, but it does illustrate more interaction code as well as provide a test script for anyone who wants to understand how to use the three methods shown above. import matplotlib matplotlib.use('GTKAgg') from pylab import * from matplotlib.transforms import lbwh_to_bbox from matplotlib.mlab import dist_point_to_segment class RectangleWidget(Rectangle): def __init__(self, figure, *args, **kwargs): Rectangle.__init__(self, *args, **kwargs) self.figure = figure self.idle = True self.oldbox = self.get_window_extent() self.newbox = self.get_window_extent() self.region = self.figure.canvas.copy_from_bbox(self.oldbox) self.figure.canvas.mpl_connect('motion_notify_event', self.move) self.figure.canvas.mpl_connect('button_press_event', self.press) self.figure.canvas.mpl_connect('button_release_event', self.release) self.figure.draw_artist(self) self._resize = False self._drag = False def redraw(self): canvas = self.figure.canvas canvas.restore_region(self.region) self.region = canvas.copy_from_bbox(self.newbox) self.figure.draw_artist(self) canvas.blit(self.oldbox) canvas.blit(self.newbox) def press(self, event): if event.button!=1: return x, y = self.xy w, h = self.width, self.height # the four line segments of the rectangle lb = x, y lt = x, y+h rb = x+w, y rt = x+w, y+h segments = { 'left' : (lb, lt), 'right' : (rb, rt), 'top' : (lt, rt), 'bottom' : (lb, rb), } p = event.x, event.y near = [] for name, segment in segments.items(): s0, s1 = segment d = dist_point_to_segment(p, s0, s1) if d<5: near.append(name) info = event.x, event.y, self.xy[0], self.xy[1], self.width, self.height, near if len(near): self._resize = info self.set_edgecolor('red') self.set_linewidth(2) else: self._resize = False if self.get_window_extent().contains(event.x, event.y): self._drag = info self.redraw() def release(self, event): if event.button!=1: return self._resize = False self._drag = False self.idle = True self.set_edgecolor('black') self.set_linewidth(0.5) self.redraw() def move(self, event): if not (self.idle and (self._resize or self._drag)): return self.idle = False canvas = self.figure.canvas if self._resize: exo, eyo, xo, yo, wo, ho, near = self._resize else: exo, eyo, xo, yo, wo, ho, near = self._drag scalex=0; scaley=0; scalew=0; scaleh=0 if 'left' in near: scalex = 1 scalew = -1 if 'right' in near: scalew = 1 if 'bottom' in near: scaley = 1 scaleh = -1 if 'top' in near: scaleh = 1 if self._drag: scalex = 1 scaley = 1 dx = event.x - exo dy = event.y - eyo if event.button ==1: self.oldbox = self.get_padded_box() newx = xo + scalex*dx if scalew==0 or newx<xo+wo: self.xy[0] = newx newy = yo + scaley*dy if scaleh==0 or newy<yo+ho: self.xy[1] = newy neww = wo + scalew*dx if neww>0: self.width = neww newh = ho + scaleh*dy if newh>0: self.height = newh #self.xy = event.x, event.y self.newbox = self.get_padded_box() #print event.x, event.y, self.get_padded_box().get_bounds() self.redraw() self.idle = True def get_padded_box(self, pad=5): xmin = self.xy[0]-pad ymin = self.xy[1]-pad return lbwh_to_bbox(xmin, ymin, self.width+2*pad, self.height+2*pad) ion() fig = figure() def keypress(event): if event.key=='n': widget = RectangleWidget( fig, (100,100), 20, 30) fig.canvas.blit() fig.canvas.mpl_connect('key_press_event', keypress) fig.text(0.1, 0.9, "Press n for new rectangle and then resize it or move it") draw() show()
Hi there I have a problem with matplotlib (0.8) and IPython (0.6.15) on a Debian 3.1 system together with the GTK interface. Ipython crashes when one tries to make a simple plot. This is quite strange since I changes from a former setup with ipython (0.6.13) to iptyon (0.6.15) to use the GTK interface and it worked quite well. It seems that maybe changing from Debian testing to stable maybe messed up the setup. Has anyone an idea where the problem described below comes from. Starting ipython with the -pylab option and typing In [1]: x = arrayrange(1,100) In [2]: plot(x) gives *** Break *** segmentation violation Generating stack trace... 0x40d3cff1 in <unknown> from /usr/X11R6/lib/libX11.so.6 0x40d28439 in XrmQGetResource + 0x149 from /usr/X11R6/lib/libX11.so.6 0x40d08896 in XGetDefault + 0xd6 from /usr/X11R6/lib/libX11.so.6 0x40dd4456 in <unknown> from /usr/lib/libXft.so.2 0x40dd4592 in <unknown> from /usr/lib/libXft.so.2 0x40dd4728 in <unknown> from /usr/lib/libXft.so.2 0x40dd4806 in XftDefaultGetInteger + 0x26 from /usr/lib/libXft.so.2 0x40dd3e62 in _XftDisplayInfoGet + 0x152 from /usr/lib/libXft.so.2 0x40dd4218 in XftDefaultHasRender + 0x28 from /usr/lib/libXft.so.2 0x40dd4ce0 in XftDefaultSubstitute + 0x470 from /usr/lib/libXft.so.2 0x40ca0a93 in <unknown> from /usr/lib/libpangoxft-1.0.so.0 0x40ea7503 in <unknown> from /usr/lib/libpangoft2-1.0.so.0 0x40ea75ab in <unknown> from /usr/lib/libpangoft2-1.0.so.0 0x40ea78c4 in <unknown> from /usr/lib/libpangoft2-1.0.so.0 0x40cc48b1 in pango_font_map_load_fontset + 0x81 from /usr/lib/libpango-1.0.so.0 0x40cc2eb3 in <unknown> from /usr/lib/libpango-1.0.so.0 0x40cc2f86 in <unknown> from /usr/lib/libpango-1.0.so.0 0x40cc3258 in pango_itemize_with_base_dir + 0xa8 from /usr/lib/libpango-1.0.so.0 0x40cca69f in <unknown> from /usr/lib/libpango-1.0.so.0 0x40cc8b86 in <unknown> from /usr/lib/libpango-1.0.so.0 0x40cc8ef7 in pango_layout_get_extents + 0x37 from /usr/lib/libpango-1.0.so.0 0x40cc8f84 in pango_layout_get_pixel_extents + 0x54 from /usr/lib/libpango-1.0.so.0 0x40977136 in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x409774c1 in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x40971c63 in gtk_cell_renderer_get_size + 0xb3 from /usr/lib/libgtk-x11-2.0.so.0 0x40b0ca24 in gtk_tree_view_column_cell_get_size + 0x144 from /usr/lib/libgtk-x11-2.0.so.0 0x40af9ef5 in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x40afaddb in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x40afb165 in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x40af4a25 in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x406e4b63 in g_cclosure_marshal_VOID__BOXED + 0x83 from /usr/lib/libgobject-2.0.so.0 0x406d29c9 in <unknown> from /usr/lib/libgobject-2.0.so.0 0x406d2736 in g_closure_invoke + 0xb6 from /usr/lib/libgobject-2.0.so.0 0x406e3651 in <unknown> from /usr/lib/libgobject-2.0.so.0 0x406e2e9c in g_signal_emit_valist + 0x73c from /usr/lib/libgobject-2.0.so.0 0x406e3216 in g_signal_emit_by_name + 0xe6 from /usr/lib/libgobject-2.0.so.0 0x40a78ece in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x40a79248 in _gtk_size_group_compute_requisition + 0x68 from /usr/lib/libgtk-x11-2.0.so.0 0x40b1c61c in gtk_widget_size_request + 0x4c from /usr/lib/libgtk-x11-2.0.so.0 0x40a6e113 in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x406e4b63 in g_cclosure_marshal_VOID__BOXED + 0x83 from /usr/lib/libgobject-2.0.so.0 0x406d29c9 in <unknown> from /usr/lib/libgobject-2.0.so.0 0x406d2736 in g_closure_invoke + 0xb6 from /usr/lib/libgobject-2.0.so.0 0x406e3651 in <unknown> from /usr/lib/libgobject-2.0.so.0 0x406e2e9c in g_signal_emit_valist + 0x73c from /usr/lib/libgobject-2.0.so.0 0x406e3216 in g_signal_emit_by_name + 0xe6 from /usr/lib/libgobject-2.0.so.0 0x40a78ece in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x40a79248 in _gtk_size_group_compute_requisition + 0x68 from /usr/lib/libgtk-x11-2.0.so.0 0x40b1c61c in gtk_widget_size_request + 0x4c from /usr/lib/libgtk-x11-2.0.so.0 0x40b14c23 in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x406e4b63 in g_cclosure_marshal_VOID__BOXED + 0x83 from /usr/lib/libgobject-2.0.so.0 0x406d29c9 in <unknown> from /usr/lib/libgobject-2.0.so.0 0x406d2736 in g_closure_invoke + 0xb6 from /usr/lib/libgobject-2.0.so.0 0x406e3651 in <unknown> from /usr/lib/libgobject-2.0.so.0 0x406e2e9c in g_signal_emit_valist + 0x73c from /usr/lib/libgobject-2.0.so.0 0x406e3216 in g_signal_emit_by_name + 0xe6 from /usr/lib/libgobject-2.0.so.0 0x40a78ece in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x40a79248 in _gtk_size_group_compute_requisition + 0x68 from /usr/lib/libgtk-x11-2.0.so.0 0x40b1c61c in gtk_widget_size_request + 0x4c from /usr/lib/libgtk-x11-2.0.so.0 0x409f4dcf in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x406e4b63 in g_cclosure_marshal_VOID__BOXED + 0x83 from /usr/lib/libgobject-2.0.so.0 0x406d29c9 in <unknown> from /usr/lib/libgobject-2.0.so.0 0x406d2736 in g_closure_invoke + 0xb6 from /usr/lib/libgobject-2.0.so.0 0x406e3651 in <unknown> from /usr/lib/libgobject-2.0.so.0 0x406e2e9c in g_signal_emit_valist + 0x73c from /usr/lib/libgobject-2.0.so.0 0x406e3216 in g_signal_emit_by_name + 0xe6 from /usr/lib/libgobject-2.0.so.0 0x40a78ece in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x40a79248 in _gtk_size_group_compute_requisition + 0x68 from /usr/lib/libgtk-x11-2.0.so.0 0x40b1c61c in gtk_widget_size_request + 0x4c from /usr/lib/libgtk-x11-2.0.so.0 0x40b14c23 in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x406e4b63 in g_cclosure_marshal_VOID__BOXED + 0x83 from /usr/lib/libgobject-2.0.so.0 0x406d29c9 in <unknown> from /usr/lib/libgobject-2.0.so.0 0x406d2736 in g_closure_invoke + 0xb6 from /usr/lib/libgobject-2.0.so.0 0x406e3651 in <unknown> from /usr/lib/libgobject-2.0.so.0 0x406e2e9c in g_signal_emit_valist + 0x73c from /usr/lib/libgobject-2.0.so.0 0x406e3216 in g_signal_emit_by_name + 0xe6 from /usr/lib/libgobject-2.0.so.0 0x40a78ece in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x40a79248 in _gtk_size_group_compute_requisition + 0x68 from /usr/lib/libgtk-x11-2.0.so.0 0x40b1c61c in gtk_widget_size_request + 0x4c from /usr/lib/libgtk-x11-2.0.so.0 0x40b14c23 in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x406e4b63 in g_cclosure_marshal_VOID__BOXED + 0x83 from /usr/lib/libgobject-2.0.so.0 0x406d29c9 in <unknown> from /usr/lib/libgobject-2.0.so.0 0x406d2736 in g_closure_invoke + 0xb6 from /usr/lib/libgobject-2.0.so.0 0x406e3651 in <unknown> from /usr/lib/libgobject-2.0.so.0 0x406e2e9c in g_signal_emit_valist + 0x73c from /usr/lib/libgobject-2.0.so.0 0x406e3216 in g_signal_emit_by_name + 0xe6 from /usr/lib/libgobject-2.0.so.0 0x40a78ece in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x40a79248 in _gtk_size_group_compute_requisition + 0x68 from /usr/lib/libgtk-x11-2.0.so.0 0x40b1c61c in gtk_widget_size_request + 0x4c from /usr/lib/libgtk-x11-2.0.so.0 0x409dbecf in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x409dbf65 in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x409d1818 in _gtk_file_chooser_embed_get_default_size + 0x78 from /usr/lib/libgtk-x11-2.0.so.0 0x409d15d5 in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x409d1818 in _gtk_file_chooser_embed_get_default_size + 0x78 from /usr/lib/libgtk-x11-2.0.so.0 0x409d0eec in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x406e42a6 in g_cclosure_marshal_VOID__VOID + 0x76 from /usr/lib/libgobject-2.0.so.0 0x406d2736 in g_closure_invoke + 0xb6 from /usr/lib/libgobject-2.0.so.0 0x406e3dcf in <unknown> from /usr/lib/libgobject-2.0.so.0 0x406e2e9c in g_signal_emit_valist + 0x73c from /usr/lib/libgobject-2.0.so.0 0x406e3216 in g_signal_emit_by_name + 0xe6 from /usr/lib/libgobject-2.0.so.0 0x409d16a9 in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x406e42a6 in g_cclosure_marshal_VOID__VOID + 0x76 from /usr/lib/libgobject-2.0.so.0 0x406d2736 in g_closure_invoke + 0xb6 from /usr/lib/libgobject-2.0.so.0 0x406e3dcf in <unknown> from /usr/lib/libgobject-2.0.so.0 0x406e2e9c in g_signal_emit_valist + 0x73c from /usr/lib/libgobject-2.0.so.0 0x406e3216 in g_signal_emit_by_name + 0xe6 from /usr/lib/libgobject-2.0.so.0 0x409d99e8 in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x406e4ca3 in g_cclosure_marshal_VOID__OBJECT + 0x83 from /usr/lib/libgobject-2.0.so.0 0x406d29c9 in <unknown> from /usr/lib/libgobject-2.0.so.0 0x406d2736 in g_closure_invoke + 0xb6 from /usr/lib/libgobject-2.0.so.0 0x406e3651 in <unknown> from /usr/lib/libgobject-2.0.so.0 0x406e2e9c in g_signal_emit_valist + 0x73c from /usr/lib/libgobject-2.0.so.0 0x406e3126 in g_signal_emit + 0x26 from /usr/lib/libgobject-2.0.so.0 0x40b1fc7c in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x40b1f44a in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x40a78ea8 in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x40a79248 in _gtk_size_group_compute_requisition + 0x68 from /usr/lib/libgtk-x11-2.0.so.0 0x40b1c61c in gtk_widget_size_request + 0x4c from /usr/lib/libgtk-x11-2.0.so.0 0x409dbecf in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x409dbf65 in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x409d1818 in _gtk_file_chooser_embed_get_default_size + 0x78 from /usr/lib/libgtk-x11-2.0.so.0 0x409d15d5 in <unknown> from /usr/lib/libgtk-x11-2.0.so.0 0x409d1818 in _gtk_file_chooser_embed_get_default_size + 0x78 from /usr/lib/libgtk-x11-2.0.so.0 Aborted Thanks for answering my question cu Eugen
Hello NG, I am building a GUI with wxPython+Matplotlib, using the WXAgg backend= . Basically, what I would like to do, is the following: 1) Having a series of points (x and y coordinates), plot these points (ob= vious ;-) ); 2) I would like to be able to interact with every single point in this se= ries (using the buttondown and buttonmotion functions of Matplotlib); 3) The interaction should include point selection (with some kind of "hig= hlight" when I select one or more point), point editing (move a point in the x or= y direction using the mouse); 4) I would like to be able to plot an interpolation of the selected point= s, with a straight line (in a least squares sense), and then be able to inte= ract with this line (move it, delete it and so on). Now, the question: Which is the best approach with Matplotlib for this ki= nd of interaction? Should I plot every point using plot(x1, y1), plot(x2, y2= ) etc...? Or should I use Collections (i have no idea on what to do with co= llections)? Scattered plots? Does anyone have any suggestion/pointer for me? Some exa= mples of editing/interacting with plots? Thanks for every suggestion. Andrea.
Alan, > > But I still feel something is missing from this discussion. > Would it be odd/hard for plot() to have an option that says, > effectively, mask NaNs so that the expected behavior results? Again, the problem is that automatic masking of nans would be easy with numarray but not at all easy with Numeric. Given that mpl is designed to work the same with numarray and Numeric, it is not easy to build good nan support into mpl. This will change when the successor to Numeric becomes common enough that support for old Numeric can be dropped, but not soon. In the meantime, if you want to use nans, you can do something like this: >>> import numarray as N >>> from numarray.ieeespecial import isnan, nan >>> import numarray.ma as ma >>> a = N.array([1, 2, nan, 3, 4]) >>> b = ma.masked_where(isnan(a), a) Now you can plot b and it will have a gap in the middle. Eric
Not a big deal but ... Would it not be natural for date2num to accept an rrule as an argument? I.e., why force us to make a list of an rrule? fwiw, Alan Isaac
>> x=[1,2,nan,4,5] plot(x) plots a single line. >> I expect two segments and a gap. On 2005年7月11日, Eric Firing apparently wrote: > Slightly modifying a reply to a similar question not long ago: > At present, you need to use masked arrays instead of NaN. So if I use masked arrays, I should get two segments and a gap in the above case? I'm not familiar with masked arrays. Sounds like I'll have to learn about them. But I still feel something is missing from this discussion. Would it be odd/hard for plot() to have an option that says, effectively, mask NaNs so that the expected behavior results? Thanks, Alan
>>>>> "Danny" == Danny Shevitz <sh...@la...> writes: Danny> I would like to create a colormap that plots a particular Danny> value in a specific color but is otherwise normal. So far Danny> I haven't been smart enough to figure out how to do Danny> this. For example, imagine an image with missing data. The Danny> missing data has some sentinel value e.g. -1, which I can Danny> set to be outside the range of the rest of the image. I Danny> want the missing data to plot is a specific color unrelated Danny> to the colormap for the rest of the image. Like I said, I Danny> haven't been clever enough to figure it out. This is sort Danny> of similar behavior to masked arrays in pcolor, but I would Danny> like to use imshow if possible. Perhaps a custom Danny> normalization to compress a given colormap and map the Danny> sentinel to a boundary value which has discontinuous Danny> segment? Any ideas would be appreciated. This is a nice example. At first I thought it would be easier since all one needs to do is define a custom norm and cmap instance to imshow. All these really need to be is callable, but, but because of my &$*%*!#@ C++ background, I introduced typechecking in the imshow code if norm is not None: assert(isinstance(norm, normalize)) if cmap is not None: assert(isinstance(cmap, Colormap)) So there is a little extra overhead to make them the right "type". It would have been preferable to use ducktyping here. The norm instance takes your data and returns a same shape float array ranging normalized to [0,1]. We want to define our own norm instance that preserves the sentinel import pylab import matplotlib.numerix as nx import matplotlib.colors class DannysNorm(matplotlib.colors.normalize): """ Leave the sentinel unchanged """ def __init__(self, sentinel): matplotlib.colors.normalize.__init__(self) self.sentinel = sentinel def __call__(self, value): vnorm = matplotlib.colors.normalize.__call__(self, value) return nx.where(value==self.sentinel, self.sentinel, vnorm) Next you have to define a custom colormap. The cmap instance takes normalized data and returns RGBA data, and the call method is def __call__(self, X, alpha=1): So we need to create a class which takes a default cmap and returns it except at the sentinel value class DannysMap(matplotlib.colors.Colormap): def __init__(self, cmap, sentinel, rgb): self.N = cmap.N self.name = 'DannysMap' self.cmap = cmap self.sentinel = sentinel if len(rgb)!=3: raise ValueError('sentinel color must be RGB') self.rgb = rgb def __call__(self, X, alpha=1): m,n = X.shape r,g,b = self.rgb Xm = self.cmap(X) ret = nx.zeros( (m,n,4), typecode=nx.Float) ret[:,:,0] = nx.where(X==self.sentinel, r, Xm[:,:,0]) ret[:,:,1] = nx.where(X==self.sentinel, g, Xm[:,:,1]) ret[:,:,2] = nx.where(X==self.sentinel, b, Xm[:,:,2]) ret[:,:,3] = nx.where(X==self.sentinel, alpha, Xm[:,:,3]) return ret That's it. Now you just have to pass these on to imshow X = nx.mlab.rand(100,50) X[20:30, 5:10] = -1 cmap = DannysMap(pylab.cm.jet, -1, (1,0,0)) norm = DannysNorm(-1) pylab.imshow(X, cmap = cmap, norm=norm) pylab.show() JDH