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


Showing results of 201

<< < 1 .. 5 6 7 8 9 > >> (Page 7 of 9)
From: Klonuo U. <kl...@gm...> - 2011年06月09日 14:13:40
I use matplotlib through IPython on Windows XP with Python 2.6.6 and Qt4Agg
as backend
Trying to save plot as EMF, after installing pyemf 2.0 raises this
error:
too many values to unpack
From: Klonuo U. <kl...@gm...> - 2011年06月09日 13:54:42
Hi,
How can I use font in my locale or even better UTF-8 for plot
annotations?
Right now I can see only empty rectangles instead characters when I try
to enter anything other then ASCII
Thanks
From: Richard H. <ric...@io...> - 2011年06月09日 11:26:01
Hello mplot3d specialists,
I would like to change the aspect ratio of the 3d axes similar to matlab's
functionality with daspect() or the 'dataaspectratio' property of 3d-axes.
In the end, the x-y-plane should be non-square due to different lengths (not
range) of the x and y axis (i know that i can use the aspect property of the
axes to set the x-z/y-z aspect ratio).
There is also the package "scitools", which provides all the matlab-3d
functions including daspect via a VTK-backend; that would be my next try.
For the simple 3d-plotting without fancy shading, i would like to stick to
mplot3d:
Is it possible to change the axis lengths/aspect ratios independently?
Richard
From: Eric F. <ef...@ha...> - 2011年06月08日 18:35:22
On 06/08/2011 01:28 AM, Daniel Mader wrote:
> Dear Eric,
>
> thanks again for your comment, I am aware that the script contained
> both the individual colorbars and the common one. My comment in the
> code was because the placement on the figure is somewhat cramped:
That's what I suspected, so the main point of the modified version was 
using subplots_adjust to give more room at the bottom, and then shifting 
the bottom colorbar so that it was less cramped. Granted, this approach 
takes some fiddling; but if you are using subplots and care about 
appearance, then sooner or later you will probably benefit from 
subplots_adjust, a function/method which is probably not as well-known 
as it deserves to be.
Eric
>
> ## doesn't really work :/ ## in what way?
> cax = fig.add_axes([0.25, 0.06, 0.5, 0.02])
> fig.colorbar(im2, cax, orientation='horizontal')
>
> Ideally, I'd need to create a new subfig 313 with a much reduced height.
>
> Either way, you helped me a lot!
>
>
> 2011年6月7日 Eric Firing<ef...@ha...>:
>> On 06/07/2011 01:37 AM, Daniel Mader wrote:
>>>
>>> Hi Eric,
>>>
>>>
>>> 2011年6月6日 Eric Firing<ef...@ha...>:
>>>>
>>>> It's not quite clear to me yet, but I assume you want to use a call to
>>>> imshow with a different data set in the second subplot, but have the
>>>> color scale and colorbar be identical to those in the first subplot. Is
>>>> that correct? If so, all you need to do is use the same norm for both
>>>> calls to imshow--that is, define a norm, set the limits you want on it,
>>>> and supply it as a kwarg.
>>>
>>> thanks a lot, you helped me to work around my problem, see code below :)
>>>
>>>> Also, for this sort of comparison, sometimes it is more efficient to use
>>>> a single colorbar for multiple panels, as in this example:
>>>>
>>>>
>>>> http://matplotlib.sourceforge.net/examples/pylab_examples/multi_image.html
>>>
>>> Very nice example! It's a little too complex for me, though, with all
>>> the calculations for the axes layout -- I prefer subplots :) However,
>>> I think I have found a nice compromise:
>>
>> Attached is a slight modification, much simpler than the example above, but
>> retaining the single colorbar. Alternatively, if you stick with the
>> colorbar for each panel (which is sometimes clearer), it illustrates a
>> slightly clearer way of handling the cmap and norm, explicitly using the
>> same instance of each for both images.
>>
>> Eric
>>
>>>
>>> import pylab
>>> import matplotlib as mpl
>>>
>>> pylab.close('all')
>>>
>>> dat = pylab.array([[1,2,3,4],[5,6,7,8]])
>>> datT = dat/2
>>>
>>> fig = pylab.figure()
>>>
>>> ax1 = fig.add_subplot(211)
>>> ax1.set_title('raw data')
>>> im1 = ax1.imshow(dat, interpolation='nearest',
>>> cmap=mpl.cm.get_cmap('rainbow', 20))
>>> fig.colorbar(im1)
>>>
>>> ax2 = fig.add_subplot(212)
>>> ax2.set_title('leveled')
>>> im2 = ax2.imshow(datT, interpolation='nearest',
>>> cmap=mpl.cm.get_cmap('rainbow', 20))
>>> ## apply norm:
>>> norm = mpl.colors.Normalize(vmin=dat.min(), vmax=dat.max())
>>> im2.set_norm(norm)
>>> fig.colorbar(im2)
>>>
>>> ## doesn't really work :/
>>> cax = fig.add_axes([0.25, 0.04, 0.5, 0.02])
>>> fig.colorbar(im2, cax, orientation='horizontal')
>>>
>>> pylab.show()
>>>
>>> Thanks a lot,
>>> best regards,
>>>
>>> Daniel
>
> ------------------------------------------------------------------------------
> EditLive Enterprise is the world's most technically advanced content
> authoring tool. Experience the power of Track Changes, Inline Image
> Editing and ensure content is compliant with Accessibility Checking.
> http://p.sf.net/sfu/ephox-dev2dev
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: John H. <jd...@gm...> - 2011年06月08日 14:13:34
On Tue, Jun 7, 2011 at 5:16 PM, Shankararaman Ramakrishnan <
Sha...@tr...> wrote:
> Hi,
>
>
>
> I use matplotlib as my python graphics library. I happen to see the
> following problems with the plot() function and would appreciate any help to
> resolve these problems!
>
>
>
> 1. Using the default line style under plot() results in the function
> dropping data points from the plot. Plotting the same data with a ‘dot’
> linestyle shows the missing data points.
>
> 2. Any large outliers in a data set are generally excluded from the
> resulting plot.
>
>
>
> The original plot generated using the default linestyle does not show the
> large outliers in the dataset. Further comparing against the second plot
> shows missing data points which were not connected by the default linestyle.
> Several missing data points are not necessarily large outliers. My initial
> guess for missing large outliers was that the function was aliasing down
> large values.
>
>
>
> Missing nominal data points makes me wonder if the plot function internally
> generates a "best-fit" or least squares plot of the data points? This
> inconsistent plot occurs only with large data sets. The two plots were
> generated with over 100000 (hundred thousand) data points.
>
>
>
> Would be happy to send you the original data if that may help troubleshoot
> this problem.
>
In all liklihood, you are using an older version of matplotlib which had a
bug in the path.simplify logic that caused some points to be dropped. The
solution is to either upgrade to the latest matplotlib (1.0.1) or turn off
path simplification by setting 'path.simplify : False' in your matplotlibrc
http://matplotlib.sourceforge.net/users/customizing.html
You can find out what version of matplotlib you are running by doing
In [127]: import matplotlib
In [128]: matplotlib.__version__
Out[128]: '1.0.1'
JDH
From: Daniel M. <dan...@go...> - 2011年06月08日 11:29:12
Dear Eric,
thanks again for your comment, I am aware that the script contained
both the individual colorbars and the common one. My comment in the
code was because the placement on the figure is somewhat cramped:
## doesn't really work :/ ## in what way?
cax = fig.add_axes([0.25, 0.06, 0.5, 0.02])
fig.colorbar(im2, cax, orientation='horizontal')
Ideally, I'd need to create a new subfig 313 with a much reduced height.
Either way, you helped me a lot!
2011年6月7日 Eric Firing <ef...@ha...>:
> On 06/07/2011 01:37 AM, Daniel Mader wrote:
>>
>> Hi Eric,
>>
>>
>> 2011年6月6日 Eric Firing<ef...@ha...>:
>>>
>>> It's not quite clear to me yet, but I assume you want to use a call to
>>> imshow with a different data set in the second subplot, but have the
>>> color scale and colorbar be identical to those in the first subplot. Is
>>> that correct? If so, all you need to do is use the same norm for both
>>> calls to imshow--that is, define a norm, set the limits you want on it,
>>> and supply it as a kwarg.
>>
>> thanks a lot, you helped me to work around my problem, see code below :)
>>
>>> Also, for this sort of comparison, sometimes it is more efficient to use
>>> a single colorbar for multiple panels, as in this example:
>>>
>>>
>>> http://matplotlib.sourceforge.net/examples/pylab_examples/multi_image.html
>>
>> Very nice example! It's a little too complex for me, though, with all
>> the calculations for the axes layout -- I prefer subplots :) However,
>> I think I have found a nice compromise:
>
> Attached is a slight modification, much simpler than the example above, but
> retaining the single colorbar. Alternatively, if you stick with the
> colorbar for each panel (which is sometimes clearer), it illustrates a
> slightly clearer way of handling the cmap and norm, explicitly using the
> same instance of each for both images.
>
> Eric
>
>>
>> import pylab
>> import matplotlib as mpl
>>
>> pylab.close('all')
>>
>> dat = pylab.array([[1,2,3,4],[5,6,7,8]])
>> datT = dat/2
>>
>> fig = pylab.figure()
>>
>> ax1 = fig.add_subplot(211)
>> ax1.set_title('raw data')
>> im1 = ax1.imshow(dat, interpolation='nearest',
>> cmap=mpl.cm.get_cmap('rainbow', 20))
>> fig.colorbar(im1)
>>
>> ax2 = fig.add_subplot(212)
>> ax2.set_title('leveled')
>> im2 = ax2.imshow(datT, interpolation='nearest',
>> cmap=mpl.cm.get_cmap('rainbow', 20))
>> ## apply norm:
>> norm = mpl.colors.Normalize(vmin=dat.min(), vmax=dat.max())
>> im2.set_norm(norm)
>> fig.colorbar(im2)
>>
>> ## doesn't really work :/
>> cax = fig.add_axes([0.25, 0.04, 0.5, 0.02])
>> fig.colorbar(im2, cax, orientation='horizontal')
>>
>> pylab.show()
>>
>> Thanks a lot,
>> best regards,
>>
>> Daniel
From: Johannes R. <JRa...@gm...> - 2011年06月08日 10:52:26
Hello,
I've got following function describing any kind of animal dispersal kernel:
def pdf(x,s1,s2):
 return (p/(math.sqrt(2*math.pi*s1**2))*numpy.exp(-((x-0)**(2)/(2*s1**(2)))))+((1-p)/(s2*math.sqrt(2*math.pi))*numpy.exp(-((x-0)**(2)/(2*s2**(2)))))
