SourceForge logo
SourceForge logo
Menu

matplotlib-users — Discussion related to using matplotlib

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
(7)
2
(5)
3
(18)
4
(9)
5
(13)
6
(14)
7
(8)
8
(7)
9
(6)
10
(6)
11
(24)
12
(14)
13
(9)
14
(21)
15
(6)
16
(1)
17
(20)
18
(42)
19
(16)
20
(21)
21
(41)
22
(13)
23
(11)
24
(15)
25
(32)
26
(27)
27
(29)
28
(10)
29
(3)
30
(1)
31
(5)





Showing 14 results of 14

From: Tommy G. <tg...@ma...> - 2008年03月06日 18:42:10
I have an array of 0s and 1s and plot it with imshow. Is there a way to
set the 0 part only to have a transparency (alpha)?
Cheers
 Tommy
From: Jeff W. <js...@fa...> - 2008年03月06日 18:27:38
Stephane Raynaud wrote:
> On Thu, Mar 6, 2008 at 6:15 PM, Jeff Whitaker <js...@fa...> wrote:
> 
>> Stephane Raynaud wrote:
>> > Hi,
>> >
>> > this scalebar is a really good idea!
>> >
>> > However, I suggest that all parameters must be optional:
>> > - The position could be by default somewhere in the lower left corner
>> > (for example). It may be interesting to find a "best" position using
>> > the algo of legend.
>> > - Then length could be estimated from automatically from the map coordinates.
>> >
>> >
>> >
>> Stephane: While I agree it would be nice to be able to just say 'give
>> me a scalebar', I don't think having Basemap choose a default location
>> and size would be very useful. You want the scalebar to be where there
>> is nothing else drawn on the map, and this will be different in every
>> case.
>> 
>
> Sure, but the algorithm used by legend tries to put the legend where
> there is nothing drawn.
>
>
> 
>> Plus, you probably want the length to be a nice round number, not
>> an arbitrary fraction of the map domain.
>> 
>
> I was not thinking about a simple fraction, but a nice length taken
> within values derived from a Locator scaled by a fraction on the map
> domain.
>
> 
Stephane: Sounds reasonable, but I don't have time to work on this 
now. Patches are always welcome! (including your caching module)
-Jeff
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328
From: Stephane R. <ste...@gm...> - 2008年03月06日 18:05:01
On Thu, Mar 6, 2008 at 6:15 PM, Jeff Whitaker <js...@fa...> wrote:
> Stephane Raynaud wrote:
> > Hi,
> >
> > this scalebar is a really good idea!
> >
> > However, I suggest that all parameters must be optional:
> > - The position could be by default somewhere in the lower left corner
> > (for example). It may be interesting to find a "best" position using
> > the algo of legend.
> > - Then length could be estimated from automatically from the map coordinates.
> >
> >
> >
> Stephane: While I agree it would be nice to be able to just say 'give
> me a scalebar', I don't think having Basemap choose a default location
> and size would be very useful. You want the scalebar to be where there
> is nothing else drawn on the map, and this will be different in every
> case.
Sure, but the algorithm used by legend tries to put the legend where
there is nothing drawn.
> Plus, you probably want the length to be a nice round number, not
> an arbitrary fraction of the map domain.
I was not thinking about a simple fraction, but a nice length taken
within values derived from a Locator scaled by a fraction on the map
domain.
>
> -Jeff
>
>
> > On Tue, Mar 4, 2008 at 3:47 PM, Michael Hearne <mh...@us...> wrote:
> >
> >> Jeff - I think the way GMT does it would be okay - they have a latitude of
> >> true scale, which I usually choose as the center latitude of the map.
> >>
> >> I was thinking we should allow people to choose the "simple" or "fancy"
> >> options. Do you think it will be okay to have the height of the bar and the
> >> text offset be relative to the length of it? I suppose if the height
> >> becomes a problem, people could use the yoffset keyword...
> >>
> >> --Mike
> >>
> >>
> >> On Mar 4, 2008, at 6:05 AM, Jeff Whitaker wrote:
> >>
> >> Michael Hearne wrote:
> >> Jeff - That would replicate the "simple" scale-bar from GMT. Below is my
> >> not-complete attempt at replicating the "fancy" scale bar. It would need
> >> some options for specifying different units (miles, nautical miles, etc.)
> >> and perhaps some more attention to spacing of the text from the scale bar
> >> and tick marks...
> >>
> >> --Mike
> >>
> >> Mike: Very nice! Do you want the scale to show the true distance on the
> >> earth (in which case the labels will vary depending on where the label is
> >> placed), or the distance in map projection coordinates (in which case the
> >> labels are constant)? Or perhaps a lat/lon value could be given to specify
> >> where the scale is true?
> >>
> >> -Jeff
> >>
> >> from numpy import *
> >> from matplotlib.toolkits.basemap import Basemap, pyproj
> >> from pylab import *
> >> # add drawscale method to Basemap class.
> >> class Basemap2(Basemap):
> >> def drawscale(self,lon,lat,length,yoffset=None):
> >> """draw a fancy map scale from lon-length/2,lat-yoffset to
> >> lon-length/2,lat-yoffset, label it with actual distance in km"""
> >> length = length*1000 #input length is km
> >>
> >> #we need 5 sets of x coordinates (in map units)
> >> #center of scale
> >> xc,yc = self(lon,lat)
> >> #left edge of scale
> >> lon1,lat1 = self(xc-length/2,yc,inverse=True)
> >> x1,y1 = self(lon1,lat1)
> >> #quarter scale
> >> lon2,lat2 = self(xc-length/4,yc,inverse=True)
> >> x2,y2 = self(lon2,lat2)
> >> #three quarter scale
> >> lon3,lat3 = self(xc+length/4,yc,inverse=True)
> >> x3,y3 = self(lon3,lat3)
> >> #right edge of scale
> >> lon4,lat4 = self(xc+length/2,yc,inverse=True)
> >> x4,y4 = self(lon4,lat4)
> >> if yoffset is None: yoffset = 0.1*length
> >>
> >> #plot top line
> >> ytop = yc+yoffset/2
> >> ybottom = yc-yoffset/2
> >> ytick = ybottom - yoffset/2
> >> ytext = ytick - yoffset/2
> >> m.plot([x1,x4],[ytop,ytop],color='k')
> >> #plot bottom line
> >> m.plot([x1,x4],[ybottom,ybottom],color='k')
> >> #plot left edge
> >> m.plot([x1,x1],[ybottom,ytop],color='k')
> >> #plot right edge
> >> m.plot([x4,x4],[ybottom,ytop],color='k')
> >>
> >> #make a filled black box from left edge to 1/4 way across
> >> fill([x1,x2,x2,x1,x1],[ytop,ytop,ybottom,ybottom,ytop],'k')
> >> #make a filled white box from 1/4 way across to 1/2 way across
> >> fill([x2,xc,xc,x2,x2],[ytop,ytop,ybottom,ybottom,ytop],'w')
> >> #make a filled white box from 1/2 way across to 3/4 way across
> >> fill([xc,x3,x3,xc,xc],[ytop,ytop,ybottom,ybottom,ytop],'k')
> >> #make a filled white box from 3/4 way across to end
> >> fill([x3,x4,x4,x3,x3],[ytop,ytop,ybottom,ybottom,ytop],'w')
> >> #plot 3 tick marks at left edge, center, and right edge
> >> m.plot([x1,x1],[ytick,ybottom],color='k')
> >> m.plot([xc,xc],[ytick,ybottom],color='k')
> >> m.plot([x4,x4],[ytick,ybottom],color='k')
> >>
> >> #label 3 tick marks
> >> text(x1,ytext,'%d' % (0),\
> >> horizontalalignment='center',\
> >> verticalalignment='top',\
> >> fontsize=9)
> >> text(xc,ytext,'%d' % (round((length/2)/1000)),\
> >> horizontalalignment='center',\
> >> verticalalignment='top',\
> >> fontsize=9)
> >> text(x4,ytext,'%d' % (round((length)/1000)),\
> >> horizontalalignment='center',\
> >> verticalalignment='top',\
> >> fontsize=9)
> >>
> >> #put units on top
> >> text(xc,ytop+yoffset/2,'km',\
> >> horizontalalignment='center',\
> >> verticalalignment='bottom',\
> >> fontsize=9)
> >>
> >> # setup of basemap ('lcc' = lambert conformal conic).
> >> # use major and minor sphere radii from WGS84 ellipsoid.
> >> m =
> >> Basemap2(llcrnrlon=-145.5,llcrnrlat=1.,urcrnrlon=-2.566,urcrnrlat=46.352,\
> >> rsphere=(6378137.00,6356752.3142),\
> >> resolution='l',area_thresh=1000.,projection='lcc',\
> >> lat_1=50.,lon_0=-107.)
> >> # draw coastlines and political boundaries.
> >> m.drawcoastlines()
> >> m.fillcontinents()
> >> # draw parallels and meridians.
> >> # label on left, right and bottom of map.
> >> m.drawparallels(arange(0.,80,20.),labels=[1,1,0,1])
> >> m.drawmeridians(arange(10.,360.,30.),labels=[1,1,0,1])
> >> # draw a line from x1,y to x2,y and label it with distance in km.
> >> length = 3000 #kilometers
> >> x1,y1 = 0.25*m.xmax, 0.25*m.ymax
> >> lon1,lat1 = m(x1,y1,inverse=True)
> >> m.drawscale(lon1,lat1,length)
> >> title('a fancy map scale')
> >> show()
> >>
> >>
> >>
> >>
> >> ------------------------------------------------------
> >> Michael Hearne
> >> mh...@us... <mailto:mh...@us...>
> >> (303) 273-8620
> >> USGS National Earthquake Information Center
> >> 1711 Illinois St. Golden CO 80401
> >> Senior Software Engineer
> >> Synergetics, Inc.
> >> ------------------------------------------------------
> >>
> >>
> >>
> >>
> >>
> >> --
> >> Jeffrey S. Whitaker Phone : (303)497-6313
> >> NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
> >> 325 Broadway Boulder, CO, USA 80305-3328
> >>
> >>
> >>
> >>
> >>
> >> ------------------------------------------------------
> >> Michael Hearne
> >> mh...@us...
> >> (303) 273-8620
> >> USGS National Earthquake Information Center
> >> 1711 Illinois St. Golden CO 80401
> >> Senior Software Engineer
> >> Synergetics, Inc.
> >> ------------------------------------------------------
> >>
> >>
> >> -------------------------------------------------------------------------
> >> This SF.net email is sponsored by: Microsoft
> >> Defy all challenges. Microsoft(R) Visual Studio 2008.
> >> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> >> _______________________________________________
> >> Matplotlib-users mailing list
> >> Mat...@li...
> >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >>
> >>
> >>
> >
> >
> >
> >
>
>
> --
> Jeffrey S. Whitaker Phone : (303)497-6313
> NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
> 325 Broadway Boulder, CO, USA 80305-3328
>
>
-- 
Stephane Raynaud
From: Kevin C. <kch...@ya...> - 2008年03月06日 17:18:56
When errorbar() and legend(loc='best') are used an error message appears. But other legend locations (e.g. 'upper left' or 'upper right') work fine.
 pylab.figure()
 pylab.errorbar(xdata,ydata,z*y_standardError,fmt='o-',label='test') 
 pylab.legend(loc='best')
 pylab.show()
