You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
(12) |
Sep
(12) |
Oct
(56) |
Nov
(65) |
Dec
(37) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(59) |
Feb
(78) |
Mar
(153) |
Apr
(205) |
May
(184) |
Jun
(123) |
Jul
(171) |
Aug
(156) |
Sep
(190) |
Oct
(120) |
Nov
(154) |
Dec
(223) |
2005 |
Jan
(184) |
Feb
(267) |
Mar
(214) |
Apr
(286) |
May
(320) |
Jun
(299) |
Jul
(348) |
Aug
(283) |
Sep
(355) |
Oct
(293) |
Nov
(232) |
Dec
(203) |
2006 |
Jan
(352) |
Feb
(358) |
Mar
(403) |
Apr
(313) |
May
(165) |
Jun
(281) |
Jul
(316) |
Aug
(228) |
Sep
(279) |
Oct
(243) |
Nov
(315) |
Dec
(345) |
2007 |
Jan
(260) |
Feb
(323) |
Mar
(340) |
Apr
(319) |
May
(290) |
Jun
(296) |
Jul
(221) |
Aug
(292) |
Sep
(242) |
Oct
(248) |
Nov
(242) |
Dec
(332) |
2008 |
Jan
(312) |
Feb
(359) |
Mar
(454) |
Apr
(287) |
May
(340) |
Jun
(450) |
Jul
(403) |
Aug
(324) |
Sep
(349) |
Oct
(385) |
Nov
(363) |
Dec
(437) |
2009 |
Jan
(500) |
Feb
(301) |
Mar
(409) |
Apr
(486) |
May
(545) |
Jun
(391) |
Jul
(518) |
Aug
(497) |
Sep
(492) |
Oct
(429) |
Nov
(357) |
Dec
(310) |
2010 |
Jan
(371) |
Feb
(657) |
Mar
(519) |
Apr
(432) |
May
(312) |
Jun
(416) |
Jul
(477) |
Aug
(386) |
Sep
(419) |
Oct
(435) |
Nov
(320) |
Dec
(202) |
2011 |
Jan
(321) |
Feb
(413) |
Mar
(299) |
Apr
(215) |
May
(284) |
Jun
(203) |
Jul
(207) |
Aug
(314) |
Sep
(321) |
Oct
(259) |
Nov
(347) |
Dec
(209) |
2012 |
Jan
(322) |
Feb
(414) |
Mar
(377) |
Apr
(179) |
May
(173) |
Jun
(234) |
Jul
(295) |
Aug
(239) |
Sep
(276) |
Oct
(355) |
Nov
(144) |
Dec
(108) |
2013 |
Jan
(170) |
Feb
(89) |
Mar
(204) |
Apr
(133) |
May
(142) |
Jun
(89) |
Jul
(160) |
Aug
(180) |
Sep
(69) |
Oct
(136) |
Nov
(83) |
Dec
(32) |
2014 |
Jan
(71) |
Feb
(90) |
Mar
(161) |
Apr
(117) |
May
(78) |
Jun
(94) |
Jul
(60) |
Aug
(83) |
Sep
(102) |
Oct
(132) |
Nov
(154) |
Dec
(96) |
2015 |
Jan
(45) |
Feb
(138) |
Mar
(176) |
Apr
(132) |
May
(119) |
Jun
(124) |
Jul
(77) |
Aug
(31) |
Sep
(34) |
Oct
(22) |
Nov
(23) |
Dec
(9) |
2016 |
Jan
(26) |
Feb
(17) |
Mar
(10) |
Apr
(8) |
May
(4) |
Jun
(8) |
Jul
(6) |
Aug
(5) |
Sep
(9) |
Oct
(4) |
Nov
|
Dec
|
2017 |
Jan
(5) |
Feb
(7) |
Mar
(1) |
Apr
(5) |
May
|
Jun
(3) |
Jul
(6) |
Aug
(1) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
|
2018 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2025 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
1
(2) |
2
(5) |
3
(8) |
4
(6) |
5
(9) |
6
(7) |
7
(6) |
8
(10) |
9
(27) |
10
(7) |
11
(22) |
12
(13) |
13
(7) |
14
(4) |
15
(12) |
16
(32) |
17
(26) |
18
(14) |
19
(1) |
20
(11) |
21
(6) |
22
(11) |
23
(17) |
24
(18) |
25
(28) |
26
(11) |
27
(6) |
28
(1) |
29
(10) |
30
(12) |
|
|
|
|
Hi all, the new polar projection gives me a strange behavour by interpolating each simple line between two consecutives points. Where I just want points at specified coordinates and lines connecting them, between each pairs appears a interpolated line in polar projection with multiple points. Looking in the documentation doesn't give an alternative. Is there a way to have just "simples" lines? thanks ################## from pylab import * theta = arange(0, 360, 36) r = [5,1] * (len(theta)/2) polar(radians(theta), r, 'o-') show() ################## -- Lionel Roubeyrie - lro...@li... Chargé d'études et de maintenance LIMAIR - la Surveillance de l'Air en Limousin http://www.limair.asso.fr
Hi, In a previous email I pointed out that I was having problems with pcolormesh output as a PDF: the files are really big and impractical even for smallish arrays (1000x1000 pixels). I don't have that problem using imshow, which presumably resamples the image or somesuch wizardry :) Here's an example import pylab data = pylab.randn((512*512)).reshape((512,512)) #First imshow. I use the dpi keyword "just in case" pylab.imshow ( data, interpolation='nearest') pylab.savefig ("/tmp/imshow_72.pdf",dpi=72) pylab.savefig ("/tmp/imshow.pdf") #Now pcolormesh pylab.pcolormesh ( data ) pylab.savefig ("/tmp/pcolor_72.pdf",dpi=72) pylab.savefig ("/tmp/pcolor.pdf") This results in the following files: 166K /tmp/imshow_72.pdf 307K /tmp/imshow.pdf 2.6M /tmp/pcolor_72.pdf 2.7M /tmp/pcolor.pdf So: in the imshow case, the dpi keyword makes a difference (good!), but if you compare the pcolormesh and imshow filesizes you immediately notice a large difference. The rendering of the pcolor files is also very slow, line-by-line sort of thing. I presume that the different patches are stored as vectors, and that's why there's no change with setting dpi to 300 or to 72. Is this the expected behaviour? Thanks, J
David Goldsmith wrote: > Hi, folks. OK, I'm trying to set the alpha channel, pixel by pixel, using figimage w/ the data being of the "luminance" type (i.e., an MxN array). The Users Guide indicates that figimage takes an alpha= keyword argument, and it doesn't crash when I pass an array for this value, but subsequently when I try to draw it using fig.draw(canvas.get_renderer()), I get: > > >>>> fig.draw(canvas.get_renderer()) >>>> > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File "C:\python25\lib\site-packages\matplotlib\figure.py", line 607, in draw > im.draw(renderer) > File "C:\python25\lib\site-packages\matplotlib\image.py", line 597, in draw > im = self.make_image() > File "C:\python25\lib\site-packages\matplotlib\image.py", line 583, in make_im > age > x = self.to_rgba(self._A, self._alpha) > File "C:\python25\lib\site-packages\matplotlib\cm.py", line 76, in to_rgba > x = self.cmap(x, alpha=alpha, bytes=bytes) > File "C:\python25\lib\site-packages\matplotlib\colors.py", line 423, in __call > __ > alpha = min(alpha, 1.0) # alpha must be between 0 and 1 > ValueError: The truth value of an array with more than one element is ambiguous. > Use a.any() or a.all() > > which to me "smells" as if the array-valued alpha is the problem. > > Clearly (?) I can do what I'm after if I use MxNx4 data, but is that the only way to have a varying alpha? > The alpha parameter always takes only a single (global) value, and the only way to do pixel-by-pixel alpha is an MxNx4 array. It should be fairly straightforward to create this array by concatenating together three copies of the luminance and one copy of your alpha, though. Something like: # lum is MxN, alpha is MxN lum = lum.reshape((M, N, 1)) alpha = alpha.reshape((M, N, 1)) rgba = numpy.concatenate((lum, lum, lum, alpha)) (There might be an even more straightforward way --- I'm not much of a numpy expert...) Cheers Mike -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA
On Tue, Sep 9, 2008 at 9:03 AM, Michael Droettboom <md...@st...> wrote: > You're right: multi-column legends aren't implemented. > > There have been a number of points raised lately around the layout of > legends (such as baseline alignment), that are starting to add up to a > push for a (partial) rewrite of the legend code. Unfortunately, I don't > think anyone has stepped up with time available to work on it. But I > think this should go on the list of things to consider, assuming we can > come up with a nice clean interface to present to the user. It would be > helpful to collect use cases for that. For example, would an option > "numcols" be enough (and the legend would just layout the text in that > number of columns), or would you want/need more control over where > individual elements are placed? > > Of course, we're always looking for new developers, and if you have the > motivation to work on this, I'm sure the various people on this list > would be happy to help you work through it. > > Cheers, > Mike I'd be willing to put some time in on that... I've not ever contributed code for anything though, so I'll be on a learning curve. I've had this problem myself. I would think a number of columns or a number of rows argument either would work.. just restrict based on one or the other, and if both are given... not sure about that one. What's a sensible way to ignore one or the other?
On Tue, Sep 9, 2008 at 2:02 AM, Eric Firing <ef...@ha...> wrote: > Evan Mason wrote: > >> Hi, wonder if anyone can help me with path and bbox. I have a set of >> ocean drifter tracks and I want to know if they pass through a particular >> boxed area. This is straightforward to do but I wanted to try to do it with >> matplotlib.transforms and matplotlib.path, which look well-suited to this >> kind of task using 'intersects_bbox'. >> >> The essence of my code is below. I have a single drifter track (lon, lat) >> and have defined a boxed area. At no time does the drifter approach or >> enter the box - however, the final line, >> >> print track.intersects_bbox(bbox) >> >> returns True, which it shouldn't. In total I have 340 tracks. My code >> says 74 pass though the box, but by counting there should be only about 9. >> Any help appreciated, thanks, Evan >> >> >> import numpy as N >> import numpy.ma <http://numpy.ma> as MA >> import matplotlib.transforms as BB >> import matplotlib.path as PP >> >> In [200]: lon >> Out[200]: >> masked_array(data = [-15.52 -15.521 -15.541 ..., -- -- --], >> mask = [False False False ..., True True True], >> fill_value=1e+20) >> >> In [201]: lat >> Out[201]: >> masked_array(data = [29.2 29.2 29.196 ..., -- -- --], >> mask = [False False False ..., True True True], >> fill_value=1e+20) >> >> In [202]: len(lon), len(lat) >> Out[202]: (3750, 3750) >> >> track = MA.transpose([lon, lat]) >> track = PP.Path(track) >> bbox = BB.Bbox.from_extents(-15.95, 29.6, -15.9, 29.65) >> >> In [206]: print track.intersects_bbox(bbox) >> 1 >> > > Evan, > > Can you strip the problem down more? That is, find one track that is > misdiagnosed, and then try to find the shortest segment of it that still > gets misdiagnosed. You could try subsampling and/or chopping chunks off the > ends. If you can get it down to a track with only a few points, so that you > can email a very short but complete script with illustrative data, that > would make it much easier for someone to figure out what is going on. > > I suspect it is related to the masked values. If you strip the masked > points out of your lon and lat arrays, do you get the same result? > Try making an example with only 3 points, say with the middle one masked, > and then unmasked. > > Eric > Eric, I tried what you say about masked values, and that has helped. However there are still a few tracks that creep through. Below is a short script that shows what I mean. It loads in a matfile with the drifter track, which I will send to you separately. # %run path_example.py import pylab as P import numpy as N from scipy import io from matplotlib.transforms import Bbox as BB import matplotlib.path as PP P.close('all') # Load drifter track (lon, lat) lonlat = io.loadmat('lonlat') lon = N.squeeze(lonlat.values()[1]) lat = N.squeeze(lonlat.values()[0]) # Set up box box = BB.from_extents(-16.6, 28.05, -15.65, 28.15) bx = [box.xmin, box.xmax, box.xmax, box.xmin, box.xmin] by = [box.ymin, box.ymin, box.ymax, box.ymax, box.ymin] track_all = N.transpose([lon, lat]) track_1 = N.transpose([lon[81:295], lat[81:295]]) track_2 = N.transpose([lon[81:290], lat[81:290]]) track_all = PP.Path(track_all) track_1 = PP.Path(track_1) track_2 = PP.Path(track_2) # Test if drifter passes thru box (it doesn't so should be 0) print track_all.intersects_bbox(box), 'Should be 0' print track_1.intersects_bbox(box), 'Should be 0' print track_2.intersects_bbox(box), 'Should be 0' P.figure() P.plot(lon, lat, 'r', lw=0.3) P.plot(lon[81:290], lat[81:290], 'g', lw=0.5) P.plot(bx, by, 'b') P.show()
You're right: multi-column legends aren't implemented. There have been a number of points raised lately around the layout of legends (such as baseline alignment), that are starting to add up to a push for a (partial) rewrite of the legend code. Unfortunately, I don't think anyone has stepped up with time available to work on it. But I think this should go on the list of things to consider, assuming we can come up with a nice clean interface to present to the user. It would be helpful to collect use cases for that. For example, would an option "numcols" be enough (and the legend would just layout the text in that number of columns), or would you want/need more control over where individual elements are placed? Of course, we're always looking for new developers, and if you have the motivation to work on this, I'm sure the various people on this list would be happy to help you work through it. Cheers, Mike Jose Gómez-Dans wrote: > Hi! > About a year ago, Jouni Seppänen indicated how to put a number of patches in a > legend. So far so good. Now, it turns out that I do have quite a lot of > patches to throw into this legend, and it would be nice, rather than to have > a single column, to have the possibility to arrange these patches (and > associated labels) into columns. I have looked at the legend object, but > there is nothing suggesting that things can be shuffled around within the > legend box itself, some sort of "subplot()" for the legend patches. Am I > correct in assuming this doesn't exist (yet!). I am running 0.91.2, maybe > it's already been implemented, but I thought I'd ask! > > Cheers! > J > > > -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA
On Tue, Sep 9, 2008 at 12:40 AM, David Goldsmith <d_l...@ya...> wrote: > Clearly (?) I can do what I'm after if I use MxNx4 data, but is that the only way to have a varying alpha? Yep, currently that is the only way. If you start with luminance, you can use the colormapping code to generate RGB, and then attach an alpha mask for RGBA and pass that to figimage or imshow. JDH
On Tue, Sep 9, 2008 at 7:12 AM, Adam <ada...@gm...> wrote: > This gets rid of the blank space, but at the expense of the aspect ratio, as > you mention. Isn't there away to preserve the aspect ratios of the > individual > sub-images, and just remove the white space between them? I really to not > want to mess with the images themselves. Yes, but you will need to use the "axes" command rather than the "subplot" command, to position the axes where you want them. This will take a little arithmetic, since the axes parameters are fractions of the figure parameters. So you will want to create a figsize and axes that in combination have the right aspect ratio, and issue the axes commands such that there is no space between them. JDH
I just added a test of intersects_bbox to SVN that seems to be working correctly for short paths containing masked values. It would appear that masked values *should* be dealt with correctly (that is, in exactly the same way as they are drawn) by the intersection code. However, there is probably a side case here that I'm missing. As Eric suggests, see if you can break it down into a simple example that fails and hopefully the problem and/or solution will be more obvious from that. Cheers, Mike Eric Firing wrote: > Evan Mason wrote: > >> Hi, wonder if anyone can help me with path and bbox. I have a set of >> ocean drifter tracks and I want to know if they pass through a >> particular boxed area. This is straightforward to do but I wanted to >> try to do it with matplotlib.transforms and matplotlib.path, which look >> well-suited to this kind of task using 'intersects_bbox'. >> >> The essence of my code is below. I have a single drifter track (lon, >> lat) and have defined a boxed area. At no time does the drifter >> approach or enter the box - however, the final line, >> >> print track.intersects_bbox(bbox) >> >> returns True, which it shouldn't. In total I have 340 tracks. My code >> says 74 pass though the box, but by counting there should be only about >> 9. Any help appreciated, thanks, Evan >> >> >> import numpy as N >> import numpy.ma <http://numpy.ma> as MA >> import matplotlib.transforms as BB >> import matplotlib.path as PP >> >> In [200]: lon >> Out[200]: >> masked_array(data = [-15.52 -15.521 -15.541 ..., -- -- --], >> mask = [False False False ..., True True True], >> fill_value=1e+20) >> >> In [201]: lat >> Out[201]: >> masked_array(data = [29.2 29.2 29.196 ..., -- -- --], >> mask = [False False False ..., True True True], >> fill_value=1e+20) >> >> In [202]: len(lon), len(lat) >> Out[202]: (3750, 3750) >> >> track = MA.transpose([lon, lat]) >> track = PP.Path(track) >> bbox = BB.Bbox.from_extents(-15.95, 29.6, -15.9, 29.65) >> >> In [206]: print track.intersects_bbox(bbox) >> 1 >> > > Evan, > > Can you strip the problem down more? That is, find one track that is > misdiagnosed, and then try to find the shortest segment of it that still > gets misdiagnosed. You could try subsampling and/or chopping chunks off > the ends. If you can get it down to a track with only a few points, so > that you can email a very short but complete script with illustrative > data, that would make it much easier for someone to figure out what is > going on. > > I suspect it is related to the masked values. If you strip the masked > points out of your lon and lat arrays, do you get the same result? > Try making an example with only 3 points, say with the middle one > masked, and then unmasked. > > Eric > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA
You can use def ticklabel_format(self, **kwargs): """ Convenience method for manipulating the ScalarFormatter used by default for linear axes. Optional keyword arguments: ======= ===================================== Keyword Description ======= ===================================== *style* [ 'sci' (or 'scientific') | 'plain' ] plain turns off scientific notation *axis* [ 'x' | 'y' | 'both' ] ======= ===================================== Only the major ticks are affected. If the method is called when the :class:`~matplotlib.ticker.ScalarFormatter` is not the :class:`~matplotlib.ticker.Formatter` being used, an :exc:`AttributeError` will be raised with no additional error message. Additional capabilities and/or friendlier error checking may be added. """ anirudh vij wrote: > Hi, > > How can I plot numbers on the x and y axes in scientific notation? > I have very large values on the y axis which I'd like to show as 1e9 > and not 1 followed by 9 zeros. > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > ------------------------------------------------------------------------ > > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA
John, By default, matplotlib will resize your axes to preserve the aspect > ratio of your image, which in the case of your 23x25 images is not > equal. You can override this behavior by setting aspect='auto' > > for i in range(6): > fig1.add_subplot(2,3,i+1) > pylab.imshow(data, aspect='auto') This gets rid of the blank space, but at the expense of the aspect ratio, as you mention. Isn't there away to preserve the aspect ratios of the individual sub-images, and just remove the white space between them? I really to not want to mess with the images themselves. cheers, adam.
On Tue, Sep 9, 2008 at 6:26 AM, Adam <ada...@gm...> wrote: > I thought the desired result could be achieved by the following code, but > there is > still blank space (in the vertical-direction) between the subplots: By default, matplotlib will resize your axes to preserve the aspect ratio of your image, which in the case of your 23x25 images is not equal. You can override this behavior by setting aspect='auto' for i in range(6): fig1.add_subplot(2,3,i+1) pylab.imshow(data, aspect='auto') JDH
Hello, I am trying to plot a 2x3 matrix of (sub)images, with no spacing in between. I thought the desired result could be achieved by the following code, but there is still blank space (in the vertical-direction) between the subplots: #-------------- import pylab from scipy import randn data=randn(575) data.shape=(23,25) fig1 = pylab.figure() for i in range(6): fig1.add_subplot(2,3,i+1) pylab.imshow(data) fig1.subplots_adjust(wspace=0,hspace=0.0) pylab.show() #-------------- I guess I am asking in general the proper way to display an NxM matrix of images with no spaces in between, as the above code is not working. Thank you for the help! -adam.
thanks Eric! Could you provide me with an executive summary as to pcolorfast vs imshow? Is it essentially a matter of speed? Also, I tried to add a colorbar but failed. What is the correct invocation? thanks a gain, Johann Eric Firing wrote: > Johann Cohen-Tanugi wrote: >> thanks Johan, >> I posted to scipy because of histogram2d being in numpy, sorry about >> that. >> Now the stupid question, why can't imshow directly parse histogram2d, >> without the transitory extent object? > > imshow is a general image display function; it would not make sense to > customize it to match histogram2d. > > You may want to use Axes.pcolorfast instead. Example using ipython > -pylab: > > In [1]:import numpy as np > > In [2]:x, y = np.random.randn(2, 100000) > > In [3]:H, xedges, yedges = np.histogram2d(x, y, bins=50) > > In [4]:fig = figure() > > In [5]:ax = fig.add_subplot(111) > > In [6]:ax.pcolorfast? > > In [7]:ax.pcolorfast(xedges, yedges, H) > Out[7]:<matplotlib.image.AxesImage object at 0x8bf0ecc> > > In [8]:draw() > > Eric > >> Anyway, I am happy that there is a simple way as explained below! >> >> thanks again, >> Johann >> >> John Hunter wrote: >>> On Fri, Sep 5, 2008 at 10:36 AM, Johann Cohen-Tanugi >>> <co...@sl...> wrote: >>> >>>> hi, I hope someone can quickly point me to some doc. >>>> I can do imshow(histogram2d(x,y)[0]) but then I miss the x and y >>>> binning >>>> correct labels. >>>> If I do imshow(histogram2d(x,y)) I get: >>>> ERROR: An unexpected error occurred while tokenizing input >>>> The following traceback may be corrupted or invalid >>>> The error message is: ('EOF in multi-line statement', (115, 0)) >>>> >>> matplotlib questions are best addressed to the matplotlib-users >>> mailing list at >>> >>> http://lists.sourceforge.net/mailman/listinfo/matplotlib-users >>> >>> histogram2d returns H, xedges and yedges. The first argument should >>> be passed to imshow, and the second two can be used to get the extents >>> >>> In [26]: x, y = np.random.randn(2, 100000) >>> >>> In [27]: H, xedges, yedges = np.histogram2d(x, y, bins=50) >>> >>> In [28]: extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]] >>> >>> In [29]: imshow(H, extent=extent) >>> Out[29]: <matplotlib.image.AxesImage object at 0x9377bcc> >>>
Hi, folks. OK, I'm trying to set the alpha channel, pixel by pixel, using figimage w/ the data being of the "luminance" type (i.e., an MxN array). The Users Guide indicates that figimage takes an alpha= keyword argument, and it doesn't crash when I pass an array for this value, but subsequently when I try to draw it using fig.draw(canvas.get_renderer()), I get: >>> fig.draw(canvas.get_renderer()) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\python25\lib\site-packages\matplotlib\figure.py", line 607, in draw im.draw(renderer) File "C:\python25\lib\site-packages\matplotlib\image.py", line 597, in draw im = self.make_image() File "C:\python25\lib\site-packages\matplotlib\image.py", line 583, in make_im age x = self.to_rgba(self._A, self._alpha) File "C:\python25\lib\site-packages\matplotlib\cm.py", line 76, in to_rgba x = self.cmap(x, alpha=alpha, bytes=bytes) File "C:\python25\lib\site-packages\matplotlib\colors.py", line 423, in __call __ alpha = min(alpha, 1.0) # alpha must be between 0 and 1 ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() which to me "smells" as if the array-valued alpha is the problem. Clearly (?) I can do what I'm after if I use MxNx4 data, but is that the only way to have a varying alpha? Thanks! DG
Evan Mason wrote: > Hi, wonder if anyone can help me with path and bbox. I have a set of > ocean drifter tracks and I want to know if they pass through a > particular boxed area. This is straightforward to do but I wanted to > try to do it with matplotlib.transforms and matplotlib.path, which look > well-suited to this kind of task using 'intersects_bbox'. > > The essence of my code is below. I have a single drifter track (lon, > lat) and have defined a boxed area. At no time does the drifter > approach or enter the box - however, the final line, > > print track.intersects_bbox(bbox) > > returns True, which it shouldn't. In total I have 340 tracks. My code > says 74 pass though the box, but by counting there should be only about > 9. Any help appreciated, thanks, Evan > > > import numpy as N > import numpy.ma <http://numpy.ma> as MA > import matplotlib.transforms as BB > import matplotlib.path as PP > > In [200]: lon > Out[200]: > masked_array(data = [-15.52 -15.521 -15.541 ..., -- -- --], > mask = [False False False ..., True True True], > fill_value=1e+20) > > In [201]: lat > Out[201]: > masked_array(data = [29.2 29.2 29.196 ..., -- -- --], > mask = [False False False ..., True True True], > fill_value=1e+20) > > In [202]: len(lon), len(lat) > Out[202]: (3750, 3750) > > track = MA.transpose([lon, lat]) > track = PP.Path(track) > bbox = BB.Bbox.from_extents(-15.95, 29.6, -15.9, 29.65) > > In [206]: print track.intersects_bbox(bbox) > 1 Evan, Can you strip the problem down more? That is, find one track that is misdiagnosed, and then try to find the shortest segment of it that still gets misdiagnosed. You could try subsampling and/or chopping chunks off the ends. If you can get it down to a track with only a few points, so that you can email a very short but complete script with illustrative data, that would make it much easier for someone to figure out what is going on. I suspect it is related to the masked values. If you strip the masked points out of your lon and lat arrays, do you get the same result? Try making an example with only 3 points, say with the middle one masked, and then unmasked. Eric
Jose Gomez-Dans wrote: > Jeff, > > On Mon, Sep 8, 2008 at 6:48 PM, Jeff Whitaker <js...@fa... > <mailto:js...@fa...>> wrote: > > Note that to plot the data with pcolor/pcolormesh of contourf, you > don't need to interpolate to a native projection grid. You can > just do > > lons, lats = np.meshgrid(lons,lats) > x,y = m(lons,lats) > im = m.pcolormesh(x,y,datain) > > > OK, I've gone down the pcolormesh route. Results is very nice. > However, if I try to save my file as an EPS or PDF, it takes a long > time, and the resulting PDF is 12Mb (!). The equivalent EPS is of the > order of 500MB (!!!!), and the PNG is around 100kb (!!!!!). I have a > really hard time rendering either the EPS or the PDF, and I guess that > using pcolormesh somehow sticks all the pixels into the resulting > "page". My image size is around 1000x2500 pixels, and I'm not > particularly bothered if it is smoothed for "presentation purposes" > (in fact, I think I can see some aliasing, but don't have the plot in > front of me right now). > > I don't recall this problem when using imshow (no basemap involved). > Is this a pcolormesh "feature" (or converseley, an imshow feature?). > Is there some I can make my plots be as reasonable as other MPL plots > that are mostly vectors rather than rasters? > > Cheers, > J Jose: Basemap has nothing to do with it. I suspect you would see the same PDF and EPS sizes with imshow. I don't know of anyway around it, other than using high-resolution PNG files instead of EPS/PDF. -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449 325 Broadway Boulder, CO, USA 80305-3328
Johann Cohen-Tanugi wrote: > thanks Johan, > I posted to scipy because of histogram2d being in numpy, sorry about that. > Now the stupid question, why can't imshow directly parse histogram2d, > without the transitory extent object? imshow is a general image display function; it would not make sense to customize it to match histogram2d. You may want to use Axes.pcolorfast instead. Example using ipython -pylab: In [1]:import numpy as np In [2]:x, y = np.random.randn(2, 100000) In [3]:H, xedges, yedges = np.histogram2d(x, y, bins=50) In [4]:fig = figure() In [5]:ax = fig.add_subplot(111) In [6]:ax.pcolorfast? In [7]:ax.pcolorfast(xedges, yedges, H) Out[7]:<matplotlib.image.AxesImage object at 0x8bf0ecc> In [8]:draw() Eric > Anyway, I am happy that there is a simple way as explained below! > > thanks again, > Johann > > John Hunter wrote: >> On Fri, Sep 5, 2008 at 10:36 AM, Johann Cohen-Tanugi >> <co...@sl...> wrote: >> >>> hi, I hope someone can quickly point me to some doc. >>> I can do imshow(histogram2d(x,y)[0]) but then I miss the x and y binning >>> correct labels. >>> If I do imshow(histogram2d(x,y)) I get: >>> ERROR: An unexpected error occurred while tokenizing input >>> The following traceback may be corrupted or invalid >>> The error message is: ('EOF in multi-line statement', (115, 0)) >>> >> matplotlib questions are best addressed to the matplotlib-users mailing list at >> >> http://lists.sourceforge.net/mailman/listinfo/matplotlib-users >> >> histogram2d returns H, xedges and yedges. The first argument should >> be passed to imshow, and the second two can be used to get the extents >> >> In [26]: x, y = np.random.randn(2, 100000) >> >> In [27]: H, xedges, yedges = np.histogram2d(x, y, bins=50) >> >> In [28]: extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]] >> >> In [29]: imshow(H, extent=extent) >> Out[29]: <matplotlib.image.AxesImage object at 0x9377bcc> >>
Jeff, On Mon, Sep 8, 2008 at 6:48 PM, Jeff Whitaker <js...@fa...> wrote: > Note that to plot the data with pcolor/pcolormesh of contourf, you don't > need to interpolate to a native projection grid. You can just do > > lons, lats = np.meshgrid(lons,lats) > x,y = m(lons,lats) > im = m.pcolormesh(x,y,datain) OK, I've gone down the pcolormesh route. Results is very nice. However, if I try to save my file as an EPS or PDF, it takes a long time, and the resulting PDF is 12Mb (!). The equivalent EPS is of the order of 500MB (!!!!), and the PNG is around 100kb (!!!!!). I have a really hard time rendering either the EPS or the PDF, and I guess that using pcolormesh somehow sticks all the pixels into the resulting "page". My image size is around 1000x2500 pixels, and I'm not particularly bothered if it is smoothed for "presentation purposes" (in fact, I think I can see some aliasing, but don't have the plot in front of me right now). I don't recall this problem when using imshow (no basemap involved). Is this a pcolormesh "feature" (or converseley, an imshow feature?). Is there some I can make my plots be as reasonable as other MPL plots that are mostly vectors rather than rasters? Cheers, J -- Centre for Terrestrial Carbon Dynamics Department of Geography, University College London Gower Street, London WC1E 6BT, UK
Hi Guys, how can I set the size of a plot window by, let's say, 320 x 180 and make it fix, that is, something like "resize=False". I had a look at the documentation but I couldn't figure out which object and method I have to use for this. Thanks in advance! Bernardo M. Rocha
Hi all, Michael's solution worked like a charm. Thanks to all for your valuable input! Rgs. >>> Michael Droettboom <md...@st...> 09/05/08 7:54 PM >>> You could do something like: def bitget(value, bit_number): return (value & (1 << bit_number)) != 0 which will return True or False for the given bit number, and this function works on numpy arrays. (Bits are numbered base-0 -- I don't know if that matches matlab). Hope that helps, Mike Marjolaine Rouault wrote: > Hi, > > I was wondering if python has the equivalent of the matlab bitget.m function. > > I have a large 2 dimensional variable of type uint32 which I must convert to binaries and then find if bit 23 of the binary for each point is 0 or 1. The matlab bitget function is ideal for that but I can't find much in python. The only thing I found was binary_repr which converts to a sting and can only be used for 1 point at a time. > > Any suggestions? > > Thanks, Marjolaine. > > -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA -- This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html. This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. MailScanner thanks Transtec Computers for their support.
Hi! About a year ago, Jouni Seppänen indicated how to put a number of patches in a legend. So far so good. Now, it turns out that I do have quite a lot of patches to throw into this legend, and it would be nice, rather than to have a single column, to have the possibility to arrange these patches (and associated labels) into columns. I have looked at the legend object, but there is nothing suggesting that things can be shuffled around within the legend box itself, some sort of "subplot()" for the legend patches. Am I correct in assuming this doesn't exist (yet!). I am running 0.91.2, maybe it's already been implemented, but I thought I'd ask! Cheers! J -- NERC Centre for Terrestrial Carbon Dynamics, Department of Geography, University College London Gower Street, London WC1E 6BT, UK
Jose Gómez-Dans wrote: > Hi, > I am starting to play with Basemap. I have some raster data in > longitude/latitude (WGS-84, EPSG: 4326). I would like to plot it using > imshow, and to then plot some country boundaries and so on and so forth. I > have studied the plotprecip.py example in Basemap's distribution, but as far > as i can tell, there's no reprojection of the data there (i.e., the data is > already in whatever projection Basemap was initiated with). While I can > reproject the data outside of MPL, I was wondering whether I'm missing > something, and I can just reproject my data and call imshow within my python > script. > > Cheers, > J > > > > Jose: If you data is on a lat/lon grid, you can plot it directly with Basemap with projection='cyl'. If you want to plot it on some other projection, you can reproject the data with Basemap quite easily. The test.py script in the examples directory shows how to reproject lat/lon data and plot with imshow for each of the map projections Basemap supports. The basic recipe is this: import numpy as np import matplotlib.pyplot as plt # transform to nx x ny regularly spaced 40km native projection grid nx = int((m.xmax-m.xmin)/40000.)+1; ny = int((m.ymax-m.ymin)/40000.)+1 # datain is input data on lat/lon grid described by 1d arrays lons, lats # (longitudes and latitudes in degrees). topodat = m.transform_scalar(datain,lons,lats,nx,ny) # plot image over map with imshow. m is a Basemap instance defining the projection # you want to plot on. im = m.imshow(topodat,plt.cm.jet) Note that to plot the data with pcolor/pcolormesh of contourf, you don't need to interpolate to a native projection grid. You can just do lons, lats = np.meshgrid(lons,lats) x,y = m(lons,lats) im = m.pcolormesh(x,y,datain) -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/PSD R/PSD1 Email : Jef...@no... 325 Broadway Office : Skaggs Research Cntr 1D-113 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
Hi, wonder if anyone can help me with path and bbox. I have a set of ocean drifter tracks and I want to know if they pass through a particular boxed area. This is straightforward to do but I wanted to try to do it with matplotlib.transforms and matplotlib.path, which look well-suited to this kind of task using 'intersects_bbox'. The essence of my code is below. I have a single drifter track (lon, lat) and have defined a boxed area. At no time does the drifter approach or enter the box - however, the final line, print track.intersects_bbox(bbox) returns True, which it shouldn't. In total I have 340 tracks. My code says 74 pass though the box, but by counting there should be only about 9. Any help appreciated, thanks, Evan import numpy as N import numpy.ma as MA import matplotlib.transforms as BB import matplotlib.path as PP In [200]: lon Out[200]: masked_array(data = [-15.52 -15.521 -15.541 ..., -- -- --], mask = [False False False ..., True True True], fill_value=1e+20) In [201]: lat Out[201]: masked_array(data = [29.2 29.2 29.196 ..., -- -- --], mask = [False False False ..., True True True], fill_value=1e+20) In [202]: len(lon), len(lat) Out[202]: (3750, 3750) track = MA.transpose([lon, lat]) track = PP.Path(track) bbox = BB.Bbox.from_extents(-15.95, 29.6, -15.9, 29.65) In [206]: print track.intersects_bbox(bbox) 1
Hi, I am starting to play with Basemap. I have some raster data in longitude/latitude (WGS-84, EPSG: 4326). I would like to plot it using imshow, and to then plot some country boundaries and so on and so forth. I have studied the plotprecip.py example in Basemap's distribution, but as far as i can tell, there's no reprojection of the data there (i.e., the data is already in whatever projection Basemap was initiated with). While I can reproject the data outside of MPL, I was wondering whether I'm missing something, and I can just reproject my data and call imshow within my python script. Cheers, J -- NERC Centre for Terrestrial Carbon Dynamics, Department of Geography, University College London Gower Street, London WC1E 6BT, UK