On the other hand I've got data from literature with which I want to fit the function so that I get s1, s2 and x. 
Ususally the data in the literature are as follows:
Example 1: 50% of the animals are between -270m and +270m and 90% are between -500m and + 500m
Example 2: 84% is between - 5000 m and +5000m, and 73% are between -1000m and +1000m
So far as I understand an integration of the function is needed to solve for s1 and s2 as all the literature data give percentage (area under the curve) Can that be used to fit the curve or can that create ranges for s1 and s2.
/Johannes
-- 
NEU: FreePhone - kostenlos mobil telefonieren!			
Jetzt informieren: http://www.gmx.net/de/go/freephone
From: Eric O L. (EOL) <Eri...@no...> - 2011年06月08日 08:18:32
efiring wrote:
> 
> My github branch now includes a changeset with augmented docstrings for 
> show and draw.
> 
Your new docstrings are a great improvement. They answer many of the
questions I have been having for years.
As for where the interactive mode/non-interactive mode discussion should be,
I think that while the mere existence of this discussion is an improvement. 
I vote for moving it to a more prominent place than the FAQ, as it is about
an important, practical subject that users should be aware of quite early
when they learn Matplotlib.
Anyway, many thanks to you and Ben for devoting time to this.
:-)
-- 
View this message in context: http://old.nabble.com/Exact-semantics-of-ion%28%29---tp31728909p31798588.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Benjamin R. <ben...@ou...> - 2011年06月07日 23:37:06
On Tuesday, June 7, 2011, Eric Firing <ef...@ha...> wrote:
> On 06/07/2011 11:46 AM, Benjamin Root wrote:
>> On Saturday, June 4, 2011, Eric Firing<ef...@ha...> wrote:
>>>
>>>
>>> https://github.com/efiring/matplotlib/blob/faq_show_draw/doc/faq/usage_faq.rst
>>>
>>> Eric, Ben,
>>>
>>> See if the section "What is interactive mode" makes sense to you. I have just added it to a feature branch (which includes some other faq madifications, mainly moving the backend section from installation to usage), but have not yet generated a pull request. It doesn't go into every detail, or into the underlying machinery. It is intended to provide just enough understanding to clear up user-level confusion about interactive mode, show, and draw, and let most relatively new users get on with their work.
>>>
>>> Eric
>>>
>>
>> Eric,
>>
>> I see where you are going with this, and this is valuable information
>> to include in the docs. However, the interactive mode and backend info
>> doesn't seem to fit properly with everything else on the page. I am
>
> I don't see why not. A FAQ is a place for answers to questions, and
> this is the usage section of the FAQ, so I don't see any inherent reason
> why information about backends and interactive mode, both of which
> involve mpl usage, can't go there. There may be better places, to which
> the FAQ could refer, but I think the FAQ is better than nothing. I
> moved the backend piece from the installation part of the FAQ, where it
> *really* didn't belong. (And the remaining installation part is also an
> out-of-date worm jar.)
>
>> not sure where to put them yet, but I will see if I can take a deeper
>> look tomorrow. I also already noticed some other wording issues in
>> some other parts of that page.
>>
>> Ben Root
>
> What you will also find is that the section users/shell.rst, which threw
> Eric L for a loop in the first place, badly needs updating, and overlaps
> with what I was trying to do in the FAQ. As Eric also points out, a
> section with more detail would probably be good somewhere; I was
> thinking of putting that in the FAQ also, at least as a first step.
>
> My github branch now includes a changeset with augmented docstrings for
> show and draw.
>
> Eric
>
I think my main issue is that the FAQ is not really an FAQ anymore.
There are only a few remaining questions as section headers, and some
of the "answers" are much too involved. I would think we would be
best served by a real FAQ and then separate topic-based docs that the
answers can link to (as well as having them accessible from the main
toc).
Ben Root
From: Eric F. <ef...@ha...> - 2011年06月07日 22:48:04
On 06/07/2011 11:36 AM, Bruce Ford wrote:
> That's what I thought, but the code below fails (ValueError: Shape
> mismatch objects cannot be broadcast to a single shape) when trying to
> plot the 2nd parameter. Do I need another basemap?
No, but check the dimensions of t2m; maybe it is transposed relative to 
what is needed. It needs to have shape (n_latitudes, n_longitudes), 
just like x1 and y1. It's confusing, but it's a common convention.
Also, although this is not relevant to your particular problem here, it 
might be good to transform your lon, lat 2-D arrays into map 
coordinates, so that if you decide to use a different projection some 
day, it will still work.
Eric
>
> Appreciate any thoughts!
>
> from mpl_toolkits.basemap import Basemap, shiftgrid
> from netCDF4 import Dataset
> import numpy as np
> import matplotlib.pyplot as plt
>
> fig=plt.figure()
> lon1 = 0
> lon2 = 357.5
> lat1 = -90
> lat2 = 90
> m = Basemap(resolution='c',projection='cyl',llcrnrlon=lon1,llcrnrlat=lat1,\
> urcrnrlon=lon2,urcrnrlat=lat2)
>
> #get data and plot 1st parameter - This works
> filename = "/data/reanal-2/ltm/monthly_ltm_01.nc <http://monthly_ltm_01.nc>"
> print filename
> nc = Dataset(filename, mode="r")
> hgt = nc.variables['HGT_2_ISBL_10'][16,:,:]
> print hgt.shape
> lons = nc.variables['longitude'][:]
> lats = nc.variables['latitude'][:]
> x,y = np.meshgrid(lons, lats)
> CS = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
> CS = m.contourf(x,y,hgt,cmap=plt.cm.jet)
> ###########################
>
> #extract and plot 2nd paramter - This fails with
> # ValueError: Shape mismatch objects cannot be broadcast to a single shape
> filename1 = "/data/nps_datasets/WNA_T2m_200808.nc"
> print filename1
> nc1 = Dataset(filename1, mode="r")
> for var in nc1.variables:
> print var
> t2m = nc1.variables['T2m'][0,:,:]
> print t2m.shape
> lons1 = nc1.variables['lon'][:]
> lats1 = nc1.variables['lat'][:]
> x1,y1 = np.meshgrid(lons1, lats1)
> CS1 = m.contour(x1,y1,t2m,15,linewidths=0.5,colors='k')
> CS1 = m.contourf(x1,y1,t2m,cmap=plt.cm.jet)
> #############################
>
> m.drawcoastlines()
> m.drawmapboundary()
> #m.fillcontinents()
> # draw parallels and meridians.
> parallels = np.arange(-90,90,30)
> #m.drawparallels(parallels,labels=[1,0,0,1])
> m.drawparallels(parallels,labels=[1,0,0,1])
> meridians = np.arange(0,357.5,30)
> m.drawmeridians(meridians,labels=[1,0,0,1])
> plt.title('Plotted Grid')
> plt.show()
>
From: Bruce F. <br...@cl...> - 2011年06月07日 22:04:44
That's what I thought, but the code below fails (ValueError: Shape mismatch
objects cannot be broadcast to a single shape) when trying to plot the 2nd
parameter. Do I need another basemap?
Appreciate any thoughts!
from mpl_toolkits.basemap import Basemap, shiftgrid
from netCDF4 import Dataset
import numpy as np
import matplotlib.pyplot as plt
fig=plt.figure()
lon1 = 0
lon2 = 357.5
lat1 = -90
lat2 = 90
m = Basemap(resolution='c',projection='cyl',llcrnrlon=lon1,llcrnrlat=lat1,\
 urcrnrlon=lon2,urcrnrlat=lat2)
