Re: [Matplotlib-users] Watermarking figures/axes

2008-03-06 Thread Jouni . Seppanen
Anthony Floyd [EMAIL PROTECTED] 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


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] basemap scalebar

2008-03-06 Thread Stephane Raynaud
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 [EMAIL PROTECTED] 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 

[Matplotlib-users] Basemap and imshow

2008-03-06 Thread Tommy Grav
Is there a way of using imshow together with a basemap?

Cheers
   Tommy

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Basemap and imshow

2008-03-06 Thread Jeff Whitaker
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/PSD1FAX   : (303)497-6449
325 BroadwayBoulder, CO, USA 80305-3328


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Basemap cache

2008-03-06 Thread Jeff Whitaker
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/PSD1FAX   : (303)497-6449
325 BroadwayBoulder, CO, USA 80305-3328


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Basemap and imshow

2008-03-06 Thread Tommy Grav
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/PSD1FAX   : (303)497-6449
 325 BroadwayBoulder, CO, USA 80305-3328



-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Basemap and imshow

2008-03-06 Thread Jeff Whitaker
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/PSD1FAX   : (303)497-6449
325 BroadwayBoulder, CO, USA 80305-3328


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] basemap scalebar

2008-03-06 Thread Jeff Whitaker
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 [EMAIL PROTECTED] 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 =
 

[Matplotlib-users] errorbar and legend(loc='best') gives error

2008-03-06 Thread Kevin Christman
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-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] basemap scalebar

2008-03-06 Thread Stephane Raynaud
On Thu, Mar 6, 2008 at 6:15 PM, Jeff Whitaker [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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)),\
  

Re: [Matplotlib-users] basemap scalebar

2008-03-06 Thread Jeff Whitaker
Stephane Raynaud wrote:
 On Thu, Mar 6, 2008 at 6:15 PM, Jeff Whitaker [EMAIL PROTECTED] 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/PSD1FAX   : (303)497-6449
325 BroadwayBoulder, CO, USA 80305-3328


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users