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



Showing results of 285

<< < 1 .. 9 10 11 12 > >> (Page 11 of 12)
From: Matt M. <mat...@gm...> - 2008年04月08日 04:10:07
Hi,
Trying to save a figure with a black figure.facecolor, black figure.edgecolor. 
If I savefig(), it follows the rc file settings, but if save from the button 
in the GUI, I get a white figure.facecolor and figure.edgecolor. I tried 
changing the GUI backends to no avail. Currently using Qt4Agg.
Thanks.
From: Robert K. <rob...@gm...> - 2008年04月07日 21:20:23
Rich Fought wrote:
> The prism colormap repeats the same pattern over and over instead of 
> spreading itself over the plotted data range in a pcolor plot. Is this 
> expected behavior?
Yup. prism and flag are designed to repeat.
-- 
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
 -- Umberto Eco
From: Rich F. <wha...@fs...> - 2008年04月07日 16:04:42
The prism colormap repeats the same pattern over and over instead of 
spreading itself over the plotted data range in a pcolor plot. Is this 
expected behavior?
Simply add prism() to pcolor_demo.py to see what I am talking about.
Thanks,
Rich
From: Manuel M. <mm...@as...> - 2008年04月07日 13:36:07
Paul Smith wrote:
> I'm plotting two curves in one subplot with twinx to allow different y scales. 
> The script below is an example. 
> When zooming in using zoom-to-rect on Tk's navigation toolbar2 (TkAgg is my 
> backend) I think the x axis part of the zoom is happening twice. Rubberbanding 
> the example from x=20 to 80 results in a zoomed x range of about 32 to 68, 
> which is about what you'd expect for zooming with the same range twice. 
> 
> Is there a way of restricting this to only one zoom?
> 
> Paul
> ------------
> from pylab import *
> f=figure(1)
> ax1=f.add_subplot(111)
> ax1.plot(arange(100))
> ax2=twinx(ax1)
> ax2.plot(-arange(100),'g')
> draw()
> 
> ------------
> python 2.5
> winxp
> matplotlib 0.91.1
> 
Indeed, this appears to be a bug. I put this on the develop mailing list.
Manuel
From: Paul S. <pau...@ca...> - 2008年04月07日 07:40:10
I'm plotting two curves in one subplot with twinx to allow different y scales. 
The script below is an example. 
When zooming in using zoom-to-rect on Tk's navigation toolbar2 (TkAgg is my 
backend) I think the x axis part of the zoom is happening twice. Rubberbanding 
the example from x=20 to 80 results in a zoomed x range of about 32 to 68, 
which is about what you'd expect for zooming with the same range twice. 
Is there a way of restricting this to only one zoom?
Paul
------------
from pylab import *
f=figure(1)
ax1=f.add_subplot(111)
ax1.plot(arange(100))
ax2=twinx(ax1)
ax2.plot(-arange(100),'g')
draw()
------------
python 2.5
winxp
matplotlib 0.91.1
From: Alexandre Z. <ale...@gm...> - 2008年04月06日 19:50:14
Hi,
In the example below I can make the cursor snap over the
nearest point with the mouse and also move the cursor with the
keyboard.
But I can't print the coordinates in the toolbar when the I
move the cursor with the keyboard as when I move with the mouse!
Does anyone have an idea?
Cheers,
Alexandre
from pylab import *
import numpy
from matplotlib.widgets import Cursor
class DataCursor(Cursor):
 def __init__(self, t, y, ax, useblit=True, **lineprops):
 Cursor.__init__(self, ax, useblit=True, **lineprops)
 self.y = y
 self.t = t
 self.i = 0
 self.xstr = ''
 self.ystr = ''
 def onmove(self, event):
 """
 we override event.xdata to force it to snap-to nearest data item
 """
 N = len(self.y)
 # Mouse Move
 if event.name=="motion_notify_event":
 xdata = event.xdata
 ind = numpy.searchsorted(self.t, xdata)
 self.i = min(N-1, ind)
 # Key press
 elif event.name=="key_press_event":
 if event.key=="right":
 self.i+=1
 while self.i>=N:
 self.i-=N
 elif event.key=="left":
 self.i-=1
 while self.i<0:
 self.i+=N
 # Set the cursor and draw
 event.xdata = self.t[self.i]
 event.ydata = self.y[self.i]
 self.xstr = '%1.3f'%event.xdata
 self.ystr = '%1.3f'%event.ydata
 Cursor.onmove(self, event)
 def fmtx(self, x):
 return self.xstr
 def fmty(self, y):
 return self.ystr