#get data and plot 1st parameter - This works
filename = "/data/reanal-2/ltm/monthly_ltm_01.nc"
print filename
nc = Dataset(filename, mode="r")
hgt = nc.variables['HGT_2_ISBL_10'][16,:,:]
print hgt.shape
lons = nc.variables['longitude'][:]
lats = nc.variables['latitude'][:]
x,y = np.meshgrid(lons, lats)
CS = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
CS = m.contourf(x,y,hgt,cmap=plt.cm.jet)
###########################
#extract and plot 2nd paramter - This fails with
# ValueError: Shape mismatch objects cannot be broadcast to a single shape
filename1 = "/data/nps_datasets/WNA_T2m_200808.nc"
print filename1
nc1 = Dataset(filename1, mode="r")
for var in nc1.variables:
 print var
t2m = nc1.variables['T2m'][0,:,:]
print t2m.shape
lons1 = nc1.variables['lon'][:]
lats1 = nc1.variables['lat'][:]
x1,y1 = np.meshgrid(lons1, lats1)
CS1 = m.contour(x1,y1,t2m,15,linewidths=0.5,colors='k')
CS1 = m.contourf(x1,y1,t2m,cmap=plt.cm.jet)
#############################
m.drawcoastlines()
m.drawmapboundary()
#m.fillcontinents()
# draw parallels and meridians.
parallels = np.arange(-90,90,30)
#m.drawparallels(parallels,labels=[1,0,0,1])
m.drawparallels(parallels,labels=[1,0,0,1])
meridians = np.arange(0,357.5,30)
m.drawmeridians(meridians,labels=[1,0,0,1])
plt.title('Plotted Grid')
plt.show()
---------------------------------------
Bruce W. Ford
Clear Science, Inc.
br...@cl...
http://www.ClearScienceInc.com
http://www.facebook.com/clearscience
http://www.twitter.com/ROVs_rule
Phone: (904) 796-8101
Fax: (904) 379-9704
8241 Parkridge Circle N.
Jacksonville, FL 32211
Skype: bruce.w.ford
On Tue, Jun 7, 2011 at 1:06 AM, Benjamin Root <ben...@ou...> wrote:
> On Monday, June 6, 2011, Bruce Ford <br...@cl...> wrote:
> > Does anyone have an example of nested grids.
> > I need to (for instance), plot a global grid in filled contours, then
> plot another, higher resolution grid over the US.The global grid could work
> something like this, but I'm not sure where to start with the 2nd (nested)
> grid to go atop.
> >
> >
> > fig=plt.figure()m =
> Basemap(resolution='c',projection='cyl',llcrnrlon=lon1,llcrnrlat=lat1,\
> urcrnrlon=lon2,urcrnrlat=lat2)# make a filled contour plot.
> >
> > x, y = m(lons, lats)CS =
> m.contour(x,y,hgt,15,linewidths=0.5,colors='k')CS =
> m.contourf(x,y,hgt,15,cmap=plt.cm.jet)m.drawcoastlines()m.drawmapboundary()
> > m.fillcontinents()
> > # draw parallels and meridians.parallels =
> np.arange(-90,90,10)#m.drawparallels(parallels,labels=[1,0,0,1])m.drawparallels(parallels,labels=[1,0,0,1])meridians
> = np.arange(-180.,180.,10.)
> >
> > m.drawmeridians(meridians,labels=[1,0,0,1])plt.title('Plotted
> Grid')plt.show()
> > Thanks!
> > Bruce
> > ---------------------------------------
> > Bruce W. Ford
> > Clear Science, Inc.
> > br...@cl...
> >
> >
> >
> >
> >
>
> It should just work as you expect. Do the global contour with the
> coarser x/y data, and then do the US contour with finer x/y data.
>
> Ben Root
>
From: Eric F. <ef...@ha...> - 2011年06月07日 22:02:01
On 06/07/2011 11:46 AM, Benjamin Root wrote:
> On Saturday, June 4, 2011, Eric Firing<ef...@ha...> wrote:
>>
>>
>> https://github.com/efiring/matplotlib/blob/faq_show_draw/doc/faq/usage_faq.rst
>>
>> Eric, Ben,
>>
>> See if the section "What is interactive mode" makes sense to you. I have just added it to a feature branch (which includes some other faq madifications, mainly moving the backend section from installation to usage), but have not yet generated a pull request. It doesn't go into every detail, or into the underlying machinery. It is intended to provide just enough understanding to clear up user-level confusion about interactive mode, show, and draw, and let most relatively new users get on with their work.
>>
>> Eric
>>
>
> Eric,
>
> I see where you are going with this, and this is valuable information
> to include in the docs. However, the interactive mode and backend info
> doesn't seem to fit properly with everything else on the page. I am
I don't see why not. A FAQ is a place for answers to questions, and 
this is the usage section of the FAQ, so I don't see any inherent reason 
why information about backends and interactive mode, both of which 
involve mpl usage, can't go there. There may be better places, to which 
the FAQ could refer, but I think the FAQ is better than nothing. I 
moved the backend piece from the installation part of the FAQ, where it 
*really* didn't belong. (And the remaining installation part is also an 
out-of-date worm jar.)
> not sure where to put them yet, but I will see if I can take a deeper
> look tomorrow. I also already noticed some other wording issues in
> some other parts of that page.
>
> Ben Root
What you will also find is that the section users/shell.rst, which threw 
Eric L for a loop in the first place, badly needs updating, and overlaps 
with what I was trying to do in the FAQ. As Eric also points out, a 
section with more detail would probably be good somewhere; I was 
thinking of putting that in the FAQ also, at least as a first step.
My github branch now includes a changeset with augmented docstrings for 
show and draw.
Eric
From: Benjamin R. <ben...@ou...> - 2011年06月07日 21:52:33
On Tuesday, June 7, 2011, Bruce Ford <br...@cl...> wrote:
> That's what I thought, but the code below fails (ValueError: Shape mismatch objects cannot be broadcast to a single shape) when trying to plot the 2nd parameter. Do I need another basemap?
>
> Appreciate any thoughts!
>
> from mpl_toolkits.basemap import Basemap, shiftgrid
> from netCDF4 import Dataset
> import numpy as np
> import matplotlib.pyplot as plt
>
> fig=plt.figure()
> lon1 = 0
> lon2 = 357.5
> lat1 = -90
> lat2 = 90
> m = Basemap(resolution='c',projection='cyl',llcrnrlon=lon1,llcrnrlat=lat1,\
>       urcrnrlon=lon2,urcrnrlat=lat2)
>
> #get data and plot 1st parameter - This works
> filename = "/data/reanal-2/ltm/monthly_ltm_01.nc"
> print filename
> nc = Dataset(filename, mode="r")
> hgt = nc.variables['HGT_2_ISBL_10'][16,:,:]
> print hgt.shape
> lons = nc.variables['longitude'][:]
> lats = nc.variables['latitude'][:]
> x,y = np.meshgrid(lons, lats)
> CS = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
> CS = m.contourf(x,y,hgt,cmap=plt.cm.jet)
> ###########################
>
> #extract and plot 2nd paramter - This fails with
> # ValueError: Shape mismatch objects cannot be broadcast to a single shape
> filename1 = "/data/nps_datasets/WNA_T2m_200808.nc"
> print filename1
> nc1 = Dataset(filename1, mode="r")
> for var in nc1.variables:
>   print var
> t2m = nc1.variables['T2m'][0,:,:]
> print t2m.shape
> lons1 = nc1.variables['lon'][:]
> lats1 = nc1.variables['lat'][:]
> x1,y1 = np.meshgrid(lons1, lats1)
> CS1 = m.contour(x1,y1,t2m,15,linewidths=0.5,colors='k')
> CS1 = m.contourf(x1,y1,t2m,cmap=plt.cm.jet)
> #############################
>
> m.drawcoastlines()
> m.drawmapboundary()
> #m.fillcontinents()
> # draw parallels and meridians.
> parallels = np.arange(-90,90,30)
> #m.drawparallels(parallels,labels=[1,0,0,1])
> m.drawparallels(parallels,labels=[1,0,0,1])
> meridians = np.arange(0,357.5,30)
> m.drawmeridians(meridians,labels=[1,0,0,1])
> plt.title('Plotted Grid')
> plt.show()
>
> ---------------------------------------
> Bruce W. Ford
> Clear Science, Inc.
> br...@cl...
> http://www.ClearScienceInc.com
> http://www.facebook.com/clearscience
> http://www.twitter.com/ROVs_rule
> Phone: (904) 796-8101
> Fax: (904) 379-9704
> 8241 Parkridge Circle N.
> Jacksonville, FL 32211
> Skype: bruce.w.ford
>
>
I would double-check the shapes of x1 and y1 to make sure it matches
t2m's shape. You shouldn't need another Basemap object.
Ben Root
From: Benjamin R. <ben...@ou...> - 2011年06月07日 21:46:11
On Saturday, June 4, 2011, Eric Firing <ef...@ha...> wrote:
>
>
> https://github.com/efiring/matplotlib/blob/faq_show_draw/doc/faq/usage_faq.rst
>
> Eric, Ben,
>
> See if the section "What is interactive mode" makes sense to you. I have just added it to a feature branch (which includes some other faq madifications, mainly moving the backend section from installation to usage), but have not yet generated a pull request. It doesn't go into every detail, or into the underlying machinery. It is intended to provide just enough understanding to clear up user-level confusion about interactive mode, show, and draw, and let most relatively new users get on with their work.
>
> Eric
>
Eric,
I see where you are going with this, and this is valuable information
to include in the docs. However, the interactive mode and backend info
doesn't seem to fit properly with everything else on the page. I am
not sure where to put them yet, but I will see if I can take a deeper
look tomorrow. I also already noticed some other wording issues in
some other parts of that page.
Ben Root
From: Eric F. <ef...@ha...> - 2011年06月07日 19:48:58
Attachments: test_subplots.py
On 06/07/2011 01:37 AM, Daniel Mader wrote:
> Hi Eric,
>
>
> 2011年6月6日 Eric Firing<ef...@ha...>:
>> It's not quite clear to me yet, but I assume you want to use a call to
>> imshow with a different data set in the second subplot, but have the
>> color scale and colorbar be identical to those in the first subplot. Is
>> that correct? If so, all you need to do is use the same norm for both
>> calls to imshow--that is, define a norm, set the limits you want on it,
>> and supply it as a kwarg.
>
> thanks a lot, you helped me to work around my problem, see code below :)
>
>> Also, for this sort of comparison, sometimes it is more efficient to use
>> a single colorbar for multiple panels, as in this example:
>>
>> http://matplotlib.sourceforge.net/examples/pylab_examples/multi_image.html
>
> Very nice example! It's a little too complex for me, though, with all
> the calculations for the axes layout -- I prefer subplots :) However,
> I think I have found a nice compromise:
Attached is a slight modification, much simpler than the example above, 
but retaining the single colorbar. Alternatively, if you stick with the 
colorbar for each panel (which is sometimes clearer), it illustrates a 
slightly clearer way of handling the cmap and norm, explicitly using the 
same instance of each for both images.
Eric
>
> import pylab
> import matplotlib as mpl
>
> pylab.close('all')
>
> dat = pylab.array([[1,2,3,4],[5,6,7,8]])
> datT = dat/2
>
> fig = pylab.figure()
>
> ax1 = fig.add_subplot(211)
> ax1.set_title('raw data')
> im1 = ax1.imshow(dat, interpolation='nearest',
> cmap=mpl.cm.get_cmap('rainbow', 20))
> fig.colorbar(im1)
>
> ax2 = fig.add_subplot(212)
> ax2.set_title('leveled')
> im2 = ax2.imshow(datT, interpolation='nearest',
> cmap=mpl.cm.get_cmap('rainbow', 20))
> ## apply norm:
> norm = mpl.colors.Normalize(vmin=dat.min(), vmax=dat.max())
> im2.set_norm(norm)
> fig.colorbar(im2)
>
> ## doesn't really work :/
> cax = fig.add_axes([0.25, 0.04, 0.5, 0.02])
> fig.colorbar(im2, cax, orientation='horizontal')
>
> pylab.show()
>
> Thanks a lot,
> best regards,
>
> Daniel
From: Jonno <jon...@gm...> - 2011年06月07日 18:51:37
I've been looking at the matplotlib wx example here:
http://matplotlib.sourceforge.net/examples/user_interfaces/embedding_in_wx5.html
I was trying to remove the close buttons from the tabs and from what I
can tell they shouldn't be there since the default style isn't
supposed to have close buttons.
Can anyone help?
From: Daniel M. <dan...@go...> - 2011年06月07日 11:37:59
Hi Eric,
2011年6月6日 Eric Firing <ef...@ha...>:
> It's not quite clear to me yet, but I assume you want to use a call to
> imshow with a different data set in the second subplot, but have the
> color scale and colorbar be identical to those in the first subplot. Is
> that correct? If so, all you need to do is use the same norm for both
> calls to imshow--that is, define a norm, set the limits you want on it,
> and supply it as a kwarg.
thanks a lot, you helped me to work around my problem, see code below :)
> Also, for this sort of comparison, sometimes it is more efficient to use
> a single colorbar for multiple panels, as in this example:
>
> http://matplotlib.sourceforge.net/examples/pylab_examples/multi_image.html
Very nice example! It's a little too complex for me, though, with all
the calculations for the axes layout -- I prefer subplots :) However,
I think I have found a nice compromise:
import pylab
import matplotlib as mpl
pylab.close('all')
dat = pylab.array([[1,2,3,4],[5,6,7,8]])
datT = dat/2
fig = pylab.figure()
ax1 = fig.add_subplot(211)
ax1.set_title('raw data')
im1 = ax1.imshow(dat, interpolation='nearest',
cmap=mpl.cm.get_cmap('rainbow', 20))
fig.colorbar(im1)
ax2 = fig.add_subplot(212)
ax2.set_title('leveled')
im2 = ax2.imshow(datT, interpolation='nearest',
cmap=mpl.cm.get_cmap('rainbow', 20))
## apply norm:
norm = mpl.colors.Normalize(vmin=dat.min(), vmax=dat.max())
im2.set_norm(norm)
fig.colorbar(im2)
## doesn't really work :/
cax = fig.add_axes([0.25, 0.04, 0.5, 0.02])
fig.colorbar(im2, cax, orientation='horizontal')
pylab.show()
Thanks a lot,
best regards,
Daniel
From: Scott S. <sco...@gm...> - 2011年06月07日 10:20:42
On 7 June 2011 11:32, Klonuo Umom <kl...@gm...> wrote:
> I have very simple XY graph, and I want to display X grid only, and only
> on values of X variable, which are lets say [10, 11, 12, 15, 20]
This is a question for the Matplotlib list
(https://lists.sourceforge.net/lists/listinfo/matplotlib-users).
In any case, this should do what you want:
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(range(5))
ticks = [1.2, 2.3, 3.1, 4]
ax.xaxis.set_ticks(ticks)
ax.xaxis.grid()
plt.show()
Cheers,
Scott
From: Benjamin R. <ben...@ou...> - 2011年06月07日 05:06:57
On Monday, June 6, 2011, Bruce Ford <br...@cl...> wrote:
> Does anyone have an example of nested grids.
> I need to (for instance), plot a global grid in filled contours, then plot another, higher resolution grid over the US.The global grid could work something like this, but I'm not sure where to start with the 2nd (nested) grid to go atop.
>
>
> fig=plt.figure()m = Basemap(resolution='c',projection='cyl',llcrnrlon=lon1,llcrnrlat=lat1,\      urcrnrlon=lon2,urcrnrlat=lat2)# make a filled contour plot.
>
> x, y = m(lons, lats)CS = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')CS = m.contourf(x,y,hgt,15,cmap=plt.cm.jet)m.drawcoastlines()m.drawmapboundary()
> m.fillcontinents()
> # draw parallels and meridians.parallels = np.arange(-90,90,10)#m.drawparallels(parallels,labels=[1,0,0,1])m.drawparallels(parallels,labels=[1,0,0,1])meridians = np.arange(-180.,180.,10.)
>
> m.drawmeridians(meridians,labels=[1,0,0,1])plt.title('Plotted Grid')plt.show()
> Thanks!
> Bruce
> ---------------------------------------
> Bruce W. Ford
> Clear Science, Inc.
> br...@cl...
>
>
>
>
>
It should just work as you expect. Do the global contour with the
coarser x/y data, and then do the US contour with finer x/y data.
Ben Root
From: Bruce F. <br...@cl...> - 2011年06月06日 23:19:08
Does anyone have an example of nested grids.
I need to (for instance), plot a global grid in filled contours, then plot
another, higher resolution grid over the US.
The global grid could work something like this, but I'm not sure where to
start with the 2nd (nested) grid to go atop.
fig=plt.figure()
m = Basemap(resolution='c',projection='cyl',llcrnrlon=lon1,llcrnrlat=lat1,\
 urcrnrlon=lon2,urcrnrlat=lat2)
# make a filled contour plot.
x, y = m(lons, lats)
CS = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
CS = m.contourf(x,y,hgt,15,cmap=plt.cm.jet)
m.drawcoastlines()
m.drawmapboundary()
m.fillcontinents()
# draw parallels and meridians.
parallels = np.arange(-90,90,10)
#m.drawparallels(parallels,labels=[1,0,0,1])
m.drawparallels(parallels,labels=[1,0,0,1])
meridians = np.arange(-180.,180.,10.)
m.drawmeridians(meridians,labels=[1,0,0,1])
plt.title('Plotted Grid')
plt.show()
Thanks!
Bruce
---------------------------------------
Bruce W. Ford
Clear Science, Inc.
br...@cl...
From: Eric F. <ef...@ha...> - 2011年06月06日 21:48:37
On 06/06/2011 11:33 AM, Daniel Mader wrote:
> Hi all,
>
> I'd like to compare two sets of data by using subplots and imshow(). I
> have two issues with this:
>
> 1) how can I have a colorbar in each subplot?
> 2) how can I adjust the range limits for a colorbar, so that the
> comparison possible?
>
> Below is code which could serve as a starting point, I hope it helps
> to make my problem clearer...
It's not quite clear to me yet, but I assume you want to use a call to 
imshow with a different data set in the second subplot, but have the 
color scale and colorbar be identical to those in the first subplot. Is 
that correct? If so, all you need to do is use the same norm for both 
calls to imshow--that is, define a norm, set the limits you want on it, 
and supply it as a kwarg.
Also, for this sort of comparison, sometimes it is more efficient to use 
a single colorbar for multiple panels, as in this example:
 http://matplotlib.sourceforge.net/examples/pylab_examples/multi_image.html