Exception in Tkinter callback
Traceback (most recent call last):
 File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__
 return self.func(*args)
 File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_tkagg.py", line 188, in resize
 self.show()
 File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_tkagg.py", line 191, in draw
 FigureCanvasAgg.draw(self)
 File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_agg.py", line 358, in draw
 self.figure.draw(self.renderer)
 File "C:\Python25\Lib\site-packages\matplotlib\figure.py", line 624, in draw
 for a in self.axes: a.draw(renderer)
 File "C:\Python25\Lib\site-packages\matplotlib\axes.py", line 1345, in draw
 a.draw(renderer)
 File "C:\Python25\Lib\site-packages\matplotlib\legend.py", line 236, in draw
 self._update_positions(renderer)
 File "C:\Python25\Lib\site-packages\matplotlib\legend.py", line 579, in _update_positions
 ox, oy = self._find_best_position(w, h)
 File "C:\Python25\Lib\site-packages\matplotlib\legend.py", line 463, in _find_best_position
 verts, bboxes, lines = self._auto_legend_data()
 File "C:\Python25\Lib\site-packages\matplotlib\legend.py", line 378, in _auto_legend_data
 hlines = handle.get_lines()
AttributeError: LineCollection instance has no attribute 'get_lines'
 ____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page. 
http://www.yahoo.com/r/hs 
From: Jeff W. <js...@fa...> - 2008年03月06日 17:16:48
Stephane Raynaud wrote:
> Hi,
>
> this scalebar is a really good idea!
>
> However, I suggest that all parameters must be optional:
> - The position could be by default somewhere in the lower left corner
> (for example). It may be interesting to find a "best" position using
> the algo of legend.
> - Then length could be estimated from automatically from the map coordinates.
>
>
> 
Stephane: While I agree it would be nice to be able to just say 'give 
me a scalebar', I don't think having Basemap choose a default location 
and size would be very useful. You want the scalebar to be where there 
is nothing else drawn on the map, and this will be different in every 
case. Plus, you probably want the length to be a nice round number, not 
an arbitrary fraction of the map domain.
-Jeff
> On Tue, Mar 4, 2008 at 3:47 PM, Michael Hearne <mh...@us...> wrote:
> 
>> Jeff - I think the way GMT does it would be okay - they have a latitude of
>> true scale, which I usually choose as the center latitude of the map.
>>
>> I was thinking we should allow people to choose the "simple" or "fancy"
>> options. Do you think it will be okay to have the height of the bar and the
>> text offset be relative to the length of it? I suppose if the height
>> becomes a problem, people could use the yoffset keyword...
>>
>> --Mike
>>
>>
>> On Mar 4, 2008, at 6:05 AM, Jeff Whitaker wrote:
>>
>> Michael Hearne wrote:
>> Jeff - That would replicate the "simple" scale-bar from GMT. Below is my
>> not-complete attempt at replicating the "fancy" scale bar. It would need
>> some options for specifying different units (miles, nautical miles, etc.)
>> and perhaps some more attention to spacing of the text from the scale bar
>> and tick marks...
>>
>> --Mike
>>
>> Mike: Very nice! Do you want the scale to show the true distance on the
>> earth (in which case the labels will vary depending on where the label is
>> placed), or the distance in map projection coordinates (in which case the
>> labels are constant)? Or perhaps a lat/lon value could be given to specify
>> where the scale is true?
>>
>> -Jeff
>>
>> from numpy import *
>> from matplotlib.toolkits.basemap import Basemap, pyproj
>> from pylab import *
>> # add drawscale method to Basemap class.
>> class Basemap2(Basemap):
>> def drawscale(self,lon,lat,length,yoffset=None):
>> """draw a fancy map scale from lon-length/2,lat-yoffset to
>> lon-length/2,lat-yoffset, label it with actual distance in km"""
>> length = length*1000 #input length is km
>>
>> #we need 5 sets of x coordinates (in map units)
>> #center of scale
>> xc,yc = self(lon,lat)
>> #left edge of scale
>> lon1,lat1 = self(xc-length/2,yc,inverse=True)
>> x1,y1 = self(lon1,lat1)
>> #quarter scale
>> lon2,lat2 = self(xc-length/4,yc,inverse=True)
>> x2,y2 = self(lon2,lat2)
>> #three quarter scale
>> lon3,lat3 = self(xc+length/4,yc,inverse=True)
>> x3,y3 = self(lon3,lat3)
>> #right edge of scale
>> lon4,lat4 = self(xc+length/2,yc,inverse=True)
>> x4,y4 = self(lon4,lat4)
>> if yoffset is None: yoffset = 0.1*length
>>
>> #plot top line
>> ytop = yc+yoffset/2
>> ybottom = yc-yoffset/2
>> ytick = ybottom - yoffset/2
>> ytext = ytick - yoffset/2
>> m.plot([x1,x4],[ytop,ytop],color='k')
>> #plot bottom line
>> m.plot([x1,x4],[ybottom,ybottom],color='k')
>> #plot left edge
>> m.plot([x1,x1],[ybottom,ytop],color='k')
>> #plot right edge
>> m.plot([x4,x4],[ybottom,ytop],color='k')
>>
>> #make a filled black box from left edge to 1/4 way across
>> fill([x1,x2,x2,x1,x1],[ytop,ytop,ybottom,ybottom,ytop],'k')
>> #make a filled white box from 1/4 way across to 1/2 way across
>> fill([x2,xc,xc,x2,x2],[ytop,ytop,ybottom,ybottom,ytop],'w')
>> #make a filled white box from 1/2 way across to 3/4 way across
>> fill([xc,x3,x3,xc,xc],[ytop,ytop,ybottom,ybottom,ytop],'k')
>> #make a filled white box from 3/4 way across to end
>> fill([x3,x4,x4,x3,x3],[ytop,ytop,ybottom,ybottom,ytop],'w')
>> #plot 3 tick marks at left edge, center, and right edge
>> m.plot([x1,x1],[ytick,ybottom],color='k')
>> m.plot([xc,xc],[ytick,ybottom],color='k')
>> m.plot([x4,x4],[ytick,ybottom],color='k')
>>
>> #label 3 tick marks
>> text(x1,ytext,'%d' % (0),\
>> horizontalalignment='center',\
>> verticalalignment='top',\
>> fontsize=9)
>> text(xc,ytext,'%d' % (round((length/2)/1000)),\
>> horizontalalignment='center',\
>> verticalalignment='top',\
>> fontsize=9)
>> text(x4,ytext,'%d' % (round((length)/1000)),\
>> horizontalalignment='center',\
>> verticalalignment='top',\
>> fontsize=9)
>>
>> #put units on top
>> text(xc,ytop+yoffset/2,'km',\
>> horizontalalignment='center',\
>> verticalalignment='bottom',\
>> fontsize=9)
>>
>> # setup of basemap ('lcc' = lambert conformal conic).
>> # use major and minor sphere radii from WGS84 ellipsoid.
>> m =
>> Basemap2(llcrnrlon=-145.5,llcrnrlat=1.,urcrnrlon=-2.566,urcrnrlat=46.352,\
>> rsphere=(6378137.00,6356752.3142),\
>> resolution='l',area_thresh=1000.,projection='lcc',\
>> lat_1=50.,lon_0=-107.)
>> # draw coastlines and political boundaries.
>> m.drawcoastlines()
>> m.fillcontinents()
>> # draw parallels and meridians.
>> # label on left, right and bottom of map.
>> m.drawparallels(arange(0.,80,20.),labels=[1,1,0,1])
>> m.drawmeridians(arange(10.,360.,30.),labels=[1,1,0,1])
>> # draw a line from x1,y to x2,y and label it with distance in km.
>> length = 3000 #kilometers
>> x1,y1 = 0.25*m.xmax, 0.25*m.ymax
>> lon1,lat1 = m(x1,y1,inverse=True)
>> m.drawscale(lon1,lat1,length)
>> title('a fancy map scale')
>> show()
>>
>>
>>
>>
>> ------------------------------------------------------
>> Michael Hearne
>> mh...@us... <mailto:mh...@us...>
>> (303) 273-8620
>> USGS National Earthquake Information Center
>> 1711 Illinois St. Golden CO 80401
>> Senior Software Engineer
>> Synergetics, Inc.
>> ------------------------------------------------------
>>
>>
>>
>>
>>
>> --
>> Jeffrey S. Whitaker Phone : (303)497-6313
>> NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
>> 325 Broadway Boulder, CO, USA 80305-3328
>>
>>
>>
>>
>>
>> ------------------------------------------------------
>> Michael Hearne
>> mh...@us...
>> (303) 273-8620
>> USGS National Earthquake Information Center
>> 1711 Illinois St. Golden CO 80401
>> Senior Software Engineer
>> Synergetics, Inc.
>> ------------------------------------------------------
>>
>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by: Microsoft
>> Defy all challenges. Microsoft(R) Visual Studio 2008.
>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>> 
>
>
>
> 
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328
From: Jeff W. <js...@fa...> - 2008年03月06日 17:06:00
Tommy Grav wrote:
> Thanks for pointing this function out. I thought I had look for it, 
> but must have overlooked it.
>
> I am using the test code below, but the array is plotted outside the 
> boundary of the map. Is there
> a way to avoid this?
>
> Cheers
> Tommy
>
> from math import *
> from matplotlib.toolkits.basemap import Basemap
> import pylab
> import numpy
>
> rabins = numpy.arange(0.,360.,6)
> decbins = numpy.arange(-90.,90.,6)
> map = Basemap(projection="sinu",lat_0=0.,lon_0=180.,rsphere=1.)
>
> coverage = numpy.zeros([len(decbins),len(rabins)],"int")
>
> coverage[0:5,:] = 2
> coverage[5:10,:] = 4
>
>
> map.imshow(coverage,interpolation="nearest",cmap=pylab.cm.hot_r)
> map.drawmapboundary()
>
> pylab.show()
>
>
>
>
> On Mar 6, 2008, at 11:10 AM, Jeff Whitaker wrote:
>
> 
>> Tommy Grav wrote:
>> 
>>> Is there a way of using imshow together with a basemap?
>>>
>>> Cheers
>>> Tommy
>>>
>>> 
>> Tommy:
>>
>> Use the imshow basemap method, just as you would the pylab version.
>>
>> -Jeff
>>
>> 
Tommy: You're using a non-rectangular map projection, so imshow won't 
work. Try pcolor or pcolormesh instead, i.e. replace map.imshow with:
rabins, decbins = numpy.meshgrid(rabins, decbins)
x,y = map(rabins,decbins)
map.pcolor(x,y,coverage,cmap=pylab.cm.hot_r)
-Jeff
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328
From: Tommy G. <tg...@ma...> - 2008年03月06日 16:49:42
Thanks for pointing this function out. I thought I had look for it, 
but must have overlooked it.
I am using the test code below, but the array is plotted outside the 
boundary of the map. Is there
a way to avoid this?
Cheers
 Tommy