t = numpy.cumsum(numpy.random.rand(20))
y = numpy.random.rand(len(t))
fig = figure()
ax = fig.add_subplot(111)
ax.plot(t, y, 'go')
cursor = DataCursor(t, y, ax, useblit=True, color='red', linewidth=2 )
ax.fmt_xdata = cursor.fmtx
ax.fmt_ydata = cursor.fmty
fig.canvas.mpl_connect('key_press_event', cursor.onmove )
show()
From: Jochen K. <jo...@fh...> - 2008年04月04日 21:00:29
Hi,
when I create a contour plot with the following grid:
 xval = [ 1.00003324, 1.00009971, 1.00016618]
 yval = [250, 260, 270]
 data = ones((3,3))
 contourf(xval, yval, data)
matplotlib creates a contour plot with an x-axes labels of 
"0.0000324", ... and adds a "+1" in the lower right corner.
Actually, it is often not visible at all.
How can I set it to always use the "correct" values directly as labels?
Greetings,
Jochen
-- 
Fritz-Haber-Institut der MPG -- Department of Molecular Physics
Faradayweg 4-6 (C1.03)
D-14195 Berlin, Germany
phone: +49-30-84135686
fax: +49-30-84135892
http://www.fhi-berlin.mpg.de/mp/jochen
From: Glenn H T. P. <gl...@ta...> - 2008年04月04日 20:23:52
there's been some discussion on this, (I think). If by backend control,
you mean greater degree of control over the event loop, there are a
number of approaches available.
For example, look through the threads at how twisted can be integrated
with ipython0... ipython1 embraces asynchronous handling at its core,
making gui interaction even more straightforward.
Recently, in ancicipation of ipython1, but still providing current
usability, I simply nail up the twisted qtreactor -
http://code.tarbox.org/qtreactor inside ipython0 and have control over
comms, gui event handling and still am able to use matplotlib...
the primary difficulty, temporary I believe, is that if pyreadline grabs
the event loop, everything hangs... so, if there is a multi-page scroll
or, if you start typing and stop before hitting return, everything
hangs...
I think one might be able to use the multi-threaded ipython approach but
I try to stay away from threading due to the difficulties it creates
with components which aren't thread safe... like twisted and many gui
support libs.
but, ipython1 progress continues and should make issues like this simply
go away
-glenn
On Fri, 2008年04月04日 at 12:44 -0400, Alan G Isaac wrote:
> >> On Wed, 2 Apr 2008, Wolfgang Kerzendorf wrote:
> >>> If I plot something with pylab.plot and then 
> >>> pylab.show the first time. 
> 
> > Alan replied:
> >> http://matplotlib.sourceforge.net/faq.html#SHOW 
> >> http://matplotlib.sourceforge.net/faq.html#OO 
> 
> On Fri, 4 Apr 2008, Wolfgang Kerzendorf apparently wrote:
> > I have read these faq entries before, but they don't really resolve my 
> > issue. I want backend independent control over the plots. My question 
> > is, does that exist in matplotlib, or do I have to embed 
> > matplotlib in a backend to get more control? 
> 
> What kind of control do you mean?
> To quote from
> http://matplotlib.sourceforge.net/backends.html:
> 
> The matplotlib core graphics routines interact with
> an abstract renderer and graphics context to allow
> device independent ouput. Currently, output to pygtk,
> wxPython, Tkinter, postscript, pdf, svg, agg
> (antigrain geometry) and Cairo are supported. With
> not too much effort, you can port matplotlib to your
> favorite display. If you are interested in porting to
> one of these platforms, please contact the
> matplotlib-devel mailing list.
> 
> If you are additionally hoping for an abstraction of the
> GUI, I do not think Matplotlib offers such a thing. Indeed, 
> I would find such an effort very surprising. (But I'm just 
> a user.)
> 
> Maybe a very specific example of what you are doing would
> help.
> 
> Cheers,
> Alan
> 
> 
> 
> 
> -------------------------------------------------------------------------
> 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
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Alan G I. <ai...@am...> - 2008年04月04日 16:42:22
>> On Wed, 2 Apr 2008, Wolfgang Kerzendorf wrote:
>>> If I plot something with pylab.plot and then 
>>> pylab.show the first time. 
> Alan replied:
>> http://matplotlib.sourceforge.net/faq.html#SHOW 
>> http://matplotlib.sourceforge.net/faq.html#OO 
On Fri, 4 Apr 2008, Wolfgang Kerzendorf apparently wrote:
> I have read these faq entries before, but they don't really resolve my 
> issue. I want backend independent control over the plots. My question 
> is, does that exist in matplotlib, or do I have to embed 
> matplotlib in a backend to get more control? 
What kind of control do you mean?
To quote from
http://matplotlib.sourceforge.net/backends.html:
 The matplotlib core graphics routines interact with
 an abstract renderer and graphics context to allow
 device independent ouput. Currently, output to pygtk,
 wxPython, Tkinter, postscript, pdf, svg, agg
 (antigrain geometry) and Cairo are supported. With
 not too much effort, you can port matplotlib to your
 favorite display. If you are interested in porting to
 one of these platforms, please contact the
 matplotlib-devel mailing list.
If you are additionally hoping for an abstraction of the
GUI, I do not think Matplotlib offers such a thing. Indeed, 
I would find such an effort very surprising. (But I'm just 
a user.)
Maybe a very specific example of what you are doing would
help.
Cheers,
Alan
From: Alan G I. <ai...@am...> - 2008年04月04日 16:42:22
On 2008年4月03日, KURT PETERS apparently wrote:
> how would one use a GUI event handler/timer? 
<URL:http://matplotlib.sourceforge.net/tutorial.html>
(near the bottom)
hth,
Alan 
On 4/4/08, fri...@gm... <fri...@gm...> wrote:
> Dear all,
>
> I would like to plot two different data series against a common
> time-series, e.g. dataset 1 is the precipitation data around a year at
> City 1, and dataset 2 is the precipitation of the same year taken at
> City 2. They share a common x-axis. My goal is to draw the two lines
> in the same subplot so that the different climate profile of the two
> cities can be directly visualized. However, the current version of the
> plot_date() method doesn't seem to support multiple lines in the same
> subplot. What should I do?
>
> Thanks for your comments.
>
> Cong.
>
I'm sorry but I think I made a mistake. I tried calling the
plot_date() method two times with different data and it worked.
Dear all,
I would like to plot two different data series against a common
time-series, e.g. dataset 1 is the precipitation data around a year at
City 1, and dataset 2 is the precipitation of the same year taken at
City 2. They share a common x-axis. My goal is to draw the two lines
in the same subplot so that the different climate profile of the two
cities can be directly visualized. However, the current version of the
plot_date() method doesn't seem to support multiple lines in the same
subplot. What should I do?
Thanks for your comments.
Cong.
From: Pierre GM <pgm...@gm...> - 2008年04月03日 19:36:34
Chris,
Why wouldn't you try to use sorted on your dictionary, construct an array from 
the result of sorted, and get the corresponding columns ?
>>>ddict={date(2008,01,01):10,date(2008,01,03):20,date(2008,01,02):30}
>>>results=numpy.array(sorted(ddict.iteritems()),)
>>>print results[:,0]
>>>[2008年01月01日 2008年01月02日 2008年01月03日]
>>>print results[:,1]
>>>[10 30 20]
From: Chris W. <ch...@si...> - 2008年04月03日 19:20:19
Hey All,
I have a dictionary that maps date to a count (in this case the number 
of false negatives from my spam filter) and I'm wondering how to best 
plot something that looks like, say:
from datetime import date
data = {
 date(2008,03,01):10,
 date(2008,03,02):15,
 date(2008,03,03):13,
}
I'm worried about getting the dates out in order such that I get a 
straight line plot, rather than the zigzag back-and-forth line I reckon 
I'd get if I did:
dates = []
count = []
for date,count in data.items:
 dates.append(date)
 count.append(count)
plot(dates,counts)
cheers,
Chris
-- 
Simplistix - Content Management, Zope & Python Consulting
 - http://www.simplistix.co.uk
From: Lev G. <le...@co...> - 2008年04月03日 19:03:41
Using matplotlib 0.91.2 with the current development version of
ipython on Linux with no local matplotlibrc file, I have noticed that
setting the font weight via
rc('text',fontweight='bold')
or 
rc('font',weight='bold')
changes the relevant rc parameter but doesn't affect the weight of the
displayed fonts used in the axes or titles. Specifying the weight in
matplotlibrc does work, however. Has anyone else observed this?
	 	 		 	 	 L.G.
From: KURT P. <pet...@ms...> - 2008年04月03日 15:33:18
Alan,
 It would be nice to be able to plot and show, get feedback from the user 
(perhaps using tkinter), and then update the plot on the screen, causing you 
to have to use show twice (pylab.Draw()doesn't seem to work the way I'm 
trying to use it -- with basemaps -- ie. to get the user to see an 
intermediate map.)
 Any hints or examples showing how to use "draw" properly with basemaps? 
