[Matplotlib-users] Backend Control
Hello, I have some problem with the backend controls. Well to be perfectly honest I don't know if they are able to do what I want from them. As far as I understand the pylab package helps me create plots (and the windows from the different backends) without me having to write my own wxpython, gtk, qt, . application. The matplotlib package provides the plot functions and also has the backend interfaces, etc. In my opinion a "function" called with the same argument twice should always give the same result. That doesnt happen in matplotlib/pylab (probably more pylab). If I plot something with pylab.plot and then pylab.show the first time. The python interpreter halts and waits until the function show is done(me clicking quit in the window). The second time however it somehow calls the function show in the background but does not wait until the execution of show is finished. I don't know what has changed since the first time and if there are generic control features for different backends. Do I have to write my own wx application to get more control over the window or are there some features present already. It could well be that my view of the matter is wrong and that I misunderstand somethings. Please advise Wolfgang - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Basemaps - shapefile import/display for points
OK, I figured out what I was doing wrong. Quite simple really: I assumed the CITIESx020 value was the same as the "enumerated" value - which wasn't the case. Thus the wrong city name was being assigned to some correct city's location. Once I figured that out, all seems better. One thing I DID notice though, which seems to be a bug in the rendering tool is this: When I zoom into an area using the toolbar at the bottom, the annotations appear outside the "zoomed in region", ie. the rectangular area zoomed in to. Regards, Kurt Original Message Follows From: Jeff Whitaker <[EMAIL PROTECTED]> To: KURT PETERS <[EMAIL PROTECTED]> CC: [email protected] Subject: Re: [Matplotlib-users] Basemaps - shapefile import/display for points Date: Tue, 01 Apr 2008 15:54:48 -0600 KURT PETERS wrote: >Jeff, > Do you think it's possible the names or CITIESX020 variable are not being >brought in in the right order? > I modified my code to use scatter, and, although it looks like the dots >are in the right place, the names aren't matching? >see code: >= >import pylab as p >import numpy >from matplotlib.toolkits.basemap import Basemap as Basemap >from matplotlib.colors import rgb2hex >from matplotlib.patches import Polygon > ># Lambert Conformal map of lower 48 states. ># create new figure >#http://nationalatlas.gov/metadata/citiesx020.faq.html >#http://nationalatlas.gov/atlasftp.html?openChapters=chpref#chpref >fig=p.figure() >m1 = Basemap(llcrnrlon=-119,llcrnrlat=22,urcrnrlon=-64,urcrnrlat=49,\ >projection='lcc',lat_1=33,lat_2=45,lon_0=-95,resolution='c') >shp_info = >m1.readshapefile(r'C:\Python25\Lib\basemap-0.9.9.1\examples\citiesx020','states',drawbounds=True) > > >ax=p.gca() > >#define SHPT_POINT1Points >#define SHPT_ARC 3Arcs (Polylines, possible in parts) >#define SHPT_POLYGON 5Polygons (possible in parts) >#define SHPT_MULTIPOINT 8MultiPoint (related points) >print shp_info >print m1.states_info[0].keys() >seqnum={} >criteriatodisplay=[] >names={} >ii=0 >for shapedict in m1.states_info: >if int(shapedict['POP_2000'])>10: >#'STATE_FIPS', 'NAME', 'POP_2000', 'FEATURE', 'COUNTY', 'STATE', 'FIPS', >'CITIESX020', 'FIPS55', 'DISPLAY', 'POP_RANGE'] >print 'STATE_FIPS = %s, NAME = %s, POP_2000=%s, FEATURE = %s, >COUNTY=%s, STATE=%s, FIPS=%s, CITIESX020 = %s, FIPS55=%s, DISPLAY=%s, >POP_RANGE=%s' %\ >(str(shapedict['STATE_FIPS']), str(shapedict['NAME']), >str(shapedict['POP_2000']), str(shapedict['FEATURE']), >str(shapedict['COUNTY']), str(shapedict['STATE']), str(shapedict['FIPS']), >str(shapedict['CITIESX020']), str(shapedict['FIPS55']), >str(shapedict['DISPLAY']), str(shapedict['POP_RANGE'])) ># have an index of the names >seqnum[shapedict['CITIESX020']]=shapedict['NAME'] >criteriatodisplay.append(shapedict['CITIESX020']) > >ii+=1 > >print ii >#x, y = zip(*m1.states) >#print m1.states[1] >#print x[1] >#print y[1] >#ii=0 >x=[] >y=[] >ii=0 >for nshape,seg in enumerate(m1.states): >if nshape in criteriatodisplay: >x.append(seg[0]) >y.append(seg[1]) >p.text(seg[0],seg[1],seqnum[nshape],fontsize=12) >ii+=1 > >#print 'Shape num %s, coords=%s' % (seqnum[nshape], seg) ># ax.annotate(seqnum[nshape],seg) >m1.scatter(x,y,2,'b',marker='o',faceted=False,zorder=10) > >#ax.annotate(s='s',xy=(int(x),int(y))) >#p.figtext(x,y,'o',weight='heavy', size = 16) >m1.drawcoastlines() >m1.fillcontinents() >m1.drawcountries() >m1.drawstates() >m1.drawparallels(numpy.arange(25,65,4),labels=[1,0,0,0]) >m1.drawmeridians(numpy.arange(-120,-40,4),labels=[0,0,0,1]) >p.title('Test Cities') >p.show() > >kurt > > > > Kurt: If I look at the least entry in m.states_info (Newport, VT), the corresponding x,y location in m.states corresponds to 44.93N, -72.21W, which looks about right to me. I guess I'm still not clear on what the issue is. Could you distill your example code down to something very simple that clearly demonstrates the problem? -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX: (303)497-6449 NOAA/OAR/PSD R/PSD1Email : [EMAIL PROTECTED] 325 BroadwayOffice : Skaggs Research Cntr 1D-124 Boulder, CO, USA 80303-3328 Web: http://tinyurl.com/5telg - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Backend Control
On Wed, 2 Apr 2008, Wolfgang Kerzendorf wrote: > If I plot something with pylab.plot and then > pylab.show the first time. http://matplotlib.sourceforge.net/faq.html#SHOW http://matplotlib.sourceforge.net/faq.html#OO hth, Alan Isaac - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Nonlinear twin axis
I'm trying to make a plot that has two x-axis with one of them
nonlinear - twiny() is working great, but I'm hung up on how to get
the second axis to be spaced properly. For the sake of example, lets
say the first axis is linear on [1,2] - if I just plot data according
to that x-axis, all is fine. Now, I also want to see an x-axis on the
top that corresponds to, say x2 = x1^3 - then the second axis should
be on the range [1,8] . The problem is, it's not a linear mapping
from x1 to x2, so I can't just set the xlims on the second axis to 1
and 8 and have it work. I tried making a derived class of Scale (see
code below) using the appropriate transform, but it didn't seem to
have any effect on the axes. Do I need to do soemthing else with the
locators or formatters or something?
class Cubedscale(scale.ScaleBase):
name='cubedscale'
class CubedTransform(transforms.Transform):
input_dims=1
output_dims=1
is_seperable=True
has_inverse=False
def transform(self,values):
return values**3
def __init__(self):
pass
trans=CubedTransform()
def __init__(self, axis, **kwargs):
pass
def get_transform(self):
return trans
def set_default_locators_and_formatters(self,axis):
axis.set_major_locator(AutoLocator())
axis.set_major_formatter(ScalarFormatter())
axis.set_minor_locator(NullLocator())
axis.set_minor_formatter(NullFormatter())
scale.register_scale(CubedScale)
xaxis.set_scale('cubedscale')
-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] How do I widen the space for y coordinate ticks?
without having to increase the width of the whole chart? -- View this message in context: http://www.nabble.com/How-do-I-widen-the-space-for-y-coordinate-ticks--tp16447673p16447673.html Sent from the matplotlib - users mailing list archive at Nabble.com. - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
