You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(33) |
Dec
(20) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(7) |
Feb
(44) |
Mar
(51) |
Apr
(43) |
May
(43) |
Jun
(36) |
Jul
(61) |
Aug
(44) |
Sep
(25) |
Oct
(82) |
Nov
(97) |
Dec
(47) |
2005 |
Jan
(77) |
Feb
(143) |
Mar
(42) |
Apr
(31) |
May
(93) |
Jun
(93) |
Jul
(35) |
Aug
(78) |
Sep
(56) |
Oct
(44) |
Nov
(72) |
Dec
(75) |
2006 |
Jan
(116) |
Feb
(99) |
Mar
(181) |
Apr
(171) |
May
(112) |
Jun
(86) |
Jul
(91) |
Aug
(111) |
Sep
(77) |
Oct
(72) |
Nov
(57) |
Dec
(51) |
2007 |
Jan
(64) |
Feb
(116) |
Mar
(70) |
Apr
(74) |
May
(53) |
Jun
(40) |
Jul
(519) |
Aug
(151) |
Sep
(132) |
Oct
(74) |
Nov
(282) |
Dec
(190) |
2008 |
Jan
(141) |
Feb
(67) |
Mar
(69) |
Apr
(96) |
May
(227) |
Jun
(404) |
Jul
(399) |
Aug
(96) |
Sep
(120) |
Oct
(205) |
Nov
(126) |
Dec
(261) |
2009 |
Jan
(136) |
Feb
(136) |
Mar
(119) |
Apr
(124) |
May
(155) |
Jun
(98) |
Jul
(136) |
Aug
(292) |
Sep
(174) |
Oct
(126) |
Nov
(126) |
Dec
(79) |
2010 |
Jan
(109) |
Feb
(83) |
Mar
(139) |
Apr
(91) |
May
(79) |
Jun
(164) |
Jul
(184) |
Aug
(146) |
Sep
(163) |
Oct
(128) |
Nov
(70) |
Dec
(73) |
2011 |
Jan
(235) |
Feb
(165) |
Mar
(147) |
Apr
(86) |
May
(74) |
Jun
(118) |
Jul
(65) |
Aug
(75) |
Sep
(162) |
Oct
(94) |
Nov
(48) |
Dec
(44) |
2012 |
Jan
(49) |
Feb
(40) |
Mar
(88) |
Apr
(35) |
May
(52) |
Jun
(69) |
Jul
(90) |
Aug
(123) |
Sep
(112) |
Oct
(120) |
Nov
(105) |
Dec
(116) |
2013 |
Jan
(76) |
Feb
(26) |
Mar
(78) |
Apr
(43) |
May
(61) |
Jun
(53) |
Jul
(147) |
Aug
(85) |
Sep
(83) |
Oct
(122) |
Nov
(18) |
Dec
(27) |
2014 |
Jan
(58) |
Feb
(25) |
Mar
(49) |
Apr
(17) |
May
(29) |
Jun
(39) |
Jul
(53) |
Aug
(52) |
Sep
(35) |
Oct
(47) |
Nov
(110) |
Dec
(27) |
2015 |
Jan
(50) |
Feb
(93) |
Mar
(96) |
Apr
(30) |
May
(55) |
Jun
(83) |
Jul
(44) |
Aug
(8) |
Sep
(5) |
Oct
|
Nov
(1) |
Dec
(1) |
2016 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
(3) |
Sep
(1) |
Oct
(3) |
Nov
|
Dec
|
2017 |
Jan
|
Feb
(5) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(3) |
Aug
|
Sep
(7) |
Oct
|
Nov
|
Dec
|
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
|
1
(3) |
2
(2) |
3
(4) |
4
(4) |
5
|
6
|
7
|
8
(2) |
9
(4) |
10
(3) |
11
|
12
(2) |
13
|
14
|
15
(1) |
16
(4) |
17
|
18
(4) |
19
(5) |
20
(8) |
21
(4) |
22
(3) |
23
(1) |
24
(3) |
25
|
26
(1) |
27
(3) |
28
(1) |
29
(1) |
30
(9) |
|
|
|
>>>>> "Alex" == Alex Gontmakher <gs...@cs...> writes: Alex> Currently implemented for PostScript backend only - the rest Alex> ignore the command. I tried to make it in the same style as Alex> the rest of Matplotlib iface: 'x' does bidiagonal hatching Alex> '/' does diagonal, '-' does horizontal, and so on. Alex> Repeating the hatching symbol increases the density of Alex> hatching. Alex> Attached is the diff for version 0.85. Is there a chance Alex> for this thing to be included into the source? Thanks Alex -- I'm happy to include this but am having trouble applying your patch. Could you get a fresh CVS checkout, reapply your changes, and do a 'cvs diff'? Thanks, JDH Alex> Only in matplotlib-0.85.new: build diff -r Alex> matplotlib-0.85/lib/matplotlib/backend_bases.py Alex> matplotlib-0.85.new/lib/matplotlib/backend_bases.py 389a390 >> self._hatch = None Alex> 401a403 >> self._hatch = gc._hatch Alex> 549c551,558 < --- >> def set_hatch(self, hatch): """ Sets the hatch style for >> filling """ self._hatch = hatch def get_hatch(self): return >> self._hatch Alex> Only in matplotlib-0.85.new/lib/matplotlib: Alex> backend_bases.py~ diff -r Alex> matplotlib-0.85/lib/matplotlib/backends/backend_ps.py Alex> matplotlib-0.85.new/lib/matplotlib/backends/backend_ps.py Alex> 148a149,150 >> self.hatch = None self.hatch_func = False Alex> 195a198,260 >> def set_hatch(self, hatch): """ hatch can be one of: / - >> diagonal hatching \ - back diagonal | - vertical - - horizontal >> # - crossed X - crossed diagonal letters can be combined, in >> which case all the specified hatchings are done if same letter >> repeats, it increases the density of hatching in that direction >> """ hatches = {'horiz':0, 'vert':0, 'diag1':0, 'diag2':0} >> >> for letter in hatch: if (letter == '/'): hatches['diag2'] += 1 >> elif (letter == '\\'): hatches['diag1'] += 1 elif (letter == >> '|'): hatches['vert'] += 1 elif (letter == '-'): >> hatches['horiz'] += 1 elif (letter == '+'): hatches['horiz'] += >> 1 hatches['vert'] += 1 elif (letter == 'x'): hatches['diag1'] >> += 1 hatches['diag2'] += 1 >> >> def do_hatch(angle, density): if (density == 0): return "" orig >> = """ gsave eoclip %s rotate 0.0 0.0 0.0 0.0 setrgbcolor 0 >> setlinewidth /gap %d def pathbbox /b exch def /r exch def /t >> exch def /l exch def l cvi gap idiv gap mul gap r cvi gap idiv >> gap mul {t moveto 0 b t sub rlineto} for stroke grestore """ % >> (angle, 12/density) return """ gsave eoclip %s rotate 0.0 0.0 >> 0.0 0.0 setrgbcolor 0 setlinewidth /hatchgap %d def pathbbox >> /hatchb exch def /hatchr exch def /hatcht exch def /hatchl exch >> def hatchl cvi hatchgap idiv hatchgap mul hatchgap hatchr cvi >> hatchgap idiv hatchgap mul {hatcht moveto 0 hatchb hatcht sub >> rlineto} for stroke grestore """ % (angle, 12/density) >> self._pswriter.write("gsave\n") >> self._pswriter.write(do_hatch(0, hatches['horiz'])) >> self._pswriter.write(do_hatch(90, hatches['vert'])) >> self._pswriter.write(do_hatch(45, hatches['diag1'])) >> self._pswriter.write(do_hatch(-45, hatches['diag2'])) >> self._pswriter.write("grestore\n") >> Alex> 771,772c836,837 < write(ps.strip()) < write("\n") --- >> write(ps.strip()) write("\n") Alex> 778a844,847 >> hatch = gc.get_hatch() if (hatch): self.set_hatch(hatch) >> Alex> Only in matplotlib-0.85.new/lib/matplotlib/backends: Alex> backend_ps.py~ diff -r Alex> matplotlib-0.85/lib/matplotlib/patches.py Alex> matplotlib-0.85.new/lib/matplotlib/patches.py 30a31 >> hatch = None, Alex> 44a46 >> self.hatch = hatch Alex> 53a56 >> self.set_hatch(other.get_hatch()) Alex> 114a118,128 >> def set_hatch(self, h): """ Set the hatching pattern >> >> ACCEPTS: string (can be one of "|,/,,円x,+", or combinations >> thereof") """ self.hatch = h >> >> def get_hatch(self): 'return the current hatch pattern' return >> self.hatch Alex> 127a142,143 >> if self.hatch != None: gc.set_hatch(self.hatch) Alex> Only in matplotlib-0.85.new/lib/matplotlib: patches.py~ Only Alex> in matplotlib-0.85.new: setupext.pyc Only in Alex> matplotlib-0.85/src: _na_backend_agg.cpp Only in Alex> matplotlib-0.85/src: _na_backend_gdk.c Only in Alex> matplotlib-0.85/src: _na_cntr.c Only in matplotlib-0.85/src: Alex> _na_image.cpp Only in matplotlib-0.85/src: Alex> _na_transforms.cpp Only in matplotlib-0.85/src: Alex> _nc_backend_agg.cpp Only in matplotlib-0.85/src: Alex> _nc_backend_gdk.c Only in matplotlib-0.85/src: _nc_cntr.c Alex> Only in matplotlib-0.85/src: _nc_image.cpp Only in Alex> matplotlib-0.85/src: _nc_transforms.cpp
>>>>> "Rob" == Rob McMullen <rob...@gm...> writes: Rob> Oh, and I didn't say so in the patch itself, but I'm happy to Rob> donate the patch to matplotlib under the default matplotlib Rob> license. Great Rob -- thanks. This was the first I've heard of EMF but I read through your web page and it looks interesting. I don't have time right now to install the prereqs and test, but you may want to grab the latest CVS mpl and make sure everything is working for you. You may also want to write a blurb for the release notes, and add a patch against the matplotlib CVS htdocs and or users guide to explain EMF and provide pointers to your web site on the mpl site. Checking in matplotlib/backends/backend_emf.py; /cvsroot/matplotlib/matplotlib/lib/matplotlib/backends/backend_emf.py,v <-- backend_emf.py initial revision: 1.1 done Thanks again, JDH
John, > I am weakly inclined to support all three rather than one or the other > in the interim, if only because it is a nice way to profile scipy core > versus the old Numeric and because it may be easier to debug what is > going on when we hit user level snags. But since this is only an > interim solution I'm not strongly wedded to any approach. I agree. I think the testing and transition will be easier if all three are supported for now. I don't see much downside to doing this. Eric
>>>>> "John" == John Hunter <jdh...@ac...> writes: John> I just committed Daishi's patch to CVS, with Fernando's John> modification to catch the new scipy versus old scipy. Seems there is a problem with "resize" peds-pc311:~/python/projects/matplotlib/examples> python contour_demo.py --Numeric --verbose-helpful matplotlib data path /usr/share/matplotlib $HOME=/home/jdhunter CONFIGDIR=/home/jdhunter/.matplotlib loaded rc file /home/jdhunter/.matplotlib/matplotlibrc matplotlib version 0.85.1.cvs verbose.level helpful interactive is False platform is linux2 numerix Numeric 24.0b2 font search path ['/usr/share/matplotlib'] loaded ttfcache file /home/jdhunter/.matplotlib/ttffont.cache backend GTKAgg version 2.6.1 Traceback (most recent call last): File "contour_demo.py", line 29, in ? clabel(CS, inline=1, fontsize=10) File "/home/jdhunter/debs/matplotlib/usr//lib/python2.4/site-packages/matplotlib/pylab.py", line 1783, in clabel ret = gca().clabel(*args, **kwargs) File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line 1264, in clabel return CS.clabel(*args, **kwargs) File "/usr/lib/python2.4/site-packages/matplotlib/contour.py", line 121, in clabel self.labels(inline) File "/usr/lib/python2.4/site-packages/matplotlib/contour.py", line 338, in labels x,y, rotation, ind = self.locate_label(slc, lw) File "/usr/lib/python2.4/site-packages/matplotlib/contour.py", line 291, in locate_label XX = resize(array(linecontour)[:,0],(xsize, ysize)) File "/usr/lib/python2.4/site-packages/matplotlib/numerix/__init__.py", line 87, in resize return a.resize(shape) ValueError: resize only works on contiguous arrays and for numarray peds-pc311:~/python/projects/matplotlib/examples> python contour_demo.py --numarray --verbose-helpful matplotlib data path /usr/share/matplotlib $HOME=/home/jdhunter CONFIGDIR=/home/jdhunter/.matplotlib loaded rc file /home/jdhunter/.matplotlib/matplotlibrc matplotlib version 0.85.1.cvs verbose.level helpful interactive is False platform is linux2 numerix numarray 1.3.3 font search path ['/usr/share/matplotlib'] loaded ttfcache file /home/jdhunter/.matplotlib/ttffont.cache backend GTKAgg version 2.6.1 Traceback (most recent call last): File "contour_demo.py", line 29, in ? clabel(CS, inline=1, fontsize=10) File "/home/jdhunter/debs/matplotlib/usr//lib/python2.4/site-packages/matplotlib/pylab.py", line 1783, in clabel ret = gca().clabel(*args, **kwargs) File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line 1264, in clabel return CS.clabel(*args, **kwargs) File "/usr/lib/python2.4/site-packages/matplotlib/contour.py", line 121, in clabel self.labels(inline) File "/usr/lib/python2.4/site-packages/matplotlib/contour.py", line 338, in labels x,y, rotation, ind = self.locate_label(slc, lw) File "/usr/lib/python2.4/site-packages/matplotlib/contour.py", line 291, in locate_label XX = resize(array(linecontour)[:,0],(xsize, ysize)) File "/usr/lib/python2.4/site-packages/matplotlib/numerix/__init__.py", line 87, in resize return a.resize(shape) File "/home/jdhunter/debs/numarray/usr/lib/python2.4/site-packages/numarray/generic.py", line 891, in resize self.ravel() File "/home/jdhunter/debs/numarray/usr/lib/python2.4/site-packages/numarray/generic.py", line 922, in ravel self.setshape((self.nelements(),)) File "/home/jdhunter/debs/numarray/usr/lib/python2.4/site-packages/numarray/generic.py", line 680, in setshape raise TypeError("Can't reshape non-contiguous numarray") TypeError: Can't reshape non-contiguous numarray Ditto on finance_demo.... JDH
I just committed Daishi's patch to CVS, with Fernando's modification to catch the new scipy versus old scipy. Those of you with semi-pristine boxes might want to try it out to make sure it is working. One issue: the patch builds either numarray (if found) and scipy|numeric (if found but not both) with precedence given to numeric. Shouldn't it be the other way around, with precedence to scipy_core over Numeric since if someone has the new scipy presumably it's an upgrade and should take precedence. I am weakly inclined to support all three rather than one or the other in the interim, if only because it is a nice way to profile scipy core versus the old Numeric and because it may be easier to debug what is going on when we hit user level snags. But since this is only an interim solution I'm not strongly wedded to any approach. Please test and report. Checking in lib/matplotlib/numerix/__init__.py; /cvsroot/matplotlib/matplotlib/lib/matplotlib/numerix/__init__.py,v <-- __init__.py new revision: 1.6; previous revision: 1.5 or later. JDH
>>>>> "James" == James Casbon <ca...@gm...> writes: James> Hi, The logic for displaying a figure on the interactive James> backends (eg qt) seems a little strange to me. I imagine James> that normally the screen is used as a preview for a figure James> that is going to be output on paper, or to png or some James> permanent store. Therefore, the interactive output should James> resemble the permanent output as much as possible. James> Now, when using the QtAgg backend (sorry no time to play James> with other backends) setting the figure height or width has James> no effect on the size of the figure displayed with show(). James> It always comes out at 600x400. Typically you want saved images to be at a higher resolution than the one on the screen, since most screens are less than 1500x1500 and often you want a higher resolution setting. That is why the savefig command takes a dpi parameter, which default to the settin in your rc file. You could make the screen dpi and the savefig dpi the same in rc if you want. I find that when I resize a figure in the GUI window, the aspect ratio *is* preserved when I save, so the suggestion above should suffice for you. JDH
I'm having some trouble with unpickled scipy arrays. The issue shows up when I try to plot in matplotlib, but I think it is a scipy problem. import pickle import scipy import pylab a = scipy.arange(10) pickle.dump(a,file('temp.p','w')) b = pickle.load(file('temp.p')) print type(b), type(scipy.array(b)) pylab.plot(scipy.array(b)) # no error here pylab.plot(b) # error here Traceback (most recent call last): File "pickletest.py", line 8, in ? pylab.plot(b) File "/usr/lib64/python2.4/site-packages/matplotlib/pylab.py", line 2055, in plot ret = gca().plot(*args, **kwargs) File "/usr/lib64/python2.4/site-packages/matplotlib/axes.py", line 2636, in plot for line in self._get_lines(*args, **kwargs): File "/usr/lib64/python2.4/site-packages/matplotlib/axes.py", line 267, in _grab_next_args yield self._plot_1_arg(remaining[0], **kwargs) File "/usr/lib64/python2.4/site-packages/matplotlib/axes.py", line 189, in _plot_1_arg markerfacecolor=color, File "/usr/lib64/python2.4/site-packages/matplotlib/lines.py", line 209, in __init__ self.set_data(xdata, ydata) File "/usr/lib64/python2.4/site-packages/matplotlib/lines.py", line 265, in set_data y = ma.ravel(y) File "/usr/lib64/python2.4/site-packages/Numeric/MA/MA.py", line 1810, in ravel d = Numeric.ravel(filled(a)) File "/usr/lib64/python2.4/site-packages/Numeric/MA/MA.py", line 222, in filled return Numeric.array(a) ValueError: cannot handle misaligned or not writeable arrays. Darren
Eric Firing wrote: > John, > > I have committed to CVS a set of changes that I think will address > recent requests by Jordan and Gerald, and will be of more general use > as well. From the CHANGELOG: > > 2005年11月27日 Multiple changes in cm.py, colors.py, figure.py, image.py, > contour.py, contour_demo.py; new _cm.py, > examples/image_masked.py. > 1) Separated the color table data from cm.py out into > a new file, _cm.py, to make it easier to find the actual > code in cm.py and to add new colormaps. Also added > some line breaks to the color data dictionaries. Everything > from _cm.py is imported by cm.py, so the split should be > transparent. > 2) Enabled automatic generation of a colormap from > a list of colors in contour; see modified > examples/contour_demo.py. > 3) Support for imshow of a masked array, with the > ability to specify colors (or no color at all) for > masked regions, and for regions that are above or > below the normally mapped region. See > examples/image_masked.py. > 4) In support of the above, added two new classes, > ListedColormap, and no_norm, to colors.py, and modified > the Colormap class to include common functionality. Added > a clip kwarg to the normalize class. Reworked color > handling in contour.py, especially in the ContourLabeller > mixin. > > With one very subtle exception, I don't think any default behaviors > have been changed, so the changes should be entirely non-disruptive. > > That one exception is that in the original color mapping scheme, the > last color was essentially never used. Consider an extreme case: a > colormap with two entries. Suppose the image data ranged from 0 to 1. > All values except exactly 1.0 were mapped to the first color, and only > that upper limit value was mapped to the second color. As I have > changed colors.py, values from 0.0 up to 0.5 will get the first color, > and values from 0.5 through 1.0 will get the second. I think this is > what a user would expect, and the only reason it hasn't mattered is > that with 256 colors in a continuous range, one can't see the difference. > > The request from Jordan that is addressed here is the desire for > precise color control in filled contouring. Now one can specify a > list of colors in the "colors" kwarg, and they will be used to > generate a colormap, which will then be used by colorbar. This is > shown in a second plot added to examples/contourf_demo.py. (Jordan > suggested a more extensive refactoring, which may indeed be a good > idea; but I wanted to make these simpler changes before trying to > think about anything more drastic.) > > The request from Gerald was for easy handling of masked arrays in > imshow. It was in the context of basemap, which I have not tested > yet; but at least for pylab.imshow, the situation is now easy to > handle. If changes to basemap are needed, they should be very simple, > and I can do them later as needed. I think that the changes to > colormapping that I made to support this will be useful much more > widely, but I have made no attempt to track down the places where > changes will be in order. I may make additional changes to contour, > and I know I will need to change colorbar to fully support this. I > think colorbar needs some more refactoring anyway, but I can't do it > immediately, and I did not want to delay getting the other changes out > for testing and, hopefully, productive use. > > Eric Eric: Tried the masked imshow with basemap and it seems to work fine (without any modifications to basemap). I've added a new example, plotmap_masked.py, that shows how to use mask out the oceans on a map using imshow and pcolor. Thanks again! -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/PSD R/PSD1 Email : Jef...@no... 325 Broadway Office : Skaggs Research Cntr 1D-124 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
Using the 0.85 package for ubuntu, I get the following error when I run my application: ? from matplotlib.dates import date2num, num2date, DateFormatter, IndexDateFormatter File "/home/jdhunter/debs/matplotlib/usr/lib/python2.4/site-packages/matplotlib/d ates.py", line 88, in ? ImportError: No module named pytz Any ideas? Thanks, VJ
Eric, I played with the changes you've made and the results look great! Thanks, Gerald Eric Firing wrote: > John, > > I have committed to CVS a set of changes that I think will address > recent requests by Jordan and Gerald, and will be of more general use as > well. From the CHANGELOG: > > 2005年11月27日 Multiple changes in cm.py, colors.py, figure.py, image.py, > contour.py, contour_demo.py; new _cm.py, > examples/image_masked.py. > 1) Separated the color table data from cm.py out into > a new file, _cm.py, to make it easier to find the actual > code in cm.py and to add new colormaps. Also added > some line breaks to the color data dictionaries. Everything > from _cm.py is imported by cm.py, so the split should be > transparent. > 2) Enabled automatic generation of a colormap from > a list of colors in contour; see modified > examples/contour_demo.py. > 3) Support for imshow of a masked array, with the > ability to specify colors (or no color at all) for > masked regions, and for regions that are above or > below the normally mapped region. See > examples/image_masked.py. > 4) In support of the above, added two new classes, > ListedColormap, and no_norm, to colors.py, and modified > the Colormap class to include common functionality. Added > a clip kwarg to the normalize class. Reworked color > handling in contour.py, especially in the ContourLabeller > mixin. > > With one very subtle exception, I don't think any default behaviors have > been changed, so the changes should be entirely non-disruptive. > > That one exception is that in the original color mapping scheme, the > last color was essentially never used. Consider an extreme case: a > colormap with two entries. Suppose the image data ranged from 0 to 1. > All values except exactly 1.0 were mapped to the first color, and only > that upper limit value was mapped to the second color. As I have > changed colors.py, values from 0.0 up to 0.5 will get the first color, > and values from 0.5 through 1.0 will get the second. I think this is > what a user would expect, and the only reason it hasn't mattered is that > with 256 colors in a continuous range, one can't see the difference. > > The request from Jordan that is addressed here is the desire for precise > color control in filled contouring. Now one can specify a list of > colors in the "colors" kwarg, and they will be used to generate a > colormap, which will then be used by colorbar. This is shown in a > second plot added to examples/contourf_demo.py. (Jordan suggested a > more extensive refactoring, which may indeed be a good idea; but I > wanted to make these simpler changes before trying to think about > anything more drastic.) > > The request from Gerald was for easy handling of masked arrays in > imshow. It was in the context of basemap, which I have not tested yet; > but at least for pylab.imshow, the situation is now easy to handle. If > changes to basemap are needed, they should be very simple, and I can do > them later as needed. I think that the changes to colormapping that I > made to support this will be useful much more widely, but I have made no > attempt to track down the places where changes will be in order. I may > make additional changes to contour, and I know I will need to change > colorbar to fully support this. I think colorbar needs some more > refactoring anyway, but I can't do it immediately, and I did not want to > delay getting the other changes out for testing and, hopefully, > productive use. > > Eric > > >
I finally tracked down another flipy type bug. The TkAgg blitting should be rock solid now. Thanks, Charlie On 11/22/05, Charlie Moad <cw...@gm...> wrote: > Arg! One petty thing after another. Here is a simple script > demonstrating that the last row does not render the SpanSelector, yet > the callback works fine??? > > ------------------------------------ > import matplotlib > from matplotlib.widgets import SpanSelector > matplotlib.use('TkAgg') > from pylab import * > > s =3D 3 > axs =3D [subplot(s,s,i) for i in xrange(1,s**2+1)] > def onselect(x, y): print x, y > [SpanSelector(a, onselect, 'vertical', useblit=3DTrue) for a in axs] > show() > ------------------------------------ > > Any clues as to where to look for this bug? Sorry to be a hassle, but > I need this specifically to embed in a Tk only app. > > Thanks, > Charlie > > On 11/19/05, John Hunter <jdh...@ac...> wrote: > > >>>>> "Charlie" =3D=3D Charlie Moad <cw...@gm...> writes: > > > > Charlie> Awesome, thanks! Out of curiousity... did you figure > > Charlie> this out visually or by comparing with something? > > > > Let's just say I've encountered the flipy bug before :-) > > > > JDH > > >
Eric Firing wrote: > John, > > I have committed to CVS a set of changes that I think will address > recent requests by Jordan and Gerald, and will be of more general use > as well. From the CHANGELOG: > > 2005年11月27日 Multiple changes in cm.py, colors.py, figure.py, image.py, > contour.py, contour_demo.py; new _cm.py, > examples/image_masked.py. > 1) Separated the color table data from cm.py out into > a new file, _cm.py, to make it easier to find the actual > code in cm.py and to add new colormaps. Also added > some line breaks to the color data dictionaries. Everything > from _cm.py is imported by cm.py, so the split should be > transparent. > 2) Enabled automatic generation of a colormap from > a list of colors in contour; see modified > examples/contour_demo.py. > 3) Support for imshow of a masked array, with the > ability to specify colors (or no color at all) for > masked regions, and for regions that are above or > below the normally mapped region. See > examples/image_masked.py. > 4) In support of the above, added two new classes, > ListedColormap, and no_norm, to colors.py, and modified > the Colormap class to include common functionality. Added > a clip kwarg to the normalize class. Reworked color > handling in contour.py, especially in the ContourLabeller > mixin. > > With one very subtle exception, I don't think any default behaviors > have been changed, so the changes should be entirely non-disruptive. > > That one exception is that in the original color mapping scheme, the > last color was essentially never used. Consider an extreme case: a > colormap with two entries. Suppose the image data ranged from 0 to 1. > All values except exactly 1.0 were mapped to the first color, and only > that upper limit value was mapped to the second color. As I have > changed colors.py, values from 0.0 up to 0.5 will get the first color, > and values from 0.5 through 1.0 will get the second. I think this is > what a user would expect, and the only reason it hasn't mattered is > that with 256 colors in a continuous range, one can't see the difference. > > The request from Jordan that is addressed here is the desire for > precise color control in filled contouring. Now one can specify a > list of colors in the "colors" kwarg, and they will be used to > generate a colormap, which will then be used by colorbar. This is > shown in a second plot added to examples/contourf_demo.py. (Jordan > suggested a more extensive refactoring, which may indeed be a good > idea; but I wanted to make these simpler changes before trying to > think about anything more drastic.) > > The request from Gerald was for easy handling of masked arrays in > imshow. It was in the context of basemap, which I have not tested > yet; but at least for pylab.imshow, the situation is now easy to > handle. If changes to basemap are needed, they should be very simple, > and I can do them later as needed. I think that the changes to > colormapping that I made to support this will be useful much more > widely, but I have made no attempt to track down the places where > changes will be in order. I may make additional changes to contour, > and I know I will need to change colorbar to fully support this. I > think colorbar needs some more refactoring anyway, but I can't do it > immediately, and I did not want to delay getting the other changes out > for testing and, hopefully, productive use. > > Eric > Eric: This is fantastic - thanks! I'll try imshow with masked arrays and let you know if there are any problems. Should be very useful for projections which have some parts hidden, such as orthographic. -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/PSD R/PSD1 Email : Jef...@no... 325 Broadway Office : Skaggs Research Cntr 1D-124 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
John, I think that the following change, from API_CHANGES, is causing trouble: made pos=None the default for tick formatters rather than 0 to indicate "not supplied" The symptom is that running (for example) contour_demo.py from the command line with gtkagg backend, I often, but not always, get a blast of errors like this: Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/matplotlib/backends/backend_gtk.py", line 188, in motion_notify_event FigureCanvasBase.motion_notify_event(self, x, y) File "/usr/lib/python2.4/site-packages/matplotlib/backend_bases.py", line 797, in motion_notify_event func(event) File "/usr/lib/python2.4/site-packages/matplotlib/backend_bases.py", line 1085, in mouse_move try: s = event.inaxes.format_coord(event.xdata, event.ydata) File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line 612, in format_coord ys = self.format_ydata(y) File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line 605, in format_ydata val = func(y) File "/usr/lib/python2.4/site-packages/matplotlib/ticker.py", line 152, in format_data return self.__call__(value) File "/usr/lib/python2.4/site-packages/matplotlib/ticker.py", line 178, in __call__ else: return self.seq[pos] TypeError: list indices must be integers pos=None would certainly cause this...but I haven't checked it. (System is stock Mandriva 2006; mpl is CVS.) Eric
John, I have committed to CVS a set of changes that I think will address recent requests by Jordan and Gerald, and will be of more general use as well. From the CHANGELOG: 2005年11月27日 Multiple changes in cm.py, colors.py, figure.py, image.py, contour.py, contour_demo.py; new _cm.py, examples/image_masked.py. 1) Separated the color table data from cm.py out into a new file, _cm.py, to make it easier to find the actual code in cm.py and to add new colormaps. Also added some line breaks to the color data dictionaries. Everything from _cm.py is imported by cm.py, so the split should be transparent. 2) Enabled automatic generation of a colormap from a list of colors in contour; see modified examples/contour_demo.py. 3) Support for imshow of a masked array, with the ability to specify colors (or no color at all) for masked regions, and for regions that are above or below the normally mapped region. See examples/image_masked.py. 4) In support of the above, added two new classes, ListedColormap, and no_norm, to colors.py, and modified the Colormap class to include common functionality. Added a clip kwarg to the normalize class. Reworked color handling in contour.py, especially in the ContourLabeller mixin. With one very subtle exception, I don't think any default behaviors have been changed, so the changes should be entirely non-disruptive. That one exception is that in the original color mapping scheme, the last color was essentially never used. Consider an extreme case: a colormap with two entries. Suppose the image data ranged from 0 to 1. All values except exactly 1.0 were mapped to the first color, and only that upper limit value was mapped to the second color. As I have changed colors.py, values from 0.0 up to 0.5 will get the first color, and values from 0.5 through 1.0 will get the second. I think this is what a user would expect, and the only reason it hasn't mattered is that with 256 colors in a continuous range, one can't see the difference. The request from Jordan that is addressed here is the desire for precise color control in filled contouring. Now one can specify a list of colors in the "colors" kwarg, and they will be used to generate a colormap, which will then be used by colorbar. This is shown in a second plot added to examples/contourf_demo.py. (Jordan suggested a more extensive refactoring, which may indeed be a good idea; but I wanted to make these simpler changes before trying to think about anything more drastic.) The request from Gerald was for easy handling of masked arrays in imshow. It was in the context of basemap, which I have not tested yet; but at least for pylab.imshow, the situation is now easy to handle. If changes to basemap are needed, they should be very simple, and I can do them later as needed. I think that the changes to colormapping that I made to support this will be useful much more widely, but I have made no attempt to track down the places where changes will be in order. I may make additional changes to contour, and I know I will need to change colorbar to fully support this. I think colorbar needs some more refactoring anyway, but I can't do it immediately, and I did not want to delay getting the other changes out for testing and, hopefully, productive use. Eric
On Wednesday 23 November 2005 19:51, da...@eg... wrote: > Unfortunately, I can't seem to recreate your problem. The problem is that I have both Numeric[1] and the new scipy installed. When both are installed, the Numeric headers are picked up by default during scipy compilation. By forcing them to pick up the scipy headers, the problem was resolved. But it is a rather strange coincidence that the error results in truncated numbers rather than something drastic. Ravi [1] Reason: It will be a while before all my Numeric-based libraries are ported to the new scipy; porting is trivial, but regression testing takes time, especially given that the new scipy C API is not quite stable yet and that I haven't yet ported boost.python.numeric to scipy.
Hi, The logic for displaying a figure on the interactive backends (eg qt) seems a little strange to me. I imagine that normally the screen is used as a preview for a figure that is going to be output on paper, or to png or some permanent store. Therefore, the interactive output should resemble the permanent output as much as possible. Now, when using the QtAgg backend (sorry no time to play with other backends) setting the figure height or width has no effect on the size of the figure displayed with show(). It always comes out at 600x400. Further, given that the window can be resized or embedded, ideally what is displayed should be as good a representation of the figure as possible. It is not, however. To see this try resizing the window - fonts sizes, linewidths, etc. stay the same size. I can make the rendering more realistic using the dpi setting. This can be achieved using this implementation of resizeEvent (from backend_qt_agg.py / FigureCanvasQtAgg). The original code is commented. def resizeEvent( self, e ): FigureCanvasQT.resizeEvent( self, e ) w =3D e.size().width() h =3D e.size().height() if DEBUG: print "FigureCanvasQtAgg.resizeEvent(", w, ",", h, ")" #dpival =3D self.figure.dpi.get() #winch =3D w/dpival #hinch =3D h/dpival #self.figure.set_figsize_inches( winch, hinch ) if w/self.figure.get_figwidth() < h/self.figure.get_figheight(): self.figure.set_dpi( w/self.figure.get_figwidth() ) else: self.figure.set_dpi( h/self.figure.get_figheight() ) self.draw() The original implementation doesn't really do anything to how the figure is displayed. The new one makes the plot appear how it should no matter what the window's size. This is not ideal, however, as if the figure is saved now the dpi will be wrong. So there are two questions really: is this a better way for the interactive windows to display? If so, where should this logic go? thanks, James
from __future__ import division, generators import math, sys from numerix import absolute, arange, array, asarray, ones, divide,\ transpose, log, log10, Float, Float32, ravel, zeros,\ Int16, Int32, Int, Float64, ceil, indices, \ shape, which, where, sqrt, asum, compress, maximum, minimum import numerix.ma as ma import matplotlib.mlab from artist import Artist, setp from axis import XAxis, YAxis from cbook import iterable, is_string_like, flatten, enumerate, \ allequal, dict_delall, popd, popall, silent_list from collections import RegularPolyCollection, PolyCollection, = LineCollection from colors import colorConverter, normalize, Colormap, = LinearSegmentedColormap, looks_like_color import cm #from cm import ColormapJet, Grayscale, ScalarMappable from cm import ScalarMappable from contour import ContourSet import _image from ticker import AutoLocator, LogLocator, NullLocator from ticker import ScalarFormatter, LogFormatter, LogFormatterExponent, = LogFormatterMathtext, NullFormatter from image import AxesImage from legend import Legend from lines import Line2D, lineStyles, lineMarkers from matplotlib.mlab import meshgrid, detrend_none, detrend_linear, \ window_none, window_hanning, linspace, prctile from matplotlib.numerix.mlab import flipud, amin, amax from matplotlib import rcParams from patches import Patch, Rectangle, Circle, Polygon, Arrow, Wedge, = Shadow, bbox_artist from table import Table from text import Text, TextWithDash, _process_text_args from transforms import Bbox, Point, Value, Affine, = NonseparableTransformation from transforms import FuncXY, Func, LOG10, IDENTITY, POLAR from transforms import get_bbox_transform, unit_bbox, one, origin, zero from transforms import blend_xy_sep_transform, Interval from font_manager import FontProperties import matplotlib if matplotlib._havedate: from dates import date_ticker_factory def _process_plot_format(fmt): """ Process a matlab(TM) style color/line style format string. Return a linestyle, color tuple as a result of the processing. Default values are ('-', 'b'). Example format strings include 'ko' : black circles '.b' : blue dots 'r--' : red dashed lines See Line2D.lineStyles and GraphicsContext.colors for all possible styles and color format string. """ colors =3D { 'b' : 1, 'g' : 1, 'r' : 1, 'c' : 1, 'm' : 1, 'y' : 1, 'k' : 1, 'w' : 1, } linestyle =3D 'None' marker =3D 'None' color =3D rcParams['lines.color'] # handle the multi char special cases and strip them from the # string if fmt.find('--')>=3D0: linestyle =3D '--' fmt =3D fmt.replace('--', '') if fmt.find('-.')>=3D0: linestyle =3D '-.' fmt =3D fmt.replace('-.', '') chars =3D [c for c in fmt] for c in chars: if lineStyles.has_key(c): if linestyle !=3D 'None': raise ValueError, 'Illegal format string "%s"; two = linestyle symbols' % fmt linestyle =3D c elif lineMarkers.has_key(c): if marker !=3D 'None': raise ValueError, 'Illegal format string "%s"; two = marker symbols' % fmt marker =3D c elif colors.has_key(c): color =3D c else: err =3D 'Unrecognized character %c in format string' % c raise ValueError, err if linestyle =3D=3D 'None' and marker =3D=3D 'None': linestyle =3D rcParams['lines.linestyle'] return linestyle, marker, color class _process_plot_var_args: """ Process variable length arguments to the plot command, so that plot commands like the following are supported plot(t, s) plot(t1, s1, t2, s2) plot(t1, s1, 'ko', t2, s2) plot(t1, s1, 'ko', t2, s2, 'r--', t3, e3) an arbitrary number of x, y, fmt are allowed """ def __init__(self, command=3D'plot'): self.command =3D command self._clear_color_cycle() def _clear_color_cycle(self): self.colors =3D ['b','g','r','c','m','y','k'] # if the default line color is a color format string, move it up # in the que try: ind =3D self.colors.index(rcParams['lines.color']) except ValueError: self.firstColor =3D rcParams['lines.color'] else: self.colors[0], self.colors[ind] =3D self.colors[ind], = self.colors[0] self.firstColor =3D self.colors[0] self.Ncolors =3D len(self.colors) self.count =3D 0 def __call__(self, *args, **kwargs): ret =3D self._grab_next_args(*args, **kwargs) return ret def set_lineprops(self, line, **kwargs): assert self.command =3D=3D 'plot', 'set_lineprops only works = with "plot"' for key, val in kwargs.items(): funcName =3D "set_%s"%key if not hasattr(line,funcName): raise TypeError, 'There is no line property "%s"'%key func =3D getattr(line,funcName) func(val) def set_patchprops(self, fill_poly, **kwargs): assert self.command =3D=3D 'fill', 'set_patchprops only works = with "fill"' for key, val in kwargs.items(): funcName =3D "set_%s"%key if not hasattr(fill_poly,funcName): raise TypeError, 'There is no patch property "%s"'%key func =3D getattr(fill_poly,funcName) func(val) def is_filled(self, marker): filled =3D ('o', '^', 'v', '<', '>', 's', 'd', 'D', 'h', 'H', 'p') return marker in filled def _plot_1_arg(self, y, **kwargs): assert self.command =3D=3D 'plot', 'fill needs at least 2 = arguments' if self.count=3D=3D0: color =3D self.firstColor else: color =3D self.colors[int(self.count % self.Ncolors)] assert(iterable(y)) try: N=3Dmax(y.shape) except AttributeError: N =3D len(y) ret =3D Line2D(arange(N), y, color =3D color, markerfacecolor=3Dcolor, ) self.set_lineprops(ret, **kwargs) self.count +=3D 1 return ret def _plot_2_args(self, tup2, **kwargs): if is_string_like(tup2[1]): assert self.command =3D=3D 'plot', 'fill needs at least 2 = non-string arguments' y, fmt =3D tup2 assert(iterable(y)) linestyle, marker, color =3D _process_plot_format(fmt) if self.is_filled(marker): mec =3D None # use default else: mec =3D color # use current color try: N=3Dmax(y.shape) except AttributeError: N =3D len(y) ret =3D Line2D(xdata=3Darange(N), ydata=3Dy, color=3Dcolor, linestyle=3Dlinestyle, = marker=3Dmarker, markerfacecolor=3Dcolor, markeredgecolor=3Dmec, ) self.set_lineprops(ret, **kwargs) return ret else: x,y =3D tup2 #print self.count, self.Ncolors, self.count % self.Ncolors assert(iterable(x)) assert(iterable(y)) if self.command =3D=3D 'plot': c =3D self.colors[self.count % self.Ncolors] ret =3D Line2D(x, y, color =3D c, markerfacecolor =3D c, ) self.set_lineprops(ret, **kwargs) self.count +=3D 1 elif self.command =3D=3D 'fill': ret =3D Polygon( zip(x,y), fill=3DTrue, ) self.set_patchprops(ret, **kwargs) return ret def _plot_3_args(self, tup3, **kwargs): if self.command =3D=3D 'plot': x, y, fmt =3D tup3 assert(iterable(x)) assert(iterable(y)) linestyle, marker, color =3D _process_plot_format(fmt) if self.is_filled(marker): mec =3D None # use default else: mec =3D color # use current color ret =3D Line2D(x, y, color=3Dcolor, linestyle=3Dlinestyle, marker=3Dmarker, markerfacecolor=3Dcolor, markeredgecolor=3Dmec, ) self.set_lineprops(ret, **kwargs) if self.command =3D=3D 'fill': x, y, facecolor =3D tup3 ret =3D Polygon(zip(x,y), facecolor =3D facecolor, fill=3DTrue, ) self.set_patchprops(ret, **kwargs) return ret def _grab_next_args(self, *args, **kwargs): remaining =3D args while 1: if len(remaining)=3D=3D0: return if len(remaining)=3D=3D1: yield self._plot_1_arg(remaining[0], **kwargs) remaining =3D [] continue if len(remaining)=3D=3D2: yield self._plot_2_args(remaining, **kwargs) remaining =3D [] continue if len(remaining)=3D=3D3: if not is_string_like(remaining[2]): raise ValueError, 'third arg must be a format = string' yield self._plot_3_args(remaining, **kwargs) remaining=3D[] continue if is_string_like(remaining[2]): yield self._plot_3_args(remaining[:3], **kwargs) remaining=3Dremaining[3:] else: yield self._plot_2_args(remaining[:2], **kwargs) remaining=3Dremaining[2:] #yield self._plot_2_args(remaining[:2]) #remaining=3Dargs[2:] BinOpType=3Dtype(zero()) def makeValue(v): if type(v) =3D=3D BinOpType: return v else: return Value(v) class Axes(Artist): """ Emulate matlab's (TM) axes command, creating axes with Axes(position=3D[left, bottom, width, height]) where all the arguments are fractions in [0,1] which specify the fraction of the total figure window. axisbg is the color of the axis background """ scaled =3D {IDENTITY : 'linear', LOG10 : 'log', } def __init__(self, fig, rect, axisbg =3D None, # defaults to rc axes.facecolor frameon =3D True, sharex=3DNone, # use Axes instance's xaxis info sharey=3DNone, # use Axes instance's yaxis info label=3D'', **kwargs ): Artist.__init__(self) self._position =3D map(makeValue, rect) # must be set before set_figure self._sharex =3D sharex self._sharey =3D sharey self.set_label(label) self.set_figure(fig) # this call may differ for non-sep axes, eg polar self._init_axis() if axisbg is None: axisbg =3D rcParams['axes.facecolor'] self._axisbg =3D axisbg self._frameon =3D frameon self._axisbelow =3D False # todo make me an rcparam self._hold =3D rcParams['axes.hold'] self._connected =3D {} # a dict from events to (id, func) self.cla() # funcs used to format x and y - fall back on major formatters self.fmt_xdata =3D None self.fmt_ydata =3D None self.set_cursor_props((1,'k')) # set the cursor properties for = axes self._cachedRenderer =3D None self.set_navigate(True) # aspect ration atribute, and original position self._aspect =3D 'normal' self._originalPosition =3D self.get_position() if len(kwargs): setp(self, **kwargs) def _init_axis(self): "move this out of __init__ because non-separable axes don't use = it" self.xaxis =3D XAxis(self) self.yaxis =3D YAxis(self) def set_cursor_props(self, *args): """ Set the cursor property as ax.set_cursor_props(linewidth, color) OR ax.set_cursor_props((linewidth, color)) ACCEPTS: a (float, color) tuple """ if len(args)=3D=3D1: lw, c =3D args[0] elif len(args)=3D=3D2: lw, c =3D args else: raise ValueError('args must be a (linewidth, color) tuple') c =3DcolorConverter.to_rgba(c) self._cursorProps =3D lw, c def get_cursor_props(self): """return the cursor props as a linewidth, color tuple where linewidth is a float and color is an RGBA tuple""" return self._cursorProps def set_figure(self, fig): """ Set the Axes figure ACCEPTS: a Figure instance """ Artist.set_figure(self, fig) l, b, w, h =3D self._position xmin =3D fig.bbox.ll().x() xmax =3D fig.bbox.ur().x() ymin =3D fig.bbox.ll().y() ymax =3D fig.bbox.ur().y() figw =3D xmax-xmin figh =3D ymax-ymin self.left =3D l*figw self.bottom =3D b*figh self.right =3D (l+w)*figw self.top =3D (b+h)*figh self.bbox =3D Bbox( Point(self.left, self.bottom), Point(self.right, self.top ), ) #these will be updated later as data is added self._set_lim_and_transforms() def _set_lim_and_transforms(self): """ set the dataLim and viewLim BBox attributes and the transData and transAxes Transformation attributes """ if self._sharex is not None: left=3Dself._sharex.viewLim.ll().x() right=3Dself._sharex.viewLim.ur().x() else: left=3Dzero() right=3Done() if self._sharey is not None: bottom=3Dself._sharey.viewLim.ll().y() top=3Dself._sharey.viewLim.ur().y() else: bottom=3Dzero() top=3Done() self.viewLim =3D Bbox(Point(left, bottom), Point(right, top)) self.dataLim =3D unit_bbox() self.transData =3D get_bbox_transform(self.viewLim, self.bbox) self.transAxes =3D get_bbox_transform(unit_bbox(), self.bbox) if self._sharex: self.transData.set_funcx(self._sharex.transData.get_funcx()) if self._sharey: self.transData.set_funcy(self._sharey.transData.get_funcy()) def axhline(self, y=3D0, xmin=3D0, xmax=3D1, **kwargs): """ AXHLINE(y=3D0, xmin=3D0, xmax=3D1, **kwargs) Axis Horizontal Line Draw a horizontal line at y from xmin to xmax. With the default values of xmin=3D0 and xmax=3D1, this line will always span the = horizontal extent of the axes, regardless of the xlim settings, even if you change them, eg with the xlim command. That is, the horizontal = extent is in axes coords: 0=3Dleft, 0.5=3Dmiddle, 1.0=3Dright but the y = location is in data coordinates. Return value is the Line2D instance. kwargs are the same as = kwargs to plot, and can be used to control the line properties. Eg # draw a thick red hline at y=3D0 that spans the xrange axhline(linewidth=3D4, color=3D'r') # draw a default hline at y=3D1 that spans the xrange axhline(y=3D1) # draw a default hline at y=3D.5 that spans the the middle = half of # the xrange axhline(y=3D.5, xmin=3D0.25, xmax=3D0.75) """ trans =3D blend_xy_sep_transform( self.transAxes, = self.transData) l, =3D self.plot([xmin,xmax], [y,y], transform=3Dtrans, = **kwargs) return l def axvline(self, x=3D0, ymin=3D0, ymax=3D1, **kwargs): """ AXVLINE(x=3D0, ymin=3D0, ymax=3D1, **kwargs) Axis Vertical Line Draw a vertical line at x from ymin to ymax. With the default = values of ymin=3D0 and ymax=3D1, this line will always span the = vertical extent of the axes, regardless of the xlim settings, even if you change = them, eg with the xlim command. That is, the vertical extent is in = axes coords: 0=3Dbottom, 0.5=3Dmiddle, 1.0=3Dtop but the x location = is in data coordinates. Return value is the Line2D instance. kwargs are the same as kwargs to plot, and can be used to control the line properties. = Eg # draw a thick red vline at x=3D0 that spans the yrange l =3D axvline(linewidth=3D4, color=3D'r') # draw a default vline at x=3D1 that spans the yrange l =3D axvline(x=3D1) # draw a default vline at x=3D.5 that spans the the middle = half of # the yrange axvline(x=3D.5, ymin=3D0.25, ymax=3D0.75) """ trans =3D blend_xy_sep_transform( self.transData, self.transAxes = ) l, =3D self.plot([x,x], [ymin,ymax] , transform=3Dtrans, = **kwargs) return l def axhspan(self, ymin, ymax, xmin=3D0, xmax=3D1, **kwargs): """ AXHSPAN(ymin, ymax, xmin=3D0, xmax=3D1, **kwargs) Axis Horizontal Span. ycoords are in data units and x coords are in axes (relative 0-1) units Draw a horizontal span (regtangle) from ymin to ymax. With the default values of xmin=3D0 and xmax=3D1, this always span the = xrange, regardless of the xlim settings, even if you change them, eg = with the xlim command. That is, the horizontal extent is in axes coords: 0=3Dleft, 0.5=3Dmiddle, 1.0=3Dright but the y location is in = data coordinates. kwargs are the kwargs to Patch, eg antialiased, aa linewidth, lw edgecolor, ec facecolor, fc the terms on the right are aliases Return value is the patches.Polygon instance. #draws a gray rectangle from y=3D0.25-0.75 that spans the = horizontal #extent of the axes axhspan(0.25, 0.75, facecolor=3D0.5, alpha=3D0.5) """ trans =3D blend_xy_sep_transform( self.transAxes, self.transData = ) verts =3D (xmin, ymin), (xmin, ymax), (xmax, ymax), (xmax, ymin) p =3D Polygon(verts, **kwargs) p.set_transform(trans) self.add_patch(p) return p def axvspan(self, xmin, xmax, ymin=3D0, ymax=3D1, **kwargs): """ AXVSPAN(xmin, xmax, ymin=3D0, ymax=3D1, **kwargs) axvspan : Axis Vertical Span. xcoords are in data units and y = coords are in axes (relative 0-1) units Draw a vertical span (regtangle) from xmin to xmax. With the = default values of ymin=3D0 and ymax=3D1, this always span the yrange, = regardless of the ylim settings, even if you change them, eg with the ylim command. That is, the vertical extent is in axes coords: = 0=3Dbottom, 0.5=3Dmiddle, 1.0=3Dtop but the y location is in data = coordinates. kwargs are the kwargs to Patch, eg antialiased, aa linewidth, lw edgecolor, ec facecolor, fc the terms on the right are aliases return value is the patches.Polygon instance. # draw a vertical green translucent rectangle from x=3D1.25 = to 1.55 that # spans the yrange of the axes axvspan(1.25, 1.55, facecolor=3D'g', alpha=3D0.5) """ trans =3D blend_xy_sep_transform( self.transData, self.transAxes = ) verts =3D [(xmin, ymin), (xmin, ymax), (xmax, ymax), (xmax, = ymin)] p =3D Polygon(verts, **kwargs) p.set_transform(trans) self.add_patch(p) return p def format_xdata(self, x): """ Return x string formatted. This function will use the attribute self.fmt_xdata if it is callable, else will fall back on the = xaxis major formatter """ try: return self.fmt_xdata(x) except TypeError: func =3D self.xaxis.get_major_formatter().format_data val =3D func(x) return val def format_ydata(self, y): """ Return y string formatted. This function will use the attribute self.fmt_ydata if it is callable, else will fall back on the = yaxis major formatter """ try: return self.fmt_ydata(y) except TypeError: func =3D self.yaxis.get_major_formatter().format_data val =3D func(y) return val def format_coord(self, x, y): 'return a format string formatting the x, y coord' =20 xs =3D self.format_xdata(x) ys =3D self.format_ydata(y) return 'x=3D%s, y=3D%s'%(xs,ys) def has_data(self): 'return true if any artists have been added to axes' return ( len(self.collections) + len(self.images) + len(self.lines) + len(self.patches))>0 def _set_artist_props(self, a): 'set the boilerplate props for artists added to axes' a.set_figure(self.figure) if not a.is_transform_set(): a.set_transform(self.transData) a.axes =3D self def cla(self): 'Clear the current axes' self.xaxis.cla() self.yaxis.cla() if self._sharex is not None: self.xaxis.major =3D self._sharex.xaxis.major self.xaxis.minor =3D self._sharex.xaxis.minor if self._sharey is not None: self.yaxis.major =3D self._sharey.yaxis.major self.yaxis.minor =3D self._sharey.yaxis.minor self._get_lines =3D _process_plot_var_args() self._get_patches_for_fill =3D _process_plot_var_args('fill') self._gridOn =3D rcParams['axes.grid'] self.lines =3D [] self.patches =3D [] self.texts =3D [] # text in axis coords self.tables =3D [] self.artists =3D [] self.images =3D [] self.legend_ =3D None self.collections =3D [] # collection.Collection instances self._autoscaleon =3D True self.grid(self._gridOn) self.title =3D Text( x=3D0.5, y=3D1.02, text=3D'', = fontproperties=3DFontProperties(size=3DrcParams['axes.titlesize']), verticalalignment=3D'bottom', horizontalalignment=3D'center', ) self.title.set_transform(self.transAxes) self.title.set_clip_box(None) =20 self._set_artist_props(self.title) self.axesPatch =3D Rectangle( xy=3D(0,0), width=3D1, height=3D1, facecolor=3Dself._axisbg, edgecolor=3DrcParams['axes.edgecolor'], ) self.axesPatch.set_figure(self.figure) self.axesPatch.set_transform(self.transAxes) self.axesPatch.set_linewidth(rcParams['axes.linewidth']) self.axison =3D True def add_artist(self, a): 'Add any artist to the axes' self.artists.append(a) self._set_artist_props(a) def add_collection(self, collection): 'add a Collection instance to Axes' self.collections.append(collection) self._set_artist_props(collection) collection.set_clip_box(self.bbox) def get_images(self): 'return a list of Axes images contained by the Axes' return silent_list('AxesImage', self.images) def get_xscale(self): 'return the xaxis scale string: log or linear' return self.scaled[self.transData.get_funcx().get_type()] def get_yscale(self): 'return the yaxis scale string: log or linear' return self.scaled[self.transData.get_funcy().get_type()] def update_datalim(self, xys): 'Update the data lim bbox with seq of xy tups' # if no data is set currently, the bbox will ignore it's # limits and set the bound to be the bounds of the xydata. # Otherwise, it will compute the bounds of it's current data # and the data in xydata self.dataLim.update(xys, not self.has_data()) def update_datalim_numerix(self, x, y): 'Update the data lim bbox with seq of xy tups' # if no data is set currently, the bbox will ignore it's # limits and set the bound to be the bounds of the xydata. # Otherwise, it will compute the bounds of it's current data # and the data in xydata #print type(x), type(y) self.dataLim.update_numerix(x, y, not self.has_data()) def add_line(self, l): 'Add a line to the list of plot lines' self._set_artist_props(l) l.set_clip_box(self.bbox) xdata =3D l.get_xdata(valid_only=3DTrue) ydata =3D l.get_ydata(valid_only=3DTrue) if l.get_transform() !=3D self.transData: xys =3D self._get_verts_in_data_coords( l.get_transform(), zip(xdata, ydata)) xdata =3D array([x for x,y in xys]) ydata =3D array([y for x,y in xys]) self.update_datalim_numerix( xdata, ydata ) #self.update_datalim(zip(xdata, ydata)) label =3D l.get_label() if not label: l.set_label('line%d'%len(self.lines)) self.lines.append(l) def _get_verts_in_data_coords(self, trans, xys): if trans =3D=3D self.transData: return xys # data is not in axis data units. We must transform it to # display and then back to data to get it in data units xys =3D trans.seq_xy_tups(xys) return [ self.transData.inverse_xy_tup(xy) for xy in xys] def add_patch(self, p): """ Add a patch to the list of Axes patches; the clipbox will be set to the Axes clipping box. If the transform is not set, it wil be set to self.transData. """ self._set_artist_props(p) p.set_clip_box(self.bbox) xys =3D self._get_verts_in_data_coords( p.get_transform(), p.get_verts()) #for x,y in xys: print x,y self.update_datalim(xys) self.patches.append(p) def add_table(self, tab): 'Add a table instance to the list of axes tables' self._set_artist_props(tab) self.tables.append(tab) def autoscale_view(self): 'autoscale the view limits using the data limits' # if image data only just use the datalim if not self._autoscaleon: return if (len(self.images)>0 and len(self.lines)=3D=3D0 and len(self.patches)=3D=3D0): self.set_xlim(self.dataLim.intervalx().get_bounds()) self.set_ylim(self.dataLim.intervaly().get_bounds()) return locator =3D self.xaxis.get_major_locator() self.set_xlim(locator.autoscale()) locator =3D self.yaxis.get_major_locator() self.set_ylim(locator.autoscale()) if self._aspect =3D=3D 'equal': self.set_aspect('equal') def quiver(self, U, V, *args, **kwargs ): """ QUIVER( X, Y, U, V ) QUIVER( U, V ) QUIVER( X, Y, U, V, S) QUIVER( U, V, S ) QUIVER( ..., color=3DNone, width=3D1.0, cmap=3DNone,norm=3DNone = ) Make a vector plot (U, V) with arrows on a grid (X, Y) The optional arguments color and width are used to specify the = color and width of the arrow. color can be an array of colors in which case the = arrows can be colored according to another dataset. If cm is specied and color is None, the colormap is used to give = a color according to the vector's length. If color is a scalar field, the colormap is used to map the = scalar to a color If a colormap is specified and color is an array of color = triplets, then the colormap is ignored width is a scalar that controls the width of the arrows if S is specified it is used to scale the vectors. Use S=3D0 to = disable automatic scaling. If S!=3D0, vectors are scaled to fit within the grid and then = are multiplied by S. """ if not self._hold: self.cla() do_scale =3D True S =3D 1.0 if len(args)=3D=3D0: # ( U, V ) U =3D asarray(U) V =3D asarray(V) X,Y =3D meshgrid( arange(U.shape[1]), arange(U.shape[0]) ) elif len(args)=3D=3D1: # ( U, V, S ) U =3D asarray(U) V =3D asarray(V) X,Y =3D meshgrid( arange(U.shape[1]), arange(U.shape[0]) ) S =3D float(args[0]) do_scale =3D ( S !=3D 0.0 ) elif len(args)=3D=3D2: # ( X, Y, U, V ) X =3D asarray(U) Y =3D asarray(V) U =3D asarray(args[0]) V =3D asarray(args[1]) elif len(args)=3D=3D3: # ( X, Y, U, V ) X =3D asarray(U) Y =3D asarray(V) U =3D asarray(args[0]) V =3D asarray(args[1]) S =3D float(args[2]) do_scale =3D ( S !=3D 0.0 ) assert U.shape =3D=3D V.shape assert X.shape =3D=3D Y.shape assert U.shape =3D=3D X.shape arrows =3D [] N =3D sqrt( U**2+V**2 ) if do_scale: Nmax =3D maximum.reduce(maximum.reduce(N)) or 1 # account = for div by zero U =3D U*(S/Nmax) V =3D V*(S/Nmax) N =3D N*Nmax alpha =3D kwargs.get('alpha', 1.0) width =3D kwargs.get('width', 0.25) norm =3D kwargs.get('norm', None) cmap =3D kwargs.get('cmap', None) vmin =3D kwargs.get('vmin', None) vmax =3D kwargs.get('vmax', None) color =3D kwargs.get('color', None) shading =3D kwargs.get('shading', 'faceted') C =3D None I,J =3D U.shape if color is not None and not looks_like_color(color): clr =3D asarray(color) if clr.shape=3D=3DU.shape: C =3D array([ clr[i,j] for i in xrange(I) for j in = xrange(J)]) elif clr.shape =3D=3D () and color: # a scalar (1, True,...) C =3D array([ N[i,j] for i in xrange(I) for j in = xrange(J)]) else: color =3D (0.,0.,0.,1.) elif color is None: color =3D (0.,0.,0.,1.) else: color =3D colorConverter.to_rgba( color, alpha ) arrows =3D [ Arrow(X[i,j],Y[i,j],U[i,j],V[i,j],0.1*S = ).get_verts() for i in xrange(I) for j in xrange(J) ] collection =3D PolyCollection( arrows, edgecolors =3D 'None', facecolors =3D (color,), antialiaseds =3D (1,), linewidths =3D (width,), ) if C is not None: collection.set_array( C ) else: collection.set_facecolor( (color,) ) collection.set_cmap(cmap) collection.set_norm(norm) if norm is not None: collection.set_clim( vmin, vmax ) self.add_collection( collection ) lims =3D asarray(arrows) _max =3D maximum.reduce( maximum.reduce( lims )) _min =3D minimum.reduce( minimum.reduce( lims )) self.update_datalim( [ tuple(_min), tuple(_max) ] ) self.autoscale_view() return arrows def bar(self, left, height, width=3D0.8, bottom=3D0, color=3D'b', yerr=3DNone, xerr=3DNone, ecolor=3D'k', = capsize=3D3 ): """ BAR(left, height, width=3D0.8, bottom=3D0, color=3D'b', yerr=3DNone, xerr=3DNone, ecolor=3D'k', = capsize=3D3) Make a bar plot with rectangles at left, left+width, 0, height left and height are Numeric arrays. Return value is a list of Rectangle patch instances BAR(left, height, width, bottom, color, yerr, xerr, capsize, yoff) xerr and yerr, if not None, will be used to generate = errorbars on the bar chart color specifies the color of the bar ecolor specifies the color of any errorbar capsize determines the length in points of the error bar = caps The optional arguments color, width and bottom can be either scalars or len(x) sequences This enables you to use bar as the basis for stacked bar charts, or candlestick plots """ if not self._hold: self.cla() # left =3D asarray(left) - width/2 left =3D asarray(left) height =3D asarray(height) patches =3D [] # if color looks like a color string, an RGB tuple or a # scalar, then repeat it by len(x) if (is_string_like(color) or (iterable(color) and len(color)=3D=3D3 and len(left)!=3D3) = or not iterable(color)): color =3D [color]*len(left) if not iterable(bottom): bottom =3D array([bottom]*len(left), Float) else: bottom =3D asarray(bottom) if not iterable(width): width =3D array([width]*len(left), Float) else: width =3D asarray(width) N =3D len(left) assert len(bottom)=3D=3DN, 'bar arg bottom must be len(left)' assert len(width)=3D=3DN, 'bar arg width must be len(left) or = scalar' assert len(height)=3D=3DN, 'bar arg height must be len(left) or = scalar' assert len(color)=3D=3DN, 'bar arg color must be len(left) or = scalar' args =3D zip(left, bottom, width, height, color) for l, b, w, h, c in args: if h<0: b +=3D h h =3D abs(h) r =3D Rectangle( xy=3D(l, b), width=3Dw, height=3Dh, facecolor=3Dc, ) self.add_patch(r) patches.append(r) if xerr is not None or yerr is not None: self.errorbar( left+0.5*width, bottom+height, yerr=3Dyerr, xerr=3Dxerr, fmt=3DNone, ecolor=3Decolor, capsize=3Dcapsize) self.autoscale_view() return patches def boxplot(self, x, notch=3D0, sym=3D'b+', vert=3D1, whis=3D1.5, positions=3DNone, widths=3DNone): """ boxplot(x, notch=3D0, sym=3D'+', vert=3D1, whis=3D1.5, positions=3DNone, widths=3DNone) Make a box and whisker plot for each column of x. The box extends from the lower to upper quartile values of the data, with a line at the median. The whiskers extend from the box to show the range of the data. Flier points are those past the end of the whiskers. notch =3D 0 (default) produces a rectangular box plot. notch =3D 1 will produce a notched box plot sym (default 'b+') is the default symbol for flier points. Enter an empty string ('') if you don't want to show fliers. vert =3D 1 (default) makes the boxes vertical. vert =3D 0 makes horizontal boxes. This seems goofy, but that's how Matlab did it. whis (default 1.5) defines the length of the whiskers as a function of the inner quartile range. They extend to the most extreme data point within ( whis*(75%-25%) ) data range. positions (default 1,2,...,n) sets the horizontal positions of the boxes. The ticks and limits are automatically set to match the positions. widths is either a scalar or a vector and sets the width of each box. The default is 0.5, or 0.15*(distance between extreme positions) if that is smaller. x is a Numeric array Returns a list of the lines added """ if not self._hold: self.cla() holdStatus =3D self._hold lines =3D [] x =3D asarray(x) # if we've got a vector, reshape it rank =3D len(x.shape) if 1 =3D=3D rank: x.shape =3D -1, 1 row, col =3D x.shape # get some plot info if positions is None: positions =3D range(1, col + 1) if widths is None: distance =3D max(positions) - min(positions) widths =3D distance * min(0.15, 0.5/distance) if isinstance(widths, float) or isinstance(widths, int): widths =3D ones((col,), 'd') * widths # loop through columns, adding each to plot self.hold(True) for i,pos in enumerate(positions): d =3D x[:,i] # get median and quartiles q1, med, q3 =3D prctile(d,[25,50,75]) # get high extreme iq =3D q3 - q1 hi_val =3D q3 + whis*iq wisk_hi =3D compress( d <=3D hi_val , d ) if len(wisk_hi) =3D=3D 0: wisk_hi =3D q3 else: wisk_hi =3D max(wisk_hi) # get low extreme lo_val =3D q1 - whis*iq wisk_lo =3D compress( d >=3D lo_val, d ) if len(wisk_lo) =3D=3D 0: wisk_lo =3D q1 else: wisk_lo =3D min(wisk_lo) # get fliers - if we are showing them flier_hi =3D [] flier_lo =3D [] flier_hi_x =3D [] flier_lo_x =3D [] if len(sym) !=3D 0: flier_hi =3D compress( d > wisk_hi, d ) flier_lo =3D compress( d < wisk_lo, d ) flier_hi_x =3D ones(flier_hi.shape[0]) * pos flier_lo_x =3D ones(flier_lo.shape[0]) * pos # get x locations for fliers, whisker, whisker cap and box = sides box_x_min =3D pos - widths[i] * 0.5 box_x_max =3D pos + widths[i] * 0.5 wisk_x =3D ones(2) * pos cap_x_min =3D pos - widths[i] * 0.25 cap_x_max =3D pos + widths[i] * 0.25 cap_x =3D [cap_x_min, cap_x_max] # get y location for median med_y =3D [med, med] # calculate 'regular' plot if notch =3D=3D 0: # make our box vectors box_x =3D [box_x_min, box_x_max, box_x_max, box_x_min, = box_x_min ] box_y =3D [q1, q1, q3, q3, q1 ] # make our median line vectors med_x =3D [box_x_min, box_x_max] # calculate 'notch' plot else: notch_max =3D med + 1.57*iq/sqrt(row) notch_min =3D med - 1.57*iq/sqrt(row) if notch_max > q3: notch_max =3D q3 if notch_min < q1: notch_min =3D q1 # make our notched box vectors box_x =3D [box_x_min, box_x_max, box_x_max, cap_x_max, = box_x_max, box_x_max, box_x_min, box_x_min, cap_x_min, box_x_min, = box_x_min ] box_y =3D [q1, q1, notch_min, med, notch_max, q3, q3, = notch_max, med, notch_min, q1] # make our median line vectors med_x =3D [cap_x_min, cap_x_max] med_y =3D [med, med] # make a vertical plot . . . if 1 =3D=3D vert: l =3D self.plot(wisk_x, [q1, wisk_lo], 'b--', wisk_x, [q3, wisk_hi], 'b--', cap_x, [wisk_hi, wisk_hi], 'k-', cap_x, [wisk_lo, wisk_lo], 'k-', box_x, box_y, 'b-', med_x, med_y, 'r-', flier_hi_x, flier_hi, sym, flier_lo_x, flier_lo, sym ) lines.extend(l) # or perhaps a horizontal plot else: l =3D self.plot([q1, wisk_lo], wisk_x, 'b--', [q3, wisk_hi], wisk_x, 'b--', [wisk_hi, wisk_hi], cap_x, 'k-', [wisk_lo, wisk_lo], cap_x, 'k-', box_y, box_x, 'b-', med_y, med_x, 'r-', flier_hi, flier_hi_x, sym, flier_lo, flier_lo_x, sym ) lines.extend(l) # fix our axes/ticks up a little if 1 =3D=3D vert: setticks, setlim =3D self.set_xticks, self.set_xlim else: setticks, setlim =3D self.set_yticks, self.set_ylim newlimits =3D min(positions)-0.5, max(positions)+0.5 setlim(newlimits) setticks(positions) =20 # reset hold status self.hold(holdStatus) return lines def barh(self, x, y, height=3D0.8, left=3D0, color=3D'b', yerr=3DNone, xerr=3DNone, ecolor=3D'k', = capsize=3D3 ): """ BARH(x, y, height=3D0.8, left=3D0, color=3D'b', yerr=3DNone, xerr=3DNone, ecolor=3D'k', = capsize=3D3) BARH(x, y) The y values give the heights of the center of the bars. = The x values give the length of the bars. Return value is a list of Rectangle patch instances Optional arguments height - the height (thickness) of the bar left - the x coordinate of the left side of the bar color specifies the color of the bar xerr and yerr, if not None, will be used to generate = errorbars on the bar chart ecolor specifies the color of any errorbar capsize determines the length in points of the error bar = caps The optional arguments color, height and left can be either scalars or len(x) sequences """ if not self._hold: self.cla() # left =3D asarray(left) - width/2 x =3D asarray(x) y =3D asarray(y) patches =3D [] # if color looks like a color string, and RGB tuple or a # scalar, then repeat it by len(x) if (is_string_like(color) or (iterable(color) and len(color)=3D=3D3 and len(left)!=3D3) = or not iterable(color)): color =3D [color]*len(x) if not iterable(left): left =3D array([left]*len(x), Float) else: left =3D asarray(left) if not iterable(height): height =3D array([height]*len(x), Float) else: height =3D asarray(height) N =3D len(x) assert len(left)=3D=3DN, 'bar arg left must be len(x)' assert len(height)=3D=3DN, 'bar arg height must be len(x) or = scalar' assert len(y)=3D=3DN, 'bar arg y must be len(x) or scalar' assert len(color)=3D=3DN, 'bar arg color must be len(x) or = scalar' width =3D x right =3D left+x bottom =3D y - height/2. args =3D zip(left, bottom, width, height, color) for l, b, w, h, c in args: if h<0: b +=3D h h =3D abs(h) r =3D Rectangle( xy=3D(l, b), width=3Dw, height=3Dh, facecolor=3Dc, ) self.add_patch(r) patches.append(r) if xerr is not None or yerr is not None: self.errorbar( right, y, yerr=3Dyerr, xerr=3Dxerr, fmt=3DNone, ecolor=3Decolor, capsize=3Dcapsize) self.autoscale_view() return patches def clear(self): 'clear the axes' self.cla() def clabel(self, CS, *args, **kwargs): return CS.clabel(*args, **kwargs) clabel.__doc__ =3D ContourSet.clabel.__doc__ def contour(self, *args, **kwargs): kwargs['filled'] =3D False return ContourSet(self, *args, **kwargs) contour.__doc__ =3D ContourSet.contour_doc def contourf(self, *args, **kwargs): kwargs['filled'] =3D True return ContourSet(self, *args, **kwargs) contourf.__doc__ =3D ContourSet.contour_doc def cohere(self, x, y, NFFT=3D256, Fs=3D2, detrend=3Ddetrend_none, window=3Dwindow_hanning, noverlap=3D0, **kwargs): """ COHERE(x, y, NFFT=3D256, Fs=3D2, detrend=3Ddetrend_none, window=3Dwindow_hanning, noverlap=3D0) cohere the coherence between x and y. Coherence is the = normalized cross spectral density Cxy =3D |Pxy|^2/(Pxx*Pyy) The return value is (Cxy, f), where f are the frequencies of the coherence vector. See the PSD help for a description of the optional parameters. kwargs are applied to the lines Returns the tuple Cxy, freqs Refs: Bendat & Piersol -- Random Data: Analysis and Measurement Procedures, John Wiley & Sons (1986) """ if not self._hold: self.cla() cxy, freqs =3D matplotlib.mlab.cohere(x, y, NFFT, Fs, detrend, = window, noverlap) self.plot(freqs, cxy, **kwargs) self.set_xlabel('Frequency') self.set_ylabel('Coherence') self.grid(True) return cxy, freqs def csd(self, x, y, NFFT=3D256, Fs=3D2, detrend=3Ddetrend_none, window=3Dwindow_hanning, noverlap=3D0): """ CSD(x, y, NFFT=3D256, Fs=3D2, detrend=3Ddetrend_none, window=3Dwindow_hanning, noverlap=3D0) The cross spectral density Pxy by Welches average periodogram = method. The vectors x and y are divided into NFFT length segments. Each segment is detrended by function detrend and windowed by = function window. The product of the direct FFTs of x and y are averaged = over each segment to compute Pxy, with a scaling to correct for power = loss due to windowing. See the PSD help for a description of the optional parameters. Returns the tuple Pxy, freqs. Pxy is the cross spectrum = (complex valued), and 10*log10(|Pxy|) is plotted Refs: Bendat & Piersol -- Random Data: Analysis and Measurement Procedures, John Wiley & Sons (1986) """ if not self._hold: self.cla() pxy, freqs =3D matplotlib.mlab.csd(x, y, NFFT, Fs, detrend, = window, noverlap) pxy.shape =3D len(freqs), # pxy is complex self.plot(freqs, 10*log10(absolute(pxy))) self.set_xlabel('Frequency') self.set_ylabel('Cross Spectrum Magnitude (dB)') self.grid(True) vmin, vmax =3D self.viewLim.intervaly().get_bounds() intv =3D vmax-vmin step =3D 10*int(log10(intv)) ticks =3D arange(math.floor(vmin), math.ceil(vmax)+1, step) self.set_yticks(ticks) return pxy, freqs def draw_artist(self, a): """ This method can only be used after an initial draw which caches the renderer. It is used to efficiently update Axes data (axis ticks, labels, etc are not updated) """ assert self._cachedRenderer is not None a.draw(self._cachedRenderer) def redraw_in_frame(self): """ This method can only be used after an initial draw which caches the renderer. It is used to efficiently update Axes data (axis ticks, labels, etc are not updated) """ assert self._cachedRenderer is not None self.draw(self._cachedRenderer, inframe=3DTrue) def get_renderer_cache(self): return self._cachedRenderer def draw(self, renderer=3DNone, inframe=3DFalse): "Draw everything (plot lines, axes, labels)" if renderer is None: renderer =3D self._cachedRenderer if renderer is None: raise RuntimeError('No renderer defined') if not self.get_visible(): return renderer.open_group('axes') try: self.transData.freeze() # eval the lazy objects except ValueError: print >> sys.stderr, 'data freeze value error', = self.get_position(), self.dataLim.get_bounds(), = self.viewLim.get_bounds() raise =20 self.transAxes.freeze() # eval the lazy objects if self.axison: if self._frameon: self.axesPatch.draw(renderer) if len(self.images)=3D=3D1: im =3D self.images[0] im.draw(renderer) elif len(self.images)>1: # make a composite image blending alpha # list of (_image.Image, ox, oy) ims =3D [(im.make_image(),0,0) for im in self.images if = im.get_visible()] im =3D _image.from_images(self.bbox.height(), = self.bbox.width(), ims) im.is_grayscale =3D False l, b, w, h =3D self.bbox.get_bounds() renderer.draw_image(l, b, im, self.bbox) # axis drawing was here, where contourf etc clobbered them # draw axes here, so they are on top of most things if self._axisbelow: if self.axison and not inframe: self.xaxis.draw(renderer) self.yaxis.draw(renderer) artists =3D [] artists.extend(self.collections) artists.extend(self.patches) artists.extend(self.lines) artists.extend(self.texts) # keep track of i to guarantee stable sort for python 2.2 dsu =3D [ (a.zorder, i, a) for i, a in enumerate(artists) if not a.get_animated()] dsu.sort() for zorder, i, a in dsu: a.draw(renderer) self.title.draw(renderer) if 0: bbox_artist(self.title, renderer) # optional artists for a in self.artists: a.draw(renderer) if not self._axisbelow: if self.axison and not inframe: self.xaxis.draw(renderer) self.yaxis.draw(renderer) if self.legend_ is not None: self.legend_.draw(renderer) for table in self.tables: table.draw(renderer) self.transData.thaw() # release the lazy objects self.transAxes.thaw() # release the lazy objects renderer.close_group('axes') self._cachedRenderer =3D renderer def __draw_animate(self): # ignore for now; broken if self._lastRenderer is None: raise RuntimeError('You must first call ax.draw()') dsu =3D [(a.zorder, a) for a in self.animated.keys()] dsu.sort() renderer =3D self._lastRenderer renderer.blit() for tmp, a in dsu: a.draw(renderer) def errorbar(self, x, y, yerr=3DNone, xerr=3DNone, fmt=3D'b-', ecolor=3DNone, capsize=3D3, barsabove=3DFalse, **kwargs): """ ERRORBAR(x, y, yerr=3DNone, xerr=3DNone, fmt=3D'b-', ecolor=3DNone, capsize=3D3, = barsabove=3DFalse) Plot x versus y with error deltas in yerr and xerr. Vertical errorbars are plotted if yerr is not None Horizontal errorbars are plotted if xerr is not None xerr and yerr may be any of: a rank-0, Nx1 Numpy array - symmetric errorbars +/- value an N-element list or tuple - symmetric errorbars +/- value a rank-1, Nx2 Numpy array - asymmetric errorbars = -column1/+column2 Alternatively, x, y, xerr, and yerr can all be scalars, which plots a single error bar at x, y. fmt is the plot format symbol for y. if fmt is None, just plot the errorbars with no line symbols. This can be useful for creating a bar plot with errorbars ecolor is a matplotlib color arg which gives the color the errorbar lines; if None, use the marker color. capsize is the size of the error bar caps in points barsabove, if True, will plot the errorbars above the plot = symbols - default is below kwargs are passed on to the plot command for the markers. So you can add additional key=3Dvalue pairs to control the errorbar markers. For example, this code makes big red squares with thick green edges >>> x,y,yerr =3D rand(3,10) >>> errorbar(x, y, yerr, marker=3D's', mfc=3D'red', mec=3D'green', ms=3D20, mew=3D4) mfc, mec, ms and mew are aliases for the longer property names, markerfacecolor, markeredgecolor, markersize and markeredgewith. Return value is a length 2 tuple. The first element is the Line2D instance for the y symbol lines. The second element is a list of error bar lines. """ if not self._hold: self.cla() # make sure all the args are iterable arrays if not iterable(x): x =3D asarray([x]) else: x =3D asarray(x) if not iterable(y): y =3D asarray([y]) else: y =3D asarray(y) if xerr is not None: if not iterable(xerr): xerr =3D asarray([xerr]) else: xerr =3D asarray(xerr) if yerr is not None: if not iterable(yerr): yerr =3D asarray([yerr]) else: yerr =3D asarray(yerr) l0 =3D None if barsabove and fmt is not None: l0, =3D self.plot(x,y,fmt,**kwargs) caplines =3D [] barlines =3D [] if xerr is not None: if len(xerr.shape) =3D=3D 1: left =3D x-xerr right =3D x+xerr else: left =3D x-xerr[0] right =3D x+xerr[1] barlines.extend( self.hlines(y, x, left) ) barlines.extend( self.hlines(y, x, right) ) caplines.extend( self.plot(left, y, '|', ms=3D2*capsize) ) caplines.extend( self.plot(right, y, '|', ms=3D2*capsize) ) if yerr is not None: if len(yerr.shape) =3D=3D 1: lower =3D y-yerr upper =3D y+yerr else: lower =3D y-yerr[0] upper =3D y+yerr[1] barlines.extend( self.vlines(x, y, upper ) ) barlines.extend( self.vlines(x, y, lower ) ) caplines.extend( self.plot(x, lower, '_', ms=3D2*capsize) ) caplines.extend( self.plot(x, upper, '_', ms=3D2*capsize) ) if not barsabove and fmt is not None: l0, =3D self.plot(x,y,fmt,**kwargs) if ecolor is None and l0 is None: ecolor =3D rcParams['lines.color'] elif ecolor is None: ecolor =3D l0.get_color() for l in barlines: l.set_color(ecolor) for l in caplines: l.set_color(ecolor) l.set_markerfacecolor(ecolor) l.set_markeredgecolor(ecolor) self.autoscale_view() ret =3D silent_list('Line2D errorbar', caplines+barlines) return (l0, ret) def fill(self, *args, **kwargs): """ FILL(*args, **kwargs) plot filled polygons. *args is a variable length argument, = allowing for multiple x,y pairs with an optional color format string; see = plot for details on the argument parsing. For example, all of the following are legal, assuming a is the Axis instance: ax.fill(x,y) # plot polygon with vertices at x,y ax.fill(x,y, 'b' ) # plot polygon with vertices at x,y in = blue An arbitrary number of x, y, color groups can be specified, as = in ax.fill(x1, y1, 'g', x2, y2, 'r') Return value is a list of patches that were added The same color strings that plot supports are supported by the = fill format string. The kwargs that are can be used to set line properties (any property that has a set_* method). You can use this to set edge color, face color, etc. """ if not self._hold: self.cla() patches =3D [] for poly in self._get_patches_for_fill(*args, **kwargs): self.add_patch( poly ) patches.append( poly ) self.autoscale_view() return patches def get_axis_bgcolor(self): 'Return the axis background color' return self._axisbg def get_child_artists(self): """ Return a list of artists the axes contains. Deprecated """ artists =3D [self.title, self.axesPatch, self.xaxis, self.yaxis] artists.extend(self.lines) artists.extend(self.patches) artists.extend(self.texts) artists.extend(self.collections) if self.legend_ is not None: artists.append(self.legend_) return silent_list('Artist', artists) def get_frame(self): 'Return the axes Rectangle frame' return self.axesPatch def get_legend(self): 'Return the Legend instance, or None if no legend is defined' return self.legend_ def get_lines(self): 'Return a list of lines contained by the Axes' return silent_list('Line2D', self.lines) def get_xaxis(self): 'Return the XAxis instance' return self.xaxis def get_xgridlines(self): 'Get the x grid lines as a list of Line2D instances' return silent_list('Line2D xgridline', = self.xaxis.get_gridlines()) def get_xlim(self): 'Get the x axis range [xmin, xmax]' return self.viewLim.intervalx().get_bounds() def get_xticklabels(self): 'Get the xtick labels as a list of Text instances' return silent_list('Text xticklabel', = self.xaxis.get_ticklabels()) def get_xticklines(self): 'Get the xtick lines as a list of Line2D instances' return silent_list('Text xtickline', self.xaxis.get_ticklines()) def get_xticks(self): 'Return the x ticks as a list of locations' return self.xaxis.get_ticklocs() def get_yaxis(self): 'Return the YAxis instance' return self.yaxis def get_ylim(self): 'Get the y axis range [ymin, ymax]' return self.viewLim.intervaly().get_bounds() def get_ygridlines(self): 'Get the y grid lines as a list of Line2D instances' return silent_list('Line2D ygridline', = self.yaxis.get_gridlines()) def get_yticklabels(self): 'Get the ytick labels as a list of Text instances' return silent_list('Text yticklabel', = self.yaxis.get_ticklabels()) def get_yticklines(self): 'Get the ytick lines as a list of Line2D instances' return silent_list('Line2D ytickline', = self.yaxis.get_ticklines()) def get_yticks(self): 'Return the y ticks as a list of locations' return self.yaxis.get_ticklocs() def get_frame_on(self): """ Get whether the axes rectangle patch is drawn """ return self._frameon def get_navigate(self): """ Get whether the axes responds to navigation commands """ return self._navigate def get_axisbelow(self): """ Get whether axist below is true or not """ return self._axisbelow def get_autoscale_on(self): """ Get whether autoscaling is applied on plot commands """ return self._autoscaleon def grid(self, b=3DNone): """ Set the axes grids on or off; b is a boolean if b is None, toggle the grid state """ self.xaxis.grid(b) self.yaxis.grid(b) def hist(self, x, bins=3D10, normed=3D0, bottom=3D0, orientation=3D'vertical', width=3DNone, **kwargs): """ HIST(x, bins=3D10, normed=3D0, bottom=3D0, = orientiation=3D'vertical', **kwargs) Compute the histogram of x. bins is either an integer number of bins or a sequence giving the bins. x are the data to be = binned. The return values is (n, bins, patches) If normed is true, the first element of the return tuple will be the counts normalized to form a probability density, ie, n/(len(x)*dbin) orientation =3D 'horizontal' | 'vertical'. If horizontal, barh will be used and the "bottom" kwarg will be the left. width: the width of the bars. If None, automatically compute the width. kwargs are used to update the properties of the hist bars """ if not self._hold: self.cla() n,bins =3D matplotlib.mlab.hist(x, bins, normed) if width is None: width =3D 0.9*(bins[1]-bins[0]) if orienta... [truncated message content]
On Nov 23, 2005, at 12:20 PM, Ravikiran Rajagopal wrote: > After application of Daishi Harada's patch on 0.85, I tried to use it > with > SciPy core SVN from yesterday and get rather strange results: I'm sorry you're having troubles with the patch. Unfortunately, I can't seem to recreate your problem. I realize "works for me" isn't a particularly useful response, but I'm afraid that's the best I can do for now - and I'll be away again for Thanksgiving until next week. FWIW, I'm using the CVS matplotlib with the wx backend, and the new scipy w/atlas. d
After application of Daishi Harada's patch on 0.85, I tried to use it with SciPy core SVN from yesterday and get rather strange results: x = scipy.array( [16.5]*10 ) y = scipy.array( [19.5]*10 ) w = scipy.arange(10) # This plots a line at 16.0, not 16.5! pylab.plot( w, x ) # However this works perfectly with a blue box 0-9 x 16.5x19.5 f = pylab.figure() a = f.add_subplot( 1, 1, 1 ) a.fill( scipy.concatenate((w,w[::-1])), scipy.concatenate((x,y[::-1])) ) f.canvas.draw() Further, the legend boxes are too large, usually obscuring most of the picture with a polygonal patch (such as the one produced by the fill above) or at least a half without any polygonal patches. How can I help debug these issues? Regards, Ravi
Sorry about the delay in getting back to you (I was away for a long weekend and just got back in today). On Nov 19, 2005, at 8:22 AM, John Hunter wrote: > daishi> This patch allows one to use matplotlib with (just) the > daishi> new scipy. > > Just for clarification, when you say "just" the new scipy, you mean > that it works with Numeric, numarray *and* the new scipy, not that it > works with the new scipy and only the new scipy. The intent was so that current users of numeric/numarray wouldn't see any difference at all, but that matplotlib would build against the new scipy - I believe this is the case, mod Fernando's fix. > In the near term, this means that mpl would compile three > shared object files for each of the three array objects for each > extension module, which of course will increase compile times and > binary distribution sizes. As it currently stands, the patch will build at most *two* shared objects, because the build logic is basically: if numarray: # numarray build if (numeric or scipy): # numeric or scipy build, # with numeric taking precedence. It shouldn't be difficult to flatten this out to build three libraries, however. I submitted the patch in its preliminary form to see whether there was interest in going this route at all, since I saw the discussion about the unified/new array interface plan. Fernando wrote: > Minor fix needed to avoid unpleasant surprises for users who have the > old scipy on their import path: > > try: > import scipy > if hasattr(scipy,'__core_version__'): > NUMERIX.append('scipy') > except ImportError: > pass > > You want to make sure that you only do this for users of the _new_ > scipy, not the old one. Thanks and sorry about that, this problem occurred to me over the weekend too. d
Arg! One petty thing after another. Here is a simple script demonstrating that the last row does not render the SpanSelector, yet the callback works fine??? ------------------------------------ import matplotlib from matplotlib.widgets import SpanSelector matplotlib.use('TkAgg') from pylab import * s =3D 3 axs =3D [subplot(s,s,i) for i in xrange(1,s**2+1)] def onselect(x, y): print x, y [SpanSelector(a, onselect, 'vertical', useblit=3DTrue) for a in axs] show() ------------------------------------ Any clues as to where to look for this bug? Sorry to be a hassle, but I need this specifically to embed in a Tk only app. Thanks, Charlie On 11/19/05, John Hunter <jdh...@ac...> wrote: > >>>>> "Charlie" =3D=3D Charlie Moad <cw...@gm...> writes: > > Charlie> Awesome, thanks! Out of curiousity... did you figure > Charlie> this out visually or by comparing with something? > > Let's just say I've encountered the flipy bug before :-) > > JDH >
I'm very interested to see how stuff looks on a Mac. I don't have access to one, so I'll be looking forward to your results. I still haven't figured out how to get antialiased lines in EMFs, so the output doesn't look as good on the screen as all the agg rendering. But, if you push the dots per inch high enough in the savefig() command, it looks decent. It does have the advantage of being a vector format, at least, so it resizes well. :) It's really worked well for me to be able to embed multiple EMFs and text and tables in an RTF, with everything machine generated by Python. Hopefully it works across platforms for you guys. Rob On 11/21/05, Ted Drain <ted...@jp...> wrote: > Rob, > I think you may have just implemented/discovered/unearthed the Holy > Grail! This looks fantastic. We have been fighting with EPS files for > years and trying to come up with a way to have plots that can be embedded > in Office documents that look good on the screen for presentations and > still print well. > > The EPS preview image has never worked very well and the resulting files > almost always had problems when moved from MS Office on the PC to/from th= e > Mac. If your system works well across platforms, that could save the > engineers here a lot of time. > > We'll have to download this and give it a try. Thanks! > Ted > > At 06:03 PM 11/19/2005, Rob McMullen wrote: > >I just submitted a patch to add a new non-interactive backend that > >produces enhanced metafiles, an OpenOffice and Microsoft Windows > >scalable graphics format that can also be embedded in .rtf files. > > > >http://sourceforge.net/tracker/index.php?func=3Ddetail&aid=3D1361839&gro= up_id=3D80706&atid=3D560722 > > > >The backend is based on my pyemf package that I finally released with > >its first public beta: > > > >http://pyemf.sourceforge.net > > > >The API should be stable -- I'm only planning on adding to it and not > >changing any existing method signatures in the version 2.0.* series. > > > >Oh, and I didn't say so in the patch itself, but I'm happy to donate > >the patch to matplotlib under the default matplotlib license. > > > >Rob > > > > > >------------------------------------------------------- > >This SF.Net email is sponsored by the JBoss Inc. Get Certified Today > >Register for a JBoss Training Course. Free Certification Exam > >for All Training Attendees Through End of 2005. For more info visit: > >http://ads.osdn.com/?ad_idv28&alloc_id845&opclick > >_______________________________________________ > >Matplotlib-devel mailing list > >Mat...@li... > >https://lists.sourceforge.net/lists/listinfo/matplotlib-devel > > Ted Drain Jet Propulsion Laboratory ted...@jp... > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by the JBoss Inc. Get Certified Today > Register for a JBoss Training Course. Free Certification Exam > for All Training Attendees Through End of 2005. For more info visit: > http://ads.osdn.com/?ad_id=3D7628&alloc_id=3D16845&op=3Dclick > _______________________________________________ > Matplotlib-devel mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-devel >
On Monday 21 November 2005 1:12 pm, Travis Oliphant wrote: > Darren Dale wrote: > >Sorry, I've obviously overlooked something, but maybe I have also > > discovered a bug. I've just removed atlas/blas/lapack, updated scipy_core > > from svn, removed my build and site-packages/scipy directories, and tried > > to build scipy_core. Here is a warning message I get toward the end of > > the build and install processes: > > This is definitely a configuration issue. For some reason, the system > is picking up BLAS information and therefore trying to compile _dotblas > for you. However, it is failing because the libblas file is not found. > > Can you show us the output of the start of the build (where SYSTEM INFO > things are printed). Or just attach a complete record of the build. > This might help track down what the configuration issue is. This was due to an oversight on my end. I used gentoo's package manager to completely remove atlas/blas/lapack, and afterwards verified that every instance of /usr/lib/libatlas.* had been removed. I did not check that libblas.* and liblapack.* had been removed, but I should have. Unfortunately, a few broken soft links remained, which scipy found and tried to build against. After removing those links, I was able to build scipy_core. How embarrassing. I'm sorry for the noise. Darren
Rob, I think you may have just implemented/discovered/unearthed the Holy Grail! This looks fantastic. We have been fighting with EPS files for years and trying to come up with a way to have plots that can be embedded in Office documents that look good on the screen for presentations and still print well. The EPS preview image has never worked very well and the resulting files almost always had problems when moved from MS Office on the PC to/from the Mac. If your system works well across platforms, that could save the engineers here a lot of time. We'll have to download this and give it a try. Thanks! Ted At 06:03 PM 11/19/2005, Rob McMullen wrote: >I just submitted a patch to add a new non-interactive backend that >produces enhanced metafiles, an OpenOffice and Microsoft Windows >scalable graphics format that can also be embedded in .rtf files. > >http://sourceforge.net/tracker/index.php?func=detail&aid=1361839&group_id=80706&atid=560722 > >The backend is based on my pyemf package that I finally released with >its first public beta: > >http://pyemf.sourceforge.net > >The API should be stable -- I'm only planning on adding to it and not >changing any existing method signatures in the version 2.0.* series. > >Oh, and I didn't say so in the patch itself, but I'm happy to donate >the patch to matplotlib under the default matplotlib license. > >Rob > > >------------------------------------------------------- >This SF.Net email is sponsored by the JBoss Inc. Get Certified Today >Register for a JBoss Training Course. Free Certification Exam >for All Training Attendees Through End of 2005. For more info visit: >http://ads.osdn.com/?ad_idv28&alloc_id845&opclick >_______________________________________________ >Matplotlib-devel mailing list >Mat...@li... >https://lists.sourceforge.net/lists/listinfo/matplotlib-devel Ted Drain Jet Propulsion Laboratory ted...@jp...
Currently implemented for PostScript backend only - the rest ignore the command. I tried to make it in the same style as the rest of Matplotlib iface: 'x' does bidiagonal hatching '/' does diagonal, '-' does horizontal, and so on. Repeating the hatching symbol increases the density of hatching. Attached is the diff for version 0.85. Is there a chance for this thing to be included into the source?