from math import *
from matplotlib.toolkits.basemap import Basemap
import pylab
import numpy
rabins = numpy.arange(0.,360.,6)
decbins = numpy.arange(-90.,90.,6)
map = Basemap(projection="sinu",lat_0=0.,lon_0=180.,rsphere=1.)
coverage = numpy.zeros([len(decbins),len(rabins)],"int")
coverage[0:5,:] = 2
coverage[5:10,:] = 4
map.imshow(coverage,interpolation="nearest",cmap=pylab.cm.hot_r)
map.drawmapboundary()
pylab.show()
On Mar 6, 2008, at 11:10 AM, Jeff Whitaker wrote:
> Tommy Grav wrote:
>> Is there a way of using imshow together with a basemap?
>>
>> Cheers
>> Tommy
>>
> Tommy:
>
> Use the imshow basemap method, just as you would the pylab version.
>
> -Jeff
>
> -- 
> Jeffrey S. Whitaker Phone : (303)497-6313
> NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
> 325 Broadway Boulder, CO, USA 80305-3328
>
From: Jeff W. <js...@fa...> - 2008年03月06日 16:17:27
Stephane Raynaud wrote:
> Hi
>
> Jeff: how about introducing a cache system for Basemap objects?
>
> You recently gave me the idea of using cPickle on Basemap objects, so
> I implement a very simple cache system that try to check if map has
> already been serialized and dumped to a cache file, before trying to
> create it from scratch. Checking is performed on file name which
> contains bounds and resolution of the map.
>
> Do you think that it can be managed directly (and in a better way) in
> Basemap(), let's say using the cache keyword set to False by default?
> A cache directory in ~/.matplotlib/basemap can be used for that.
>
>
> 
Stephane: I think this is best left in a separate module, since most 
people would not want the overhead incurred. 
-Jeff
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328
From: Jeff W. <js...@fa...> - 2008年03月06日 16:11:22
Tommy Grav wrote:
> Is there a way of using imshow together with a basemap?
>
> Cheers
> Tommy
> 
Tommy:
Use the imshow basemap method, just as you would the pylab version.
-Jeff
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328
From: Tommy G. <tg...@ma...> - 2008年03月06日 16:03:03
Is there a way of using imshow together with a basemap?
Cheers
 Tommy