(The links you sent said "draw" should work.) The funny thing is that when 
I look at anim.py it says:
# turn interactive mode on for dynamic updates. If you aren't in
# interactive mode, you'll need to use a GUI event handler/timer.
 but how would one use a GUI event handler/timer?
Regards,
Kurt
Date: Wed, 2 Apr 2008 10:44:43 -0400
From: Alan Isaac <ai...@am...>
Subject: Re: [Matplotlib-users] Backend Control
To: mat...@li...
Message-ID:
	<Mah...@CA...>
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
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
From: John H. <jd...@gm...> - 2008年04月03日 14:17:49
On Thu, Apr 3, 2008 at 6:19 AM, Chris Squibb <sq...@en...> wrote:
> Hey,
>
> Up until recently I have been using mpl 0.90.1, and my application
> worked fine. Yesterday I upgraded to 0.91.2 and am now getting the
> following traceback:
Are you getting that with every mpl script, eg the canconical simple_plot.py
http://matplotlib.sf.net/examples/simple_plot.py
If not, we may need to see a little code to help diagnose what is going on
JDH
From: Manuel M. <mm...@as...> - 2008年04月03日 11:58:12
carlwenrich wrote:
> without having to increase the width of the whole chart?
Have a look at examples/major_minor_demo1.py and 
examples/major_minor_demo2.py. I guess you are looking for something 
like this ...
Manuel
From: Chris S. <sq...@en...> - 2008年04月03日 11:19:13
Hey,
Up until recently I have been using mpl 0.90.1, and my application
worked fine. Yesterday I upgraded to 0.91.2 and am now getting the
following traceback:
 File "application.
py", line 667, in plot
 radial_plot_figure.savefig(png_file, dpi=self.dpi)
 File "C:\Python25\Lib\site-packages\matplotlib\figure.py", line 770,
in savefig
 self.canvas.print_figure(*args, **kwargs)
 File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_wxagg.py",
line 101, in print_figu
re
 FigureCanvasAgg.print_figure(self, filename, *args, **kwargs)
 File "C:\Python25\Lib\site-packages\matplotlib\backend_bases.py",
line 1202, in print_figure
 self.figure.canvas.draw()
 File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_wxagg.py",
line 65, in draw
 self.gui_repaint()
 File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_wx.py",
line 987, in gui_repaint
 drawDC.DrawBitmap(self.bitmap, 0, 0)
 File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_gdi.py",
line 3387, in DrawBitmap
 return _gdi_.DC_DrawBitmap(*args, **kwargs)
PyAssertionError: C++ assertion "hdcDst && hdcSrc" failed at
..\..\src\msw\dc.cpp(2559) in AlphaBlt(
): AlphaBlt(): invalid HDC
Does anyone have any suggestions to why this is happening?
Thanks.
From: Lars F. <lfr...@im...> - 2008年04月03日 09:29:40
Hello!
I use matplotlib in interactive mode with the wxAgg backend under 
WindowsXP. It often happens that I have quite a lot figure windows 
hidden by other windows. Then it is difficult to pick the right figure 
window from the taskbar, since their titles all start with 'Figure...' 
and additionally, I can't remember which number is which plot.
Therefor, I would like to raise all my figure windows to the top of my 
cluttered desktop... Is there a command like
f = figure()
# put the figure to the background
f.raise()
that will take the figure window to the top of all other windows?
Thanks
Lars
From: carlwenrich <car...@ya...> - 2008年04月02日 17:59:51
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.
From: Erik T. <eri...@gm...> - 2008年04月02日 17:56:52
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')
From: Alan I. <ai...@am...> - 2008年04月02日 14:45:07
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
From: KURT P. <pet...@ms...> - 2008年04月02日 13:23:58
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 <js...@fa...>
To: KURT PETERS <pet...@ms...>
CC: mat...@li...
Subject: Re: [Matplotlib-users] Basemaps - shapefile import/display for 
points
Date: 2008年4月01日 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_POINT 1 Points
>#define SHPT_ARC 3 Arcs (Polylines, possible in parts)
>#define SHPT_POLYGON 5 Polygons (possible in parts)
>#define SHPT_MULTIPOINT 8 MultiPoint (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'])>100000:
>#'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
>
><snip>
>
>
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/PSD1 Email : Jef...@no...
325 Broadway Office : Skaggs Research Cntr 1D-124
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
From: Wolfgang K. <wke...@go...> - 2008年04月02日 11:03:11
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
2 messages has been excluded from this view by a project administrator.

Showing results of 285

<< < 1 .. 9 10 11 12 > >> (Page 11 of 12)
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 によって変換されたページ (->オリジナル) /