Eric
>
> Thanks and best regards,
> Daniel
>
> import pylab
> #import matplotlib as mpl
> import matplotlib.cm as cm # colormaps
> #import matplotlib.colors as col # colormaps
>
> pylab.close('all')
>
> dat = pylab.array([[1,2,3,4],[5,6,7,8]])
> datT = dat/2
>
> fig = pylab.figure()
>
> ax1 = fig.add_subplot(211)
> ax1.set_title('raw data')
> im = ax.imshow(dat, interpolation='nearest', cmap=cm.get_cmap('rainbow', 20))
> fig.colorbar(im)
>
> ax2 = fig.add_subplot(212)
> ax2.set_title('transformed')
> ''' here is missing:
> a 2nd colorbar with the same limit than in the first subfig, i.e. 1..8
> '''
>
> pylab.show()
>
> ------------------------------------------------------------------------------
> EditLive Enterprise is the world's most technically advanced content
> authoring tool. Experience the power of Track Changes, Inline Image
> Editing and ensure content is compliant with Accessibility Checking.
> http://p.sf.net/sfu/ephox-dev2dev
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Daniel M. <dan...@go...> - 2011年06月06日 21:34:14
Hi all,
I'd like to compare two sets of data by using subplots and imshow(). I
have two issues with this:
1) how can I have a colorbar in each subplot?
2) how can I adjust the range limits for a colorbar, so that the
comparison possible?
Below is code which could serve as a starting point, I hope it helps
to make my problem clearer...
Thanks and best regards,
Daniel
import pylab
#import matplotlib as mpl
import matplotlib.cm as cm # colormaps
#import matplotlib.colors as col # colormaps
pylab.close('all')
dat = pylab.array([[1,2,3,4],[5,6,7,8]])
datT = dat/2
fig = pylab.figure()
ax1 = fig.add_subplot(211)
ax1.set_title('raw data')
im = ax.imshow(dat, interpolation='nearest', cmap=cm.get_cmap('rainbow', 20))
fig.colorbar(im)
ax2 = fig.add_subplot(212)
ax2.set_title('transformed')
''' here is missing:
a 2nd colorbar with the same limit than in the first subfig, i.e. 1..8
'''
pylab.show()
From: thecommexokid <the...@gm...> - 2011年06月06日 18:09:35
I found a solution after all, from 
http://old.nabble.com/_backend_gdk-not-found-td26514059.html#a26514059 the
thread I mentioned in the original post, which turned out not to be as
cryptic as I had thought.
Just as the answerer there suggested, I had PyGTK but matplotlib wasn't
recognizing it during build; when I tried building from source instead of
using macports this was made clear in the build output.
As he said, I searched my computer to find a file called pygtk-2.0.pc, and
added the directory it was in to the system variable PKG_CONFIG_PATH. After
I did that, the build was successful and I had no further problems!
Thanks to everyone who may have read my post, but I would up figuring this
one out on my own.
thecommexokid wrote:
> 
> 
Hi all,
> 
> 
I am new to the forum and to all things PyGTK and matplotlib, so go easy on
me, please.
> 
> 
A colleague created a Python program that uses matplotlib and GTK. I wanted
to be able run her program on my MacBook (OS X 10.6.7). I used macports to
update/obtain Python 2.7, matplotlib 1.0.1, and PyGTK 2.22.0. (I also
obtained ipython, if anyone cares.)
> 
> 
After all of this, my colleague's program hits a snag when I try to run it;
here is the traceback:
> 
> 
Traceback (most recent call last):
> 
&nbsp;&nbsp;File "main.py", line 5, in 
> 
&nbsp;&nbsp;&nbsp;&nbsp;from interface import Interface, Display, Controls
> 
&nbsp;&nbsp;File
"/Users/thecommexokid/Documents/CurrentProjects/Honors/DoubleSlit/interface.py",
line 5, in &lt;module&gt;
> 
&nbsp;&nbsp;&nbsp;&nbsp;from matplotlib.backends.backend_gtkagg import
FigureCanvasGTKAgg
> 
&nbsp;&nbsp;File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_gtkagg.py",
line 10, in &lt;module&gt;
> 
&nbsp;&nbsp;&nbsp;&nbsp;from matplotlib.backends.backend_gtk import gtk,
FigureManagerGTK, FigureCanvasGTK,\
> 
&nbsp;&nbsp;File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_gtk.py",
line 28, in &lt;module&gt;
> 
&nbsp;&nbsp;&nbsp;&nbsp;from matplotlib.backends.backend_gdk import
RendererGDK, FigureCanvasGDK
> 
&nbsp;&nbsp;File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_gdk.py",
line 29, in &lt;module&gt;
> 
&nbsp;&nbsp;&nbsp;&nbsp;from matplotlib.backends._backend_gdk import
pixbuf_get_pixels_array
> 
ImportError: No module named _backend_gdk
> 
> 
I believe I may be having the same problem as the user in 
http://old.nabble.com/_backend_gdk-not-found-td26514059.html#a26514059 this
post , but I am enough of a novice that the solution that was suggested
there just sounds like gobbletygook to me. If anybody wants to elaborate on
that so I can try it out, please do.
> 
> 
Anyhow, any advice anyone has on how to overcome this problem and get her
program running on my machine would be greatly appreciated. As I said, I am
new to these things, and I don't really understand the interplay between
Python, PyGTK, and matplotlib, so if there's crucial information I haven't
provided, or if this isn't the best forum in which to be asking this
question, let me know.
> 
> 
Thanks in advance for the help.
> 
> 
***
> 
> 
PS: I originally posted this question at the GTK+ Forums (
http://www.gtkforums.com/viewtopic.php?f=3&p=69969#p69969 thread ), but it
seemed as though this might be the more appropriate forum. I'll be sure to
keep both threads updated with any developments.
> 
-- 
View this message in context: http://old.nabble.com/ImportError-when-I-import-FigureCanvasGTKAgg%E2%80%94seeking-advice%21-tp31779648p31785774.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Mannucci, A. J (335G) <ant...@jp...> - 2011年06月06日 15:52:17
Benjamin,
Thanks. I will point out that the contourf in Basemap behaves differently than that contourf in pylab. That is, in pylab, for
contour(X,Y,Z)
X,Y can be 1D whereas Z must be 2D.
However, it appears that for contourf in Basemap:
from mpl_toolkits.basemap import Basemap
m=Basemap()
g=m.contourf(X,Y,Z)
X,Y and Z must all be 2D.
-Tony
--
Tony Mannucci
Supervisor, Ionospheric and Atmospheric Remote Sensing Group
 Mail-Stop 138-308, Tel > (818) 354-1699
 Jet Propulsion Laboratory, Fax > (818) 393-5115
 California Institute of Technology, Email > Ton...@jp...<mailto:Ton...@jp...>
 4800 Oak Grove Drive, http://genesis.jpl.nasa.gov
 Pasadena, CA 91109
From: Benjamin Root <ben...@ou...<mailto:ben...@ou...>>
Date: 2011年5月31日 08:50:22 -0700
To: Tony Mannucci <Ant...@jp...<mailto:Ant...@jp...>>
Cc: "mat...@li...<mailto:mat...@li...>" <mat...@li...<mailto:mat...@li...>>
Subject: Re: [Matplotlib-users] Input array dimensions for contour or contourf
On Tue, May 31, 2011 at 10:34 AM, Mannucci, Anthony J (335G) <ant...@jp...<mailto:ant...@jp...>> wrote:
The following program seems to work with contour/contourf. However the documentation for the contourf function states
contour(X,Y,Z)
"X, Y, and Z must be arrays with the same dimensions."
I am finding that contour works if the dimension of X and Y are 1, but Z must be two-dimensional. The following program seems to bear this out. Are the arrays x and y below two-dimensional, or is the documentation misleading? Thanks for your help.
import numpy as N
import pylab as PLT
lons = N.linspace(-5.,5.,5) # Is this a one or two dimensional array?
lats = N.linspace(-3.,3.,4)
z = N.zeros((len(lats), len(lons)))
for i in range(len(lons)):
 for j in range(len(lats)):
 z[j,i]=i+j
PLT.clf()
PLT.contourf(lons,lats,z)
PLT.colorbar()
PLT.show()
-Tony
Tony,
contour and contourf seems to take advantage of numpy's broadcasting feature, so it is probably more correct to say that X and Y must be at least broadcastable to the shape of Z. I think there are a number of functions where this may or may not be true, and at some point we (the developers) should agree on basic input array handling and make it consistent across all plotting functions.
So, technically speaking, the docs are "right", but should be clearer in this case. I will add it to my doc-fixing commit that I will do today.
Ben Root
From: Angel Yanguas-G. <ang...@gm...> - 2011年06月05日 23:12:38
Hi, I am running matplotlib 1.0.0 on python 2.7.1 (r271:86882M, Nov 30
2010, 09:39:13) in snow leopard from python.org and I have come across
a problem saving pdf files.
Trying the simple script:
import matplotlib.pyplot as pt
pt.plot([1, 2, 3])
pt.savefig("figure.pdf")
Causes a bus error and a python crash.
There is a previous thread in the list that suggests that the problem
is not matplotlib related. However, that thread refers to EPD, which
is not my case. The apparent solution in that thread was deleting
DYLD_LIBRARY_PATH from .profile (don't understand why), but I don't
have such environment variable defined.
Has anyone come across anything like that?
Many thanks!
Angel
2 messages has been excluded from this view by a project administrator.

Showing results of 201

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