From: Stephane R. <ste...@gm...> - 2008年03月06日 15:42:19
Hi,
this scalebar is a really good idea!
However, I suggest that all parameters must be optional:
- The position could be by default somewhere in the lower left corner
(for example). It may be interesting to find a "best" position using
the algo of legend.
- Then length could be estimated from automatically from the map coordinates.
On Tue, Mar 4, 2008 at 3:47 PM, Michael Hearne <mh...@us...> wrote:
> Jeff - I think the way GMT does it would be okay - they have a latitude of
> true scale, which I usually choose as the center latitude of the map.
>
> I was thinking we should allow people to choose the "simple" or "fancy"
> options. Do you think it will be okay to have the height of the bar and the
> text offset be relative to the length of it? I suppose if the height
> becomes a problem, people could use the yoffset keyword...
>
> --Mike
>
>
> On Mar 4, 2008, at 6:05 AM, Jeff Whitaker wrote:
>
> Michael Hearne wrote:
> Jeff - That would replicate the "simple" scale-bar from GMT. Below is my
> not-complete attempt at replicating the "fancy" scale bar. It would need
> some options for specifying different units (miles, nautical miles, etc.)
> and perhaps some more attention to spacing of the text from the scale bar
> and tick marks...
>
> --Mike
>
> Mike: Very nice! Do you want the scale to show the true distance on the
> earth (in which case the labels will vary depending on where the label is
> placed), or the distance in map projection coordinates (in which case the
> labels are constant)? Or perhaps a lat/lon value could be given to specify
> where the scale is true?
>
> -Jeff
>
> from numpy import *
> from matplotlib.toolkits.basemap import Basemap, pyproj
> from pylab import *
> # add drawscale method to Basemap class.
> class Basemap2(Basemap):
> def drawscale(self,lon,lat,length,yoffset=None):
> """draw a fancy map scale from lon-length/2,lat-yoffset to
> lon-length/2,lat-yoffset, label it with actual distance in km"""
> length = length*1000 #input length is km
>
> #we need 5 sets of x coordinates (in map units)
> #center of scale
> xc,yc = self(lon,lat)
> #left edge of scale
> lon1,lat1 = self(xc-length/2,yc,inverse=True)
> x1,y1 = self(lon1,lat1)
> #quarter scale
> lon2,lat2 = self(xc-length/4,yc,inverse=True)
> x2,y2 = self(lon2,lat2)
> #three quarter scale
> lon3,lat3 = self(xc+length/4,yc,inverse=True)
> x3,y3 = self(lon3,lat3)
> #right edge of scale
> lon4,lat4 = self(xc+length/2,yc,inverse=True)
> x4,y4 = self(lon4,lat4)
> if yoffset is None: yoffset = 0.1*length
>
> #plot top line
> ytop = yc+yoffset/2
> ybottom = yc-yoffset/2
> ytick = ybottom - yoffset/2
> ytext = ytick - yoffset/2
> m.plot([x1,x4],[ytop,ytop],color='k')
> #plot bottom line
> m.plot([x1,x4],[ybottom,ybottom],color='k')
> #plot left edge
> m.plot([x1,x1],[ybottom,ytop],color='k')
> #plot right edge
> m.plot([x4,x4],[ybottom,ytop],color='k')
>
> #make a filled black box from left edge to 1/4 way across
> fill([x1,x2,x2,x1,x1],[ytop,ytop,ybottom,ybottom,ytop],'k')
> #make a filled white box from 1/4 way across to 1/2 way across
> fill([x2,xc,xc,x2,x2],[ytop,ytop,ybottom,ybottom,ytop],'w')
> #make a filled white box from 1/2 way across to 3/4 way across
> fill([xc,x3,x3,xc,xc],[ytop,ytop,ybottom,ybottom,ytop],'k')
> #make a filled white box from 3/4 way across to end
> fill([x3,x4,x4,x3,x3],[ytop,ytop,ybottom,ybottom,ytop],'w')
> #plot 3 tick marks at left edge, center, and right edge
> m.plot([x1,x1],[ytick,ybottom],color='k')
> m.plot([xc,xc],[ytick,ybottom],color='k')
> m.plot([x4,x4],[ytick,ybottom],color='k')
>
> #label 3 tick marks
> text(x1,ytext,'%d' % (0),\
> horizontalalignment='center',\
> verticalalignment='top',\
> fontsize=9)
> text(xc,ytext,'%d' % (round((length/2)/1000)),\
> horizontalalignment='center',\
> verticalalignment='top',\
> fontsize=9)
> text(x4,ytext,'%d' % (round((length)/1000)),\
> horizontalalignment='center',\
> verticalalignment='top',\
> fontsize=9)
>
> #put units on top
> text(xc,ytop+yoffset/2,'km',\
> horizontalalignment='center',\
> verticalalignment='bottom',\
> fontsize=9)
>
> # setup of basemap ('lcc' = lambert conformal conic).
> # use major and minor sphere radii from WGS84 ellipsoid.
> m =
> Basemap2(llcrnrlon=-145.5,llcrnrlat=1.,urcrnrlon=-2.566,urcrnrlat=46.352,\
> rsphere=(6378137.00,6356752.3142),\
> resolution='l',area_thresh=1000.,projection='lcc',\
> lat_1=50.,lon_0=-107.)
> # draw coastlines and political boundaries.
> m.drawcoastlines()
> m.fillcontinents()
> # draw parallels and meridians.
> # label on left, right and bottom of map.
> m.drawparallels(arange(0.,80,20.),labels=[1,1,0,1])
> m.drawmeridians(arange(10.,360.,30.),labels=[1,1,0,1])
> # draw a line from x1,y to x2,y and label it with distance in km.
> length = 3000 #kilometers
> x1,y1 = 0.25*m.xmax, 0.25*m.ymax
> lon1,lat1 = m(x1,y1,inverse=True)
> m.drawscale(lon1,lat1,length)
> title('a fancy map scale')
> show()
>
>
>
>
> ------------------------------------------------------
> Michael Hearne
> mh...@us... <mailto:mh...@us...>
> (303) 273-8620
> USGS National Earthquake Information Center
> 1711 Illinois St. Golden CO 80401
> Senior Software Engineer
> Synergetics, Inc.
> ------------------------------------------------------
>
>
>
>
>
> --
> Jeffrey S. Whitaker Phone : (303)497-6313
> NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
> 325 Broadway Boulder, CO, USA 80305-3328
>
>
>
>
>
> ------------------------------------------------------
> Michael Hearne
> mh...@us...
> (303) 273-8620
> USGS National Earthquake Information Center
> 1711 Illinois St. Golden CO 80401
> Senior Software Engineer
> Synergetics, Inc.
> ------------------------------------------------------
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
-- 
Stephane Raynaud
From: Stephane R. <ste...@gm...> - 2008年03月06日 15:27:28
Hi
Jeff: how about introducing a cache system for Basemap objects?
You recently gave me the idea of using cPickle on Basemap objects, so
I implement a very simple cache system that try to check if map has
already been serialized and dumped to a cache file, before trying to
create it from scratch. Checking is performed on file name which
contains bounds and resolution of the map.
Do you think that it can be managed directly (and in a better way) in
Basemap(), let's say using the cache keyword set to False by default?
A cache directory in ~/.matplotlib/basemap can be used for that.
-- 
Stephane Raynaud
From: <Jou...@xt...> - 2008年03月06日 10:01:13
"Anthony Floyd" <ant...@gm...> writes:
> I would like to 'watermark' a plot. That is, display an image 'under'
> several lines. [...] I've tried using figure.figimage, but that only
> draws the watermark 'outside' the plot area. Fair enough.
The background of the axes object is called a "frame", and you want to
not draw it at all (pass frameon=False to add_axes) or make it
translucent:
fig=figure(...)
fig.figimage(...)
ax=fig.add_subplot(...)
ax.get_frame().set_alpha(0.5)
-- 
Jouni K. Seppänen
http://www.iki.fi/jks
From: Anthony F. <ant...@gm...> - 2008年03月06日 01:57:18
I'm stumped.
I would like to 'watermark' a plot. That is, display an image 'under'
several lines. I would like this watermark to be static and not
change location, shape, or size while allowing for the lines to be
zoomed and panned.
I'm doing this all using the API (not pylab). I've tried using
figure.figimage, but that only draws the watermark 'outside' the plot
area. Fair enough. I've tried creating an axes object on top of my
existing axes (actually my 'existing axes' is already four axes
objects stacked on top of each other with some sharex magic happening)
and using axes.imshow on that. While I do get the image, it doesn't
display or behave as expected.
Essentially the image displays in front of my first axes object, and
no amount of twiddling with axes.set_zorder was affecting it. Things
plotted on the subsequent axes plot on top of the image. This
reflects the axes creation sequence, but zorder doesn't seem to be
doing anything. I've also explicitly set the zorder of the image, but
didn't see any effect there either.
Adding to my confusion, the 'watermark' axes' size is wrong. When I
create the axes object, I set the size using rect=axes1.get_position()
in the figure.add_axes() call. The other 'real' axes use the same
thing, but manage to get the size correct. The watermark axes is
essentially the size of my image.
Does anyone know what I've missed? I've hit the wiki, I've exercised
my Google-fu, but I don't see any examples of what I'm trying to do.
I'm using mpl 0.90.0 at the moment ... but if pressed we can upgrade
to a newer release (our reason for not keeping up with releases is the
old 'not broken, don't fix'). At the moment I'm not too worried about
keeping the axes static while panning and zooming ... I've already
customized backend_bases and I can skip the watermark axes when the
zoom and pan events are processed. But it sure would be nice to be
able to display this image (and later, some static text boxes that
don't move with the plots too) in the appropriate location.
Thanks for any suggestions,
Anthony.

Showing 14 results of 14

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /