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
(14) |
2
(11) |
3
(5) |
4
(17) |
5
(11) |
6
(37) |
7
(35) |
8
(9) |
9
(1) |
10
(9) |
11
(7) |
12
(22) |
13
(34) |
14
(24) |
15
(27) |
16
(13) |
17
(19) |
18
(43) |
19
(36) |
20
(12) |
21
(9) |
22
(21) |
23
(3) |
24
(5) |
25
(30) |
26
(14) |
27
(23) |
28
(19) |
29
(19) |
30
(10) |
31
(6) |
|
|
|
|
|
|
Hi, I want to read images and do some processing with them. While learning how to do this, i.e. opening images, displaying them, transforming them tu numpy arrays, etc., I came across a strange behaviour. If I open an image and use imshow() to display it, it comes upside down. See this thread in the numpy mailing list for more details: http://thread.gmane.org/gmane.comp.python.numeric.general/30148 . Someone on that list suggested to check here if this behavior was correct. Is it normal that the image appears upside down? If yes, can someone explain what's going on? jorge
João, Thank you for commenting on the code. sys.argv check is a wise one. Since I was the only user of this little snippet I didn't give attention of this detail, however eventually some other people will start using the code too. I thought it is more efficient to only import functions that I use from modules. This said, I don't see much speed difference on two codes. Is import statement (or Python itself) intelligent enough to import only the modules that are used inside a program or does it load all content at the original import time? Mouse-hover readings are really nice to have while analysing the data, and ability of setting its sensitivity comes handier sometimes. I wish I could find a way to put such a mechanism on my recent poster presentation. Hah, maybe I should use a flexible lcd and let viewers to interract with the poster themselves instead of viewing things on a dry big sheet of paper. Yes, the IPython call from shell still stays a mystery... Gökhan On Thu, May 14, 2009 at 12:52 PM, João Luís Silva <js...@fc...> wrote: > Gökhan SEVER wrote: > >> Hello, >> >> After solving the boxplotting mystery, and figuring out how to change the >> mouse hover reading sensitivities, I have finished my small script which >> creates boxplots from a given file. I can call it either by issueing >> ./splot.py file or from inside ipython -pylab with run command. However I >> still couldn't figure out how to drop in ipython from the bash shell call >> while all my variable context visible in the ipython namespace. >> >> I am attaching the script and a sample file I used. Could you please >> comment whether I am on the right track? I am not very sure my locals() use >> is correct to create a variable name from a given file name. There might be >> other points that seem weaker in the code as well. >> >> Thank you. >> >> Gökhan >> >> >> > The code looks pretty good to me. I've done some minor style changes on the > imports, and added an error check to see if the user passed a parameter or > not. I didn't know how to change the mouseover format, this will be useful > for me, thanks! > > I'm only a casual user of ipython, and I don't know how to do what you ask, > so I'll leave that to someone else. > > (new splot.py attached) > > Best regards, > João Silva >
Ok, but can anyone please help me with how to find nlons and nlats dynamically.I need to do this becuase I have no idea on how many records the datasets contains. i tried user Timmes idea (but it aint working,not even starting): from matplotlib.mlab import load import matplotlib.pyplot as plt import numpy as np data = np.loadtxt("C:/Users/Linda/data.txt") y=data[:,0] x=data[:,1] z=data[:,2] ### data is loaded from a CSV file ### lats = y # data[:,0] ## lon => x lons = x # data[:,1] ## values => z values = z # ### lat_uniq = list(set(lats.tolist())) nlats = len(lat_uniq) lon_uniq = list(set(lons.tolist())) nlons = len(lon_uniq) color_map = plt.cm.spectral print lats.shape, nlats, nlons yre = lats.reshape(nlats,nlons) xre = lons.reshape(nlats,nlons) zre = values.reshape(nlats,nlons) #### later in the defined map CT = plt.contourf(xre, yre, zre, cmap=color_map) cbar = plt.colorbar() plt.show() I have also tried to use griddata but no luck xi = np.linspace(-100,100,100) yi = np.linspace(-100,100,100) # grid the data. zi = griddata(x,y,z,xi,yi) here is the datafile 40 7 10.65251434 41 7.20 16.841345477 42 7.5 10.923153289 46 7.75 13.644313708 45 8 3.550977951 45 8.25 3.352525137 45 8.5 3.080082094 45 8.75 2.971992657 45 9 2.998723785 45 9.25 3.080082094 45 9.5 3.185687405 45 9.75 3.102075854 45 10 3.185687405 45 10.25 3.213960325 45 10.5 3.32326373 45 10.75 3.465643983 45 11 3.612980369 45 11.25 3.644313708 45 11.5 30.701277511 45 11.75 30.923153289 45 12 3.797848342 45 12.25 3.612980369 45 12.5 3.435577844 45 12.75 3.294210812 45 13 3.26536503 45.25 7 16.485050223 45.25 7.25 16.343081631 45.25 7.5 13.856783573 45.25 7.75 13.405725407 45.25 8 13.550977951 45.25 8.25 13.294210812 45.25 8.5 3.294210812 45.25 8.75 3.185687405 45.25 9 3.15761656 45.25 9.25 3.213960325 45.25 9.5 3.15761656 45.25 9.75 3.32326373 45.25 10 3.405725407 45.25 10.25 3.495925216 45.25 10.5 3.465643983 45.25 10.75 3.550977951 45.25 11 3.465643983 45.25 11.25 3.765429652 45.25 11.5 3.95669157 45.25 11.75 3.797848342 45.25 12 3.923153289 45.25 12.25 3.733239867 45.25 12.5 3.550977951 45.25 12.75 3.520306012 45.25 13 3.376085288 45.5 7 6.383367092 45.5 7.25 6.383367092 45.5 7.5 6.009422688 45.5 7.75 4.679469855 45.5 8 3.435577844 45.5 8.25 3.435577844 45.5 8.5 3.236725042 45.5 8.75 3.236725042 45.5 9 3.185687405 45.5 9.25 3.102075854 45.5 9.5 3.102075854 45.5 9.75 3.185687405 45.5 10 3.352525137 45.5 10.25 3.405725407 45.5 10.5 3.376085288 45.5 10.75 3.612980369 45.5 11 3.520306012 45.5 11.25 3.352525137 45.5 11.5 3.823949103 45.5 11.75 3.856783573 45.5 12 3.856783573 45.5 12.25 3.765429652 45.5 12.5 3.669541114 45.5 12.75 3.550977951 45.5 13 3.435577844 45.75 7 5.309043916 45.75 7.25 6.057519881 45.75 7.5 5.030958443 45.75 7.75 4.836570243 45.75 8 4.836570243 45.75 8.25 2.724965001 45.75 8.5 2.607751091 45.75 8.75 3.26536503 45.75 9 2.898163214 45.75 9.25 2.872155245 45.75 9.5 1.893252754 45.75 9.75 2.043669061 45.75 10 1.75488883 45.75 10.25 2.004264146 45.75 10.5 2.971992657 45.75 10.75 1.804949998 45.75 11 2.846334614 45.75 11.25 5.519419657 45.75 11.5 2.517818813 45.75 11.75 3.733239867 45.75 12 3.376085288 45.75 12.25 3.550977951 45.75 12.5 14.612980369 45.75 12.75 10.520306012 45.75 13 31.495925216 46 7 5.06399168 46 7.25 4.949174095 46 7.5 5.266087828 46 7.75 5.352298328 46 8 4.757472437 46 8.25 2.800325674 46 8.5 3.612980369 46 8.75 3.185687405 46 9 2.323282473 46 9.25 1.671485743 46 9.5 3.856783573 46 9.75 4.572079662 46 10 4.679469855 46 10.25 4.679469855 46 10.5 5.309043916 46 10.75 3.294210812 46 11 3.405725407 46 11.25 3.669541114 46 11.5 3.495925216 46 11.75 4.255093726 46 12 3.495925216 46 12.25 3.185687405 46 12.5 3.213960325 46 12.75 3.550977951 46 13 3.520306012 46.25 7 1.969297411 46.25 7.25 14.908706364 46.25 7.5 3.052767233 46.25 7.75 3.765429652 46.25 8 3.95669157 46.25 8.25 5.06399168 46.25 8.5 5.266087828 46.25 8.75 3.669541114 46.25 9 3.185687405 46.25 9.25 3.797848342 46.25 9.5 13.352525137 46.25 9.75 15.439709782 46.25 10 25.69098301 46.25 10.25 4.949174095 46.25 10.5 5.736883145 46.25 10.75 5.105542055 46.25 11 4.255093726 46.25 11.25 3.701277511 46.25 11.5 4.255093726 46.25 11.75 4.572079662 46.25 12 3.98369323 46.25 12.25 4.148941623 46.25 12.5 3.129746478 46.25 12.75 3.236725042 46.25 13 3.550977951 46.5 7 2.872155245 46.5 7.25 3.701277511 46.5 7.5 3.15761656 46.5 7.75 3.765429652 46.5 8 5.18951259 46.5 8.25 6.105948261 46.5 8.5 5.266087828 46.5 8.75 5.69098301 46.5 9 16.009422688 46.5 9.25 5.147381739 46.5 9.5 5.829636932 46.5 9.75 5.654489904 46.5 10 6.243327668 46.5 10.25 5.395852976 46.5 10.5 5.736883145 46.5 10.75 6.057519881 46.5 11 5.147381739 46.5 11.25 3.520306012 46.5 11.5 3.856783573 46.5 11.75 4.148941623 46.5 12 4.71833512 46.5 12.25 4.71833512 46.5 12.5 3.701277511 46.5 12.75 3.889851131 46.5 13 3.32326373 46.75 7 1.859766825 46.75 7.25 2.198852355 46.75 7.5 2.345277833 46.75 7.75 2.517818813 46.75 8 3.856783573 46.75 8.25 3.856783573 46.75 8.5 5.06399168 46.75 8.75 4.184077131 46.75 9 5.829636932 46.75 9.25 3.644313708 46.75 9.5 3.765429652 46.75 9.75 5.309043916 46.75 10 6.009422688 46.75 10.25 5.147381739 46.75 10.5 5.609155594 46.75 10.75 5.783100444 46.75 11 5.147381739 46.75 11.25 3.581868928 46.75 11.5 4.908706364 46.75 11.75 3.465643983 46.75 12 3.465643983 46.75 12.25 4.148941623 46.75 12.5 3.98369323 46.75 12.75 3.581868928 46.75 13 3.644313708 -- View this message in context: http://www.nabble.com/Colormap-using-%28UV%29coordinates-from-file-tp23572972p23576916.html Sent from the matplotlib - users mailing list archive at Nabble.com.
This one is from Jeff here at the forum and it does work. But the smoothing of the color values inbetween the countour is not so good. How to improve that ? Also,i am still searching for a load .csv example to use with pcolor or countour. from matplotlib.mlab import load import matplotlib.pyplot as plt import numpy as np data = load("C:/Users/Pontus/data.txt") # need to know nlons and nlats beforehand! nlons = 8; nlats = 25 X = data[0::nlats,0] Y = data[0:nlats,1] # data is in nlons,nlats order in file, need to transpose Z = data[:,2].reshape(nlons,nlats).transpose() X,Y = np.meshgrid(X,Y) CS = plt.contourf(X,Y,Z,20) plt.show() -- View this message in context: http://www.nabble.com/Colormap-using-%28UV%29coordinates-from-file-tp23572972p23573711.html Sent from the matplotlib - users mailing list archive at Nabble.com.
On Sat, May 16, 2009 at 6:57 AM, amrbekhit <amr...@gm...> wrote: > > Hello, > > I am trying to write an application that measures data from an external > device and then displays the data on a graph, updating the graph when new > measurements arrive. Searching the web has led to matplotlib and so I've > been having a go at using that for my program. After searching around on the > forums, I have had some success in implementing the functionality I am > aiming for, but the application gets very very slow the longer it runs. By default matplotlib overplots, meaning it keeps the old data around in addition to the new data, so you are plotting on the i-th iteration 0: [d0] 1: [d0], [d0, d1][d0], [d0, d1] 2: [d0], [d0, d1], [d0, d1, d2], .... You probably don't see it because the new points overlap the old. If you turn overplotting off ax.hold(False) before issuing the plot commands you should not see the dramatic slowing. You can speed up the performance further by reusing the same line object, eg somelimit = 1000 line, = ax.plot([], []) xs = [] ys = [] for row in mydata: xs.append(row['newx']) ys.append(row['newy']) if len(xs)>somelimit: del xs[0] del ys[0] line.set_data(xs, ys) ax.figure.canvas.draw() See also the animation tutorial and examples http://www.scipy.org/Cookbook/Matplotlib/Animations http://matplotlib.sourceforge.net/examples/animation/index.html JDH
On Fri, May 15, 2009 at 4:23 PM, Christopher Barker <Chr...@no...> wrote: > Sandro Tosi wrote: >>> >>> mpl.ticker.AutoDateLocator >>> mpl.ticker.AutoDateFormatter >>> >>> Where might I find these now? They don't seem to be in matplotlib.ticker >>> or matplotlib.date. do they have a new name? Is there a new way to get >>> automatic date tic location and formating? > >> dates.AutoDateFormatter dates.AutoDateLocator > > thanks -- I did just find it myself, by looking at the code in > axes.plot_dates -- however, the plot_dates docstring is wrong, and they > don't seem to be here: I updated the plot_dates docstring in svn to point to matplotlib.dates > http://matplotlib.sourceforge.net/api/dates_api.html > > They are there in the diagram on top, but don't seem to be on the page. That is odd -- any sphinx gurus have any idea why these are not being picked up by the automodule code? >>> note: I'm trying to do this for the x axis of a quiver plot, which >>> doesn't seem to support passing in dates directly. > > by the way, is that a bug that should be tracked down and fixed? Not all of the methods currently support direct date/unit plotting, but we do try to extend support when we have reported failures, so if you post a script which exposes the problem I'll try and fix it. > However, in this case, I'm trying to write method that takes an axes object, > and plots to that -- how can I do this without the figure reference? Most mpl objects have a reference to their parent, so you can walk up the containment hierarchy, eg line.axes.figure.canvas so in your case ax.figure.autofmt_xdate() but note that autofmt_xdate is designed to work for subplots with only one column, not in the case of general axes configurations, so calling this from an axes in a method that does not know how the axes are layed out does not make sense. But you can do the main part yourself for label in ax.get_xticklabels(): label.set_rotation(30) label.set_horizontalalignment('right') > But it does work well if you apply it to the figure after my plotting > routines. That is the best place to apply it, because there you know the subplot layout is suitable for the call. JDH
Hello, I am trying to write an application that measures data from an external device and then displays the data on a graph, updating the graph when new measurements arrive. Searching the web has led to matplotlib and so I've been having a go at using that for my program. After searching around on the forums, I have had some success in implementing the functionality I am aiming for, but the application gets very very slow the longer it runs. I have attached the test program I wrote at the bottom of this post. The application uses Tkinter for the GUI. Whenever you type something into the text box at the top, the ascii code of the last character in the text is added to the data list and plotted. The more things you type, the application gets slower and slower. I initially thought that the slow down might be due to the data list getting bigger and bigger, but I no longer think that this is the case. If you comment out line 31 (self.data.append(ord(self.text.get()[-1]))) and replace it with something like self.data = [1, 2, 3], the application still exhibits the same slow down with time. Is there a 'proper' way of doing this? Thanks, --Amr PS remove the comment at the bottom of the file (root.mainloop()) http://www.nabble.com/file/p23573077/pylog.py pylog.py -- View this message in context: http://www.nabble.com/Updating-a-plot-as-data-is-acquired-tp23573077p23573077.html Sent from the matplotlib - users mailing list archive at Nabble.com.
Hi all, I have been using matplotlib for about 5 hours :-/ so please forgive me if the question has been asked several times (and i have been trying to find it in the forum) But i downloaded phyton(xy) and from there i found the poormans_countour and some pcolor scripts. I think this is what i need but how do i load a textfile (.csv or -txt with columns etc) that contains UV-coordinates (ordinary xy) with a assigned value and put them into the Z variables in the .py scripts ?? i.e from numpy import * from pylab import load from pylab import save read_data = load("myfile.txt") // here how to assign Z to read_data cmap = cm.get_cmap('jet', 35) # 35 discrete colors im = imshow(Z, cmap=cmap, interpolation='bilinear') axis('off') colorbar() show() The same goes for the pcolor plot, how can i replace the func3 so it contais an array of my values from the loaded file ? def func3(x,y): return (1- x/2 + x**5 + y**3)*exp(-x**2-y**2) # make these smaller to increase the resolution dx, dy = 0.05, 0.05 x = arange(-3.0, 3.0, dx) y = arange(-3.0, 3.0, dy) X,Y = meshgrid(x, y) Z = func3(X, Y) ax = subplot(111) im = imshow(Z, cmap=cm.jet) #im.set_interpolation('nearest') #im.set_interpolation('bicubic') im.set_interpolation('bilinear') Thanks in advance :handshake: /Linda -- View this message in context: http://www.nabble.com/Colormap-using-%28UV%29coordinates-from-file-tp23572972p23572972.html Sent from the matplotlib - users mailing list archive at Nabble.com.
Christopher Barker wrote: > Christopher Barker wrote: >> Hi all, >> >> I've been messing with quiver a bit, and have some confusions: > > one more issue with quiver -- autoscaling fails if there is a NaN in the > data: > I just committed a change to ensure that nans and infs are treated as masked points. If you still see the problem (and I suspect you will), then it is inherent in the autoscaling. Eric > > > x = (1,2) > y = (1,2) > u = (2,2) > v = (-2,2) > > > fig = plt.figure(1) > fig.clear() > > ax = fig.add_subplot(2,2,3) > > # fails for a nan data point if auto-scaling > u = (2, np.nan) > props = {'units' : "dots", > 'scale' : .1, > 'width' : 2, > 'headwidth': 2, > 'headlength': 3, > 'headaxislength': 4, > } > > ax.quiver( x, y, u, v, **props ) > > > > > -Chris > >
On Fri, May 15, 2009 at 4:24 PM, Jae-Joon Lee <lee...@gm...> wrote: > It may be doable, depending on what you exactly want. > For example > > http://dl.getdropbox.com/u/178748/AxesGrid/htdocs/users/overview.html#rgb-axes > > But my emphasis was on displaying images, and may not be suitable for > general axes. FYI, several weeks ago I updated the official site-docs after you contributes the axes grid toolkit and docs: http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/overview.html#rgb-axes Which only increases the pressure on us to get the 98 bug fix release out and then the next trunk release out so that the code keeps up with the docs... JDH
On Fri, May 15, 2009 at 5:16 PM, Jae-Joon Lee <lee...@gm...> wrote: > Attached is a patch that I want to commit to the trunk. > It introduces new attribute "_check_contains" (any name suggestion?) I'm not keen on the name either -- something more explicit would be better. Maybe, set_annotation_clip or something like that, which is more descriptive to me. > for Annotation class. > > * True : the annotation will only be drawn when self.xy is > inside the axes. > * False : the annotation will always be drawn regardless of > its position. > * None : the self.xy will be checked only if *xycoords* is "data" > > The default value is None, i.e., position is only checked if the > xycoords is "data". > > I'll commit this soon if others don't object. You don't need permission :-) but I took a look at the patch. Inline comments below + def get_check_contains(self): + " retrun *check_contains* attribute. " + return self._check_contains + retrun is misspelled + + def update_positions(self, renderer): + xy_pixel = self._get_position_xy(renderer) + self._update_position_xytext(renderer, xy_pixel) + + + def _get_position_xy(self, renderer): + x, y = self.xy + return self._get_xy(x, y, self.xycoords) + When you are extending/fixing existing code and come across methods with no docs, could you write a one or two line doc string for them? I wrote many of these and at the time they were so obvious that they didn't need docstrings, but as time passes and I reencounter them, I wish there was a simple line explaining them. As you are digging through the code figuring them all out, it is a great time to drop in a simple one-liner docstring (eg explaining what coord system is being returned by _get_position_xy). As the famous coding quip says, the literal wording or author of which I cannot dig up right now, "Leave comments in your code -- someone may read it someday, and that someone may be you!" + class _SimpleEvent: + def __init__(self, xy): + self.x, self.y = xy + + def _check_xy(self, renderer, xy_pixel): + "given the xy coordinate, check if the annotation need to be drawn" + + b = self.get_check_contains() + if b or (b is None and self.xycoords == "data"): + # check if self.xy is inside the axes. + if not self.axes.contains(Annotation._SimpleEvent(xy_pixel))[0]: + return False + I'm not wild about this -- I find myself doing similar hacks when writing GUIs and doing other stuff where the quick-and-dirty is easier than the right way, but for mpl, which is a library and is growing rapidly and has already reached the point where no one developer has their head around the whole thing, I think we need to be careful about these kinds of hacks that can result in subtle bugs down the road. You are relying on the event infrastructure API via the Axes.contain method, but are hacking around it by just providing the minimal set of things that are needed for the contains call with the _SimpleEvent. The problem is, if the event API or the contains method changes later, this is a latent bug which is difficult to unit test since it is primarily exposed interactively. Axes.contains expects a MouseEvent according to the signature -- I haven't dug to deeply here but with a little more work can we provide what it is expecting rather than the stripped down proxy class (and does "contains" really need a MouseEvent or would a LocationEvent would suffice -- this may be simply a matter of renaming the arg to contains....). Or perhaps the Axes.contains method itself is misguided, requiring a full-fledged event when an x/y location would suffice. If it is fairly easy, I would like to fix this here and now rather than hack around a bad design decision. Thanks for the patch! JDH
Christopher Barker wrote: > Hi all, > > I've been messing with quiver a bit, and have some confusions: No, you hit a bug. Thanks for the report and test script. It is fixed in r7103. If you are not running from svn, a workaround may be to specify the angles as an ndarray or masked array with the shape set to (N,1) where N is the number of arrows. I haven't tested it, but based on the changes I made, I think this will work with the version you have. Eric > > according to the docs: > > """ > units: [‘width’ | ‘height’ | ‘dots’ | ‘inches’ | ‘x’ | ‘y’ ] > > arrow units; the arrow dimensions except for length are in > multiples of this unit. > """ > > and yes, when I change units from 'dots' for 'inched', the length of the > arrows do indeed change. > > > """ > angles: [‘uv’ | ‘xy’ | array] > ... Alternatively, arbitrary angles may be specified as an array of > values in degrees, CCW from the x-axis. > """ > > This crashes for me with: > > Traceback (most recent call last): > File "quiver_test.py", line 72, in <module> > plt.draw() > File > "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/pyplot.py", > line 341, in draw > get_current_fig_manager().canvas.draw() > File > "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/backends/backend_tkagg.py", > line 215, in draw > FigureCanvasAgg.draw(self) > File > "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/backends/backend_agg.py", > line 279, in draw > self.figure.draw(self.renderer) > File > "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/figure.py", > line 772, in draw > for a in self.axes: a.draw(renderer) > File > "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/axes.py", > line 1601, in draw > a.draw(renderer) > File > "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/quiver.py", > line 425, in draw > verts = self._make_verts(self.U, self.V) > File > "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/quiver.py", > line 484, in _make_verts > theta = ma.asarray(self.angles*np.pi/180.0).filled(0) > TypeError: can't multiply sequence by non-int of type 'float' > > I've enclosed a small test script... > > Thanks, > > -Chris > > > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > Crystal Reports - New Free Runtime and 30 Day Trial > Check out the new simplified licensing option that enables > unlimited royalty-free distribution of the report engine > for externally facing server and web deployment. > http://p.sf.net/sfu/businessobjects > > > ------------------------------------------------------------------------ > > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Christopher Barker wrote: > Hi all, > > I've been messing with quiver a bit, and have some confusions: one more issue with quiver -- autoscaling fails if there is a NaN in the data: x = (1,2) y = (1,2) u = (2,2) v = (-2,2) fig = plt.figure(1) fig.clear() ax = fig.add_subplot(2,2,3) # fails for a nan data point if auto-scaling u = (2, np.nan) props = {'units' : "dots", 'scale' : .1, 'width' : 2, 'headwidth': 2, 'headlength': 3, 'headaxislength': 4, } ax.quiver( x, y, u, v, **props ) -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...