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





Showing results of 27

1 2 > >> (Page 1 of 2)
From: Jae-Joon L. <lee...@gm...> - 2009年11月11日 23:14:51
The bar command makes rectangles whose bottom position is 0.
The reason that bars disappear when you set log scale is that bottom
position of the bar become -infinity.
You may
 * set log scale before calling the bar
or
 * create bar plot but with reasonable (positive) bottom value. Take
a look at the docs.
Regards,
-JJ
On Wed, Nov 11, 2009 at 5:25 PM, per freem <per...@gm...> wrote:
> hi all,
>
> I am trying to make a simple bar graph that has its yaxis scale set to
> log. I use the following code:
>
> import matplotlib
> matplotlib.use('PDF')
> import matplotlib.pyplot as plt
> from matplotlib import rc
> rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
> plt.rcParams['ps.useafm'] = True
> rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
> plt.rcParams['pdf.fonttype'] = 42
> plt.rcParams['font.size'] = 10
>
> x = range(1, 11)
> y = [5000, 900, 600, 500, 200, 110, 50, 20, 10, 5]
> plt.figure(figsize=(5, 5), dpi=300)
> plt.bar(x, y)
> plt.gca().set_yscale('log')
> plt.savefig('test_logscale.pdf')
>
> the problem is that the bar graphs do not appear -- instead, i simply
> get horizontal lines around where the top of the bar graph should
> appear. Any idea how to fix this?
>
> also, sometimes the x axis disappears when i try this. thanks.
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Jae-Joon L. <lee...@gm...> - 2009年11月11日 23:06:43
I'm not exactly sure what you're trying to do. but I think what you
want can be easily achieved by simply using the masked array. Is the
example below similar to what you need?
a = np.arange(100).reshape((10,10))
m1 = np.triu(a, 1) > 0
m2 = np.tril(a, -1) > 0
#m2 = ~m1
am1 = np.ma.array(a, mask=m1)
am2 = np.ma.array(a, mask=m2)
pcolormesh(am1, cmap=plt.cm.jet)
pcolormesh(am2, cmap=plt.cm.gray)
-JJ
On Wed, Nov 11, 2009 at 12:11 PM, Christian Meesters
<mee...@im...> wrote:
> Hi,
>
> Is there a way to somehow squeeze two datasets with two different color
> maps into one pcolormesh? Say one dataset occupies one triangle (e. g.
> numpy.triu(dataset1, 1)) and the second dataset a different area (e. g.
> numpy.tril(dataset2, -1)) and then paste the two datasets in one
> pcolormesh (e.g. pylab.pcolormesh(numpy.triu(dataset1, 1) +
> numpy.tril(dataset2, -1)) ). This will obviously share one colormap. But
> does anybody know a trick to use two different ones?
>
> TIA
> Christian
>
> PS Forgot to thank Eric Firing for his tip last time I asked. Thank you
> Eric: You solved my problem!
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Gökhan S. <gok...@gm...> - 2009年11月11日 22:54:46
On Wed, Nov 11, 2009 at 4:25 PM, per freem <per...@gm...> wrote:
> hi all,
>
> I am trying to make a simple bar graph that has its yaxis scale set to
> log. I use the following code:
>
> import matplotlib
> matplotlib.use('PDF')
> import matplotlib.pyplot as plt
> from matplotlib import rc
> rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
> plt.rcParams['ps.useafm'] = True
> rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
> plt.rcParams['pdf.fonttype'] = 42
> plt.rcParams['font.size'] = 10
>
> x = range(1, 11)
> y = [5000, 900, 600, 500, 200, 110, 50, 20, 10, 5]
> plt.figure(figsize=(5, 5), dpi=300)
> plt.bar(x, y)
It should work scaling from within the bar()
plt.bar(x, y, log=True)
# plt.gca().set_yscale('log')
> plt.savefig('test_logscale.pdf')
>
> the problem is that the bar graphs do not appear -- instead, i simply
> get horizontal lines around where the top of the bar graph should
> appear. Any idea how to fix this?
>
> also, sometimes the x axis disappears when i try this. thanks.
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
-- 
Gökhan
From: Pauli V. <pa...@ik...> - 2009年11月11日 22:30:56
2009年11月10日 23:45:10 -0800, shriv wrote:
> I am a very new user to both python and matplotlib so please beware that
> my questions might be a real no-brainer. Here goes: I have a 3D array of
> data that I isolated from a much larger dataset. The first two columns
> are the x and y positions while the third is the intensity at the
> position (xi, yi). I would like to produce a colour map of the intensity
> as a function of x and y positions. Numerous tries with pcolor have got
> me nowhere. I constantly get an error message saying "Too many indices".
You need to regrid your data on a regular grid, not at scattered
positions. See 
http://matplotlib.sourceforge.net/api/mlab_api.html#matplotlib.mlab.griddata
-- 
Pauli Virtanen
From: per f. <per...@gm...> - 2009年11月11日 22:25:26
hi all,
I am trying to make a simple bar graph that has its yaxis scale set to
log. I use the following code:
import matplotlib
matplotlib.use('PDF')
import matplotlib.pyplot as plt
from matplotlib import rc
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
plt.rcParams['ps.useafm'] = True
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['font.size'] = 10
x = range(1, 11)
y = [5000, 900, 600, 500, 200, 110, 50, 20, 10, 5]
plt.figure(figsize=(5, 5), dpi=300)
plt.bar(x, y)
plt.gca().set_yscale('log')
plt.savefig('test_logscale.pdf')
the problem is that the bar graphs do not appear -- instead, i simply
get horizontal lines around where the top of the bar graph should
appear. Any idea how to fix this?
also, sometimes the x axis disappears when i try this. thanks.
From: Eric F. <ef...@ha...> - 2009年11月11日 22:08:36
Ryan Neve wrote:
> Hello,
> In my filled contour plot: http://imgur.com/vXoCL.png
> There are faint lines between the contour levels. I think they are 
> yellow since they disappear in the yellow parts of the graph and are 
> most obvious in the red areas. Is there any way to get rid of these 
> lines? The number of contour levels is arbitrary, and I don't need them 
> emphasized with a moire pattern.
Try experimenting with the "antialiased" kwarg in your call to contourf. 
It is a boolean; see if a value of True or False gives a better result.
Eric
> 
> Thank you,
> 
> -Ryan
> 
> 
> ------------------------------------------------------------------------
> 
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
> trial. Simplify your report design, integration and deployment - and focus on 
> what you do best, core application coding. Discover what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: John H. <jd...@gm...> - 2009年11月11日 21:30:49
On Wed, Nov 11, 2009 at 3:22 PM, Shrividya Ravi <pen...@gm...> wrote:
> Thanks for your reply, Giorgio. I had a look at the documentation for pcolor
> but unfortunately, I can't pick out where I have gone wrong. I have attached
> my data array as a txt file. In ipython, I use the 'loadtxt' command to load
> the dataset and then assigned the variables x,y, and z to the first, second
> and third columns respectively. I then specified the meshgrid X,Y from the x
> and y arrays of my data and used pcolor(X,Y,z) to try and plot the color
> map.
You have to interpolate your 1D data onto a 2D grid --
# first load the data
In [504]: x,y,z = np.loadtxt('195pt52_T6.txt', unpack=True)
# create evenly sampled x and y vectors to interpolate onto
In [505]: xi = np.linspace(x.min(), x.max(), 20)
In [506]: yi = np.linspace(y.min(), y.max(), 20)
# use griddata to do the 2D interoplation
In [507]: Z = mlab.griddata(x, y, z, xi, yi)
In [508]: Z.shape
Out[508]: (20, 20)
# use meshgrid to create 2D grids of your 1D x and 1 data
In [509]: X, Y = np.meshgrid(xi, yi)
# pass all the 2D arrays to pcolor
In [510]: pcolor(X, Y, Z)
Out[510]: <matplotlib.collections.PolyCollection object at 0x113e6d8c>
Hope this helps!
From: Shrividya R. <pen...@gm...> - 2009年11月11日 21:23:05
0 0 195.552
-13.2 9 107.092
-13.2 11.6421 158.136
-13.2 14.2842 105.09
-13.2 16.9263 123.106
-13.2 19.5684 133.114
-13.2 22.2105 93.0799
-13.2 24.8526 91.0782
-13.2 27.4947 83.0713
-13.2 30.1368 89.0765
-13.2 32.7789 97.0834
-13.2 35.4211 89.0765
-13.2 38.0632 93.0799
-13.2 40.7053 92.0791
-13.2 43.3474 86.0739
-13.2 45.9895 90.0773
-13.2 48.6316 89.0765
-13.2 51.2737 89.0765
-13.2 53.9158 88.0756
-13.2 56.5579 89.0765
-13.2 59.2 81.0696
-10.3895 9 107.092
-10.3895 11.6421 111.095
-10.3895 14.2842 123.106
-10.3895 16.9263 136.117
-10.3895 19.5684 133.114
-10.3895 22.2105 98.0842
-10.3895 24.8526 94.0808
-10.3895 27.4947 96.0825
-10.3895 30.1368 93.0799
-10.3895 32.7789 86.0739
-10.3895 35.4211 91.0782
-10.3895 38.0632 93.0799
-10.3895 40.7053 92.0791
-10.3895 43.3474 82.0705
-10.3895 45.9895 83.0713
-10.3895 48.6316 91.0782
-10.3895 51.2737 97.0834
-10.3895 53.9158 94.0808
-10.3895 56.5579 108.093
-10.3895 59.2 88.0756
-7.57895 9 81.0696
-7.57895 11.6421 83.0713
-7.57895 14.2842 89.0765
-7.57895 16.9263 93.0799
-7.57895 19.5684 87.0748
-7.57895 22.2105 100.086
-7.57895 24.8526 83.0713
-7.57895 27.4947 96.0825
-7.57895 30.1368 85.073
-7.57895 32.7789 94.0808
-7.57895 35.4211 87.0748
-7.57895 38.0632 87.0748
-7.57895 40.7053 100.086
-7.57895 43.3474 94.0808
-7.57895 45.9895 89.0765
-7.57895 48.6316 89.0765
-7.57895 51.2737 98.0842
-7.57895 53.9158 86.0739
-7.57895 56.5579 94.0808
-7.57895 59.2 87.0748
-4.76842 9 92.0791
-4.76842 11.6421 86.0739
-4.76842 14.2842 93.0799
-4.76842 16.9263 89.0765
-4.76842 19.5684 85.073
-4.76842 22.2105 97.0834
-4.76842 24.8526 84.0722
-4.76842 27.4947 98.0842
-4.76842 30.1368 93.0799
-4.76842 32.7789 89.0765
-4.76842 35.4211 79.0679
-4.76842 38.0632 96.0825
-4.76842 40.7053 97.0834
-4.76842 43.3474 91.0782
-4.76842 45.9895 86.0739
-4.76842 48.6316 82.0705
-4.76842 51.2737 104.089
-4.76842 53.9158 100.086
-4.76842 56.5579 97.0834
-4.76842 59.2 91.0782
-1.95789 9 102.088
-1.95789 11.6421 82.0705
-1.95789 14.2842 101.087
-1.95789 16.9263 95.0816
-1.95789 19.5684 82.0705
-1.95789 22.2105 89.0765
-1.95789 24.8526 92.0791
-1.95789 27.4947 103.089
-1.95789 30.1368 85.073
-1.95789 32.7789 81.0696
-1.95789 35.4211 96.0825
-1.95789 38.0632 85.073
-1.95789 40.7053 94.0808
-1.95789 43.3474 85.073
-1.95789 45.9895 94.0808
-1.95789 48.6316 91.0782
-1.95789 51.2737 93.0799
-1.95789 53.9158 87.0748
-1.95789 56.5579 109.094
-1.95789 59.2 90.0773
0.852632 9 103.089
0.852632 11.6421 89.0765
0.852632 14.2842 84.0722
0.852632 16.9263 95.0816
0.852632 19.5684 95.0816
0.852632 22.2105 86.0739
0.852632 24.8526 91.0782
0.852632 27.4947 96.0825
0.852632 30.1368 87.0748
0.852632 32.7789 95.0816
0.852632 35.4211 98.0842
0.852632 38.0632 92.0791
0.852632 40.7053 88.0756
0.852632 43.3474 85.073
0.852632 45.9895 93.0799
0.852632 48.6316 84.0722
0.852632 51.2737 89.0765
0.852632 53.9158 78.067
0.852632 56.5579 100.086
0.852632 59.2 96.0825
3.66316 9 83.0713
3.66316 11.6421 94.0808
3.66316 14.2842 91.0782
3.66316 16.9263 85.073
3.66316 19.5684 90.0773
3.66316 22.2105 90.0773
3.66316 24.8526 81.0696
3.66316 27.4947 94.0808
3.66316 30.1368 100.086
3.66316 32.7789 92.0791
3.66316 35.4211 85.073
3.66316 38.0632 100.086
3.66316 40.7053 92.0791
3.66316 43.3474 80.0687
3.66316 45.9895 91.0782
3.66316 48.6316 88.0756
3.66316 51.2737 94.0808
3.66316 53.9158 96.0825
3.66316 56.5579 86.0739
3.66316 59.2 92.0791
6.47368 9 97.0834
6.47368 11.6421 104.089
6.47368 14.2842 80.0687
6.47368 16.9263 87.0748
6.47368 19.5684 118.101
6.47368 22.2105 120.103
6.47368 24.8526 86.0739
6.47368 27.4947 91.0782
6.47368 30.1368 81.0696
6.47368 32.7789 90.0773
6.47368 35.4211 84.0722
6.47368 38.0632 90.0773
6.47368 40.7053 83.0713
6.47368 43.3474 87.0748
6.47368 45.9895 92.0791
6.47368 48.6316 97.0834
6.47368 51.2737 91.0782
6.47368 53.9158 91.0782
6.47368 56.5579 96.0825
6.47368 59.2 103.089
9.28421 9 104.089
9.28421 11.6421 104.089
9.28421 14.2842 117.101
9.28421 16.9263 93.0799
9.28421 19.5684 106.091
9.28421 22.2105 97.0834
9.28421 24.8526 96.0825
9.28421 27.4947 94.0808
9.28421 30.1368 89.0765
9.28421 32.7789 89.0765
9.28421 35.4211 97.0834
9.28421 38.0632 84.0722
9.28421 40.7053 91.0782
9.28421 43.3474 88.0756
9.28421 45.9895 95.0816
9.28421 48.6316 97.0834
9.28421 51.2737 94.0808
9.28421 53.9158 94.0808
9.28421 56.5579 83.0713
9.28421 59.2 89.0765
12.0947 9 96.0825
12.0947 11.6421 90.0773
12.0947 14.2842 91.0782
12.0947 16.9263 92.0791
12.0947 19.5684 88.0756
12.0947 22.2105 94.0808
12.0947 24.8526 93.0799
12.0947 27.4947 97.0834
12.0947 30.1368 90.0773
12.0947 32.7789 100.086
12.0947 35.4211 91.0782
12.0947 38.0632 81.0696
12.0947 40.7053 85.073
12.0947 43.3474 98.0842
12.0947 45.9895 92.0791
12.0947 48.6316 87.0748
12.0947 51.2737 93.0799
12.0947 53.9158 91.0782
12.0947 56.5579 85.073
12.0947 59.2 90.0773
14.9053 9 108.093
14.9053 11.6421 93.0799
14.9053 14.2842 79.0679
14.9053 16.9263 89.0765
14.9053 19.5684 86.0739
14.9053 22.2105 94.0808
14.9053 24.8526 98.0842
14.9053 27.4947 81.0696
14.9053 30.1368 94.0808
14.9053 32.7789 89.0765
14.9053 35.4211 94.0808
14.9053 38.0632 100.086
14.9053 40.7053 101.087
14.9053 43.3474 81.0696
14.9053 45.9895 105.09
14.9053 48.6316 99.0851
14.9053 51.2737 88.0756
14.9053 53.9158 96.0825
14.9053 56.5579 87.0748
14.9053 59.2 92.0791
17.7158 9 119.102
17.7158 11.6421 96.0825
17.7158 14.2842 86.0739
17.7158 16.9263 83.0713
17.7158 19.5684 92.0791
17.7158 22.2105 85.073
17.7158 24.8526 84.0722
17.7158 27.4947 94.0808
17.7158 30.1368 90.0773
17.7158 32.7789 92.0791
17.7158 35.4211 101.087
17.7158 38.0632 115.099
17.7158 40.7053 95.0816
17.7158 43.3474 93.0799
17.7158 45.9895 83.0713
17.7158 48.6316 94.0808
17.7158 51.2737 103.089
17.7158 53.9158 111.095
17.7158 56.5579 95.0816
17.7158 59.2 86.0739
20.5263 9 197.169
20.5263 11.6421 100.086
20.5263 14.2842 82.0705
20.5263 16.9263 89.0765
20.5263 19.5684 86.0739
20.5263 22.2105 85.073
20.5263 24.8526 91.0782
20.5263 27.4947 95.0816
20.5263 30.1368 100.086
20.5263 32.7789 102.088
20.5263 35.4211 93.0799
20.5263 38.0632 91.0782
20.5263 40.7053 91.0782
20.5263 43.3474 104.089
20.5263 45.9895 105.09
20.5263 48.6316 590.507
20.5263 51.2737 141.121
20.5263 53.9158 87.0748
20.5263 56.5579 90.0773
20.5263 59.2 86.0739
23.3368 9 150.129
23.3368 11.6421 103.089
23.3368 14.2842 91.0782
23.3368 16.9263 105.09
23.3368 19.5684 88.0756
23.3368 22.2105 91.0782
23.3368 24.8526 85.073
23.3368 27.4947 91.0782
23.3368 30.1368 96.0825
23.3368 32.7789 86.0739
23.3368 35.4211 87.0748
23.3368 38.0632 98.0842
23.3368 40.7053 94.0808
23.3368 43.3474 91.0782
23.3368 45.9895 101.087
23.3368 48.6316 181.156
23.3368 51.2737 120.103
23.3368 53.9158 80.0687
23.3368 56.5579 92.0791
23.3368 59.2 96.0825
26.1474 9 97.0834
26.1474 11.6421 90.0773
26.1474 14.2842 83.0713
26.1474 16.9263 84.0722
26.1474 19.5684 90.0773
26.1474 22.2105 98.0842
26.1474 24.8526 92.0791
26.1474 27.4947 96.0825
26.1474 30.1368 102.088
26.1474 32.7789 97.0834
26.1474 35.4211 86.0739
26.1474 38.0632 84.0722
26.1474 40.7053 93.0799
26.1474 43.3474 112.096
26.1474 45.9895 98.0842
26.1474 48.6316 112.096
26.1474 51.2737 84.0722
26.1474 53.9158 91.0782
26.1474 56.5579 92.0791
26.1474 59.2 101.087
28.9579 9 78.067
28.9579 11.6421 89.0765
28.9579 14.2842 98.0842
28.9579 16.9263 90.0773
28.9579 19.5684 86.0739
28.9579 22.2105 94.0808
28.9579 24.8526 91.0782
28.9579 27.4947 94.0808
28.9579 30.1368 90.0773
28.9579 32.7789 94.0808
28.9579 35.4211 94.0808
28.9579 38.0632 91.0782
28.9579 40.7053 109.094
28.9579 43.3474 93.0799
28.9579 45.9895 93.0799
28.9579 48.6316 98.0842
28.9579 51.2737 101.087
28.9579 53.9158 97.0834
28.9579 56.5579 96.0825
28.9579 59.2 88.0756
31.7684 9 84.0722
31.7684 11.6421 103.089
31.7684 14.2842 86.0739
31.7684 16.9263 88.0756
31.7684 19.5684 90.0773
31.7684 22.2105 98.0842
31.7684 24.8526 85.073
31.7684 27.4947 87.0748
31.7684 30.1368 104.089
31.7684 32.7789 93.0799
31.7684 35.4211 95.0816
31.7684 38.0632 98.0842
31.7684 40.7053 110.095
31.7684 43.3474 93.0799
31.7684 45.9895 90.0773
31.7684 48.6316 111.095
31.7684 51.2737 91.0782
31.7684 53.9158 98.0842
31.7684 56.5579 105.09
31.7684 59.2 96.0825
34.5789 9 95.0816
34.5789 11.6421 85.073
34.5789 14.2842 97.0834
34.5789 16.9263 91.0782
34.5789 19.5684 83.0713
34.5789 22.2105 81.0696
34.5789 24.8526 94.0808
34.5789 27.4947 91.0782
34.5789 30.1368 102.088
34.5789 32.7789 84.0722
34.5789 35.4211 98.0842
34.5789 38.0632 86.0739
34.5789 40.7053 94.0808
34.5789 43.3474 98.0842
34.5789 45.9895 94.0808
34.5789 48.6316 83.0713
34.5789 51.2737 106.091
34.5789 53.9158 93.0799
34.5789 56.5579 76.0653
34.5789 59.2 97.0834
37.3895 9 97.0834
37.3895 11.6421 89.0765
37.3895 14.2842 109.094
37.3895 16.9263 200.172
37.3895 19.5684 82.0705
37.3895 22.2105 96.0825
37.3895 24.8526 97.0834
37.3895 27.4947 96.0825
37.3895 30.1368 90.0773
37.3895 32.7789 87.0748
37.3895 35.4211 95.0816
37.3895 38.0632 84.0722
37.3895 40.7053 98.0842
37.3895 43.3474 92.0791
37.3895 45.9895 88.0756
37.3895 48.6316 96.0825
37.3895 51.2737 93.0799
37.3895 53.9158 82.0705
37.3895 56.5579 96.0825
37.3895 59.2 86.0739
40.2 9 89.0765
40.2 11.6421 103.089
40.2 14.2842 93.0799
40.2 16.9263 89.0765
40.2 19.5684 85.073
40.2 22.2105 88.0756
40.2 24.8526 97.0834
40.2 27.4947 97.0834
40.2 30.1368 90.0773
40.2 32.7789 87.0748
40.2 35.4211 101.087
40.2 38.0632 106.091
40.2 40.7053 107.092
40.2 43.3474 103.089
40.2 45.9895 100.086
40.2 48.6316 94.0808
40.2 51.2737 97.0834
40.2 53.9158 87.0748
40.2 56.5579 96.0825
40.2 59.2 128.11
From: Ryan N. <ne...@em...> - 2009年11月11日 21:10:26
Hello,
In my filled contour plot: http://imgur.com/vXoCL.png
There are faint lines between the contour levels. I think they are yellow
since they disappear in the yellow parts of the graph and are most obvious
in the red areas. Is there any way to get rid of these lines? The number of
contour levels is arbitrary, and I don't need them emphasized with a moire
pattern.
Thank you,
-Ryan
From: Tony S Yu <to...@MI...> - 2009年11月11日 19:56:00
On Nov 11, 2009, at 1:33 PM, Michael Droettboom wrote:
> Which older revision (or release) worked as you expected?
After some digging, I think this issue is caused by an error in the 
macosx backend (everything works fine with tkagg, qt4agg, and agg). 
Oddly enough, calling savefig(), instead of show(), with the macosx 
backend creates the correct plot, but calling savefig() after show() 
does not.
I'm actually not sure if my code worked for older revisions of the 
macosx backend (I may have had a different default backend before). 
The transform code doesn't work with revisions between 7950 and 7625; 
older versions break the macosx backend on my system (OS X 10.6.1).
-Tony
>
> Mike
>
> Tony S Yu wrote:
>> Hi,
>>
>> Awhile back, Jae-Joon helped me transform collection sizes from 
>> points to data values by overriding the `get_transform` method of 
>> a RegularPolyCollection (see example code below).
>>
>> When I tried the code today, the collection didn't appear on the 
>> plot. Removing the get_transform method below brings the 
>> collection back, but of course, the sizes are not what I want.
>>
>> Some simple testing suggests that changing the transform returned 
>> by `get_transform` changes the offsets of the collection items. In 
>> other words, the transform originally (i.e. in some older 
>> revision) modified only the scale of collection items, but now 
>> appears to modify both the scale and offset.
>>
>> Is there a way to modify only the scale of collection items?
>>
>> Thanks,
>> -Tony
>>
>> BTW, I'm on svn r7950.
>>
>> #-----------------
>> # The squares will not show up with the code below
>> # Comment out the get_transform method to see squares
>> # Change scale_x and scale_y to values close to 1 to see how they 
>> change both scale and offset
>>
>> class SquareCollection(collections.RegularPolyCollection):
>> """Return a collection of squares."""
>>
>> def __init__(self, **kwargs):
>> super(SquareCollection, self).__init__(4, rotation=np.pi/ 
>> 4., **kwargs)
>>
>> def get_transform(self):
>> """Return transform scaling circle areas to data space."""
>> ax = self.axes
>> pts2pixels = 72.0 / ax.figure.dpi
>> scale_x = pts2pixels * ax.bbox.width / ax.viewLim.width
>> scale_y = pts2pixels * ax.bbox.height / ax.viewLim.height
>> return transforms.Affine2D().scale(scale_x, scale_y)
>>
>> ax = plt.gca()
>> circle_areas = np.pi * np.ones(4)
>> xy = [(0, 0), (0, 1), (1, 0), (1, 1)]
>> squares = SquareCollection(sizes=circle_areas,
>> offsets=xy, transOffset=ax.transData,
>> facecolor='black')
>> ax.add_collection(squares, autolim=True)
>> plt.axis([-0.5, 1.5, -0.5, 1.5])
>> plt.show()
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free Crystal Reports 
>> 2008 30-Day trial. Simplify your report design, integration and 
>> deployment - and focus on what you do best, core application 
>> coding. Discover what's new with
>> Crystal Reports now. http://p.sf.net/sfu/bobj-july
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>
> -- 
> Michael Droettboom
> Science Software Branch
> Operations and Engineering Division
> Space Telescope Science Institute
> Operated by AURA for NASA
>
From: Tom L. <le...@ih...> - 2009年11月11日 19:36:15
It looks like you are storing your source data in a python list. Matplotlib runs much faster if you store your data using a numpy array instead. 
I'm no expert, but it certianly sped up my graph drawing.
-Tom
Message: 5
Date: 2009年11月11日 08:53:58 -0600
From: Mike Anderson <mba...@wi...>
Subject: [Matplotlib-users] matplotlib slow compared to gnuplot?
To: mat...@li...
Message-ID: <AE4...@wi...>
Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes
Hi all,
Previously I was a user of gnuplot but have been giving matplotlib a 
try. One thing I've run in to right away is that matplotlib appears 
to be significantly slower.
A script to produce a dozen plots was taking me ~1 second with 
gnuplot, and now takes me ~18 seconds with matplotlib.
I'm curious if anyone knows how to speed things up. To figure out 
what is taking most of the time, I've used cProfile and pstats and 
below is the top 15 functions taking the most time.
 (note: "plotStackedJobsVsTime" is my function that uses matplotlib.)
My script, for the curious, is at
 http://www.hep.wisc.edu/cms/comp/routerqMonitor/prodJobMonitorPlots_matplotlib.py
and produces these plots:
 http://www.hep.wisc.edu/cms/comp/routerqMonitor/index.html
Any hints at what I can do to speed up my script? Or is it out of my 
hands because it's all in matplotlib?
Thanks for any help,
Mike
From: Michael D. <md...@st...> - 2009年11月11日 18:33:25
Which older revision (or release) worked as you expected?
Mike
Tony S Yu wrote:
> Hi,
>
> Awhile back, Jae-Joon helped me transform collection sizes from points 
> to data values by overriding the `get_transform` method of a 
> RegularPolyCollection (see example code below).
>
> When I tried the code today, the collection didn't appear on the plot. 
> Removing the get_transform method below brings the collection back, 
> but of course, the sizes are not what I want.
>
> Some simple testing suggests that changing the transform returned by 
> `get_transform` changes the offsets of the collection items. In other 
> words, the transform originally (i.e. in some older revision) modified 
> only the scale of collection items, but now appears to modify both the 
> scale and offset.
>
> Is there a way to modify only the scale of collection items?
>
> Thanks,
> -Tony
>
> BTW, I'm on svn r7950.
>
> #-----------------
> # The squares will not show up with the code below
> # Comment out the get_transform method to see squares
> # Change scale_x and scale_y to values close to 1 to see how they 
> change both scale and offset
>
> class SquareCollection(collections.RegularPolyCollection):
> """Return a collection of squares."""
>
> def __init__(self, **kwargs):
> super(SquareCollection, self).__init__(4, rotation=np.pi/4., 
> **kwargs)
>
> def get_transform(self):
> """Return transform scaling circle areas to data space."""
> ax = self.axes
> pts2pixels = 72.0 / ax.figure.dpi
> scale_x = pts2pixels * ax.bbox.width / ax.viewLim.width
> scale_y = pts2pixels * ax.bbox.height / ax.viewLim.height
> return transforms.Affine2D().scale(scale_x, scale_y)
>
> ax = plt.gca()
> circle_areas = np.pi * np.ones(4)
> xy = [(0, 0), (0, 1), (1, 0), (1, 1)]
> squares = SquareCollection(sizes=circle_areas,
> offsets=xy, transOffset=ax.transData,
> facecolor='black')
> ax.add_collection(squares, autolim=True)
> plt.axis([-0.5, 1.5, -0.5, 1.5])
> plt.show()
>
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
> trial. Simplify your report design, integration and deployment - and focus on 
> what you do best, core application coding. Discover what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
From: Tony S Yu <to...@MI...> - 2009年11月11日 18:21:30
Hi,
Awhile back, Jae-Joon helped me transform collection sizes from points 
to data values by overriding the `get_transform` method of a 
RegularPolyCollection (see example code below).
When I tried the code today, the collection didn't appear on the plot. 
Removing the get_transform method below brings the collection back, 
but of course, the sizes are not what I want.
Some simple testing suggests that changing the transform returned by 
`get_transform` changes the offsets of the collection items. In other 
words, the transform originally (i.e. in some older revision) modified 
only the scale of collection items, but now appears to modify both the 
scale and offset.
Is there a way to modify only the scale of collection items?
Thanks,
-Tony
BTW, I'm on svn r7950.
#-----------------
# The squares will not show up with the code below
# Comment out the get_transform method to see squares
# Change scale_x and scale_y to values close to 1 to see how they 
change both scale and offset
class SquareCollection(collections.RegularPolyCollection):
 """Return a collection of squares."""
 def __init__(self, **kwargs):
 super(SquareCollection, self).__init__(4, rotation=np.pi/4., 
**kwargs)
 def get_transform(self):
 """Return transform scaling circle areas to data space."""
 ax = self.axes
 pts2pixels = 72.0 / ax.figure.dpi
 scale_x = pts2pixels * ax.bbox.width / ax.viewLim.width
 scale_y = pts2pixels * ax.bbox.height / ax.viewLim.height
 return transforms.Affine2D().scale(scale_x, scale_y)
ax = plt.gca()
circle_areas = np.pi * np.ones(4)
xy = [(0, 0), (0, 1), (1, 0), (1, 1)]
squares = SquareCollection(sizes=circle_areas,
 offsets=xy, transOffset=ax.transData,
 facecolor='black')
ax.add_collection(squares, autolim=True)
plt.axis([-0.5, 1.5, -0.5, 1.5])
plt.show()
On Wed, Nov 11, 2009 at 11:53 AM, per freem <per...@gm...> wrote:
> hi all,
>
> i've been using genfromtxt to parse tab separated files for plotting
> purposes in matplotlib. the problem is that genfromtxt seems to give
> only two ways to access the contents of the file: one is by column,
> where you can use:
>
> d = genfromtxt(...)
>
> and then do d['header_name1'] to access the column named by
> 'header_name1', d['header_name2'] to access the column named by
> 'header_name2', etc. Or it will allow you to traverse the file line
> by line, and then access each header by number, i.e.
>
> for line in d:
> field1 = d[0]
> field2 = d[1]
> # etc.
>
> the problem is that the second method relies on knowing the order of
> the fields rather than just their name, and the first method does not
> allow line by line iteration.
> ideally what i would like is to be able to traverse each line of the
> parsed file, and then refer to each of its fields by header name, so
> that if the column order in the file changes my program will be
> unaffected:
>
> for line in d:
> field1 = ['header_name1']
> field2 = ['header_name2']
>
> is there a way to do this using standard matplotlib/numpy/scipy
> utilities? i could write my own code to do this but it seems like
> something somebody probably already thought of a good representation
> for and has implemented a more optimized version than i could write on
> my own. does such a thing exist?
>
> thanks very much
I have a constructor class to read space-delimited ASCII files.
class NasaFile(object):
 def __init__(self, filename):
 ...
 # Reading data
 _data = np.loadtxt(filename, dtype='float', skiprows=self.NLHEAD).T
 # Read using data['Time'] syntax
 self.data = dict(zip(self.VDESC, _data))
 ...
There is a meta-header in this type of data and NLHEAD is the variable
telling me how many lines to skip to reach the actual data. VDESC
tells me what each columns are (starting with Time variable and many
other different measurement results.)
There is not any column dependence in this case, and generically read
any length specifically formatted data. For instance:
from nasafile import NasaFile
c = NasaFile("mydata")
c.data['Time'] gets me the whole Time column as an ndarray . Why do
you think dictionaries are not sufficient for your case? I was using
locals() to create automatic names but that was not a very wise
approach.
> _______________________________________________
> NumPy-Discussion mailing list
> Num...@sc...
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-- 
Gökhan
> ideally what i would like is to be able to traverse each line of the
> parsed file, and then refer to each of its fields by header name, so
> that if the column order in the file changes my program will be
> unaffected:
What you want is a DictReader.
For a quick example of me using that,
----------
aReader = csv.DictReader(open(inputFilename, 'r'), delimiter='\t')
yValues = {} # Will be a dictionary of lists (these are lists of y- 
values)
xValues = [] # List of x values (timestamps)
for row in aReader:
	xValues.append(datetime.datetime(*(time.strptime(row 
['TimeStamp'],timeStampFormat)[0:6])))
	for field in sorted(row,reverse=True): # Read from last 
to first in field list
		if field=='TimeStamp': continue # Column of x-data
		if not field in yValues.keys():
			yValues[field] = [nt(row[field])] # Start list of the values 
in this column
		else:
			yValues[field].append(int(row[field])) # Add to list of values in 
this column
----------
Mike
hi all,
i've been using genfromtxt to parse tab separated files for plotting
purposes in matplotlib. the problem is that genfromtxt seems to give
only two ways to access the contents of the file: one is by column,
where you can use:
d = genfromtxt(...)
and then do d['header_name1'] to access the column named by
'header_name1', d['header_name2'] to access the column named by
'header_name2', etc. Or it will allow you to traverse the file line
by line, and then access each header by number, i.e.
for line in d:
 field1 = d[0]
 field2 = d[1]
 # etc.
the problem is that the second method relies on knowing the order of
the fields rather than just their name, and the first method does not
allow line by line iteration.
ideally what i would like is to be able to traverse each line of the
parsed file, and then refer to each of its fields by header name, so
that if the column order in the file changes my program will be
unaffected:
for line in d:
 field1 = ['header_name1']
 field2 = ['header_name2']
is there a way to do this using standard matplotlib/numpy/scipy
utilities? i could write my own code to do this but it seems like
something somebody probably already thought of a good representation
for and has implemented a more optimized version than i could write on
my own. does such a thing exist?
thanks very much
From: Claus <cla...@gm...> - 2009年11月11日 17:18:55
Hi,
I'm running matplotlib v 0.99.0.
I can create a 3D scatterplot, like this:
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = Axes3D(fig)
ax.scatter( ... )
so far so good.
Now, say I want to add a 2D contourplot (a "slice" of the 3D scatter 
contoured).
Is there some way how I can specify along which coordinates the 
contourplot is plotted, or is it always plotted on the (x,y) plane?
How I have tried this is by
from matplotlib.mlab import griddata
fi = griddata( ... )
ax.contourf(x,z,fi, ... )
# even though I specify z, it plots the contourf along the y axis.
Thank you all for any pointers,
Cheers,
Claus
From: Christian M. <mee...@im...> - 2009年11月11日 17:11:45
Hi,
Is there a way to somehow squeeze two datasets with two different color
maps into one pcolormesh? Say one dataset occupies one triangle (e. g.
numpy.triu(dataset1, 1)) and the second dataset a different area (e. g.
numpy.tril(dataset2, -1)) and then paste the two datasets in one
pcolormesh (e.g. pylab.pcolormesh(numpy.triu(dataset1, 1) +
numpy.tril(dataset2, -1)) ). This will obviously share one colormap. But
does anybody know a trick to use two different ones?
TIA
Christian
PS Forgot to thank Eric Firing for his tip last time I asked. Thank you
Eric: You solved my problem!
From: John <was...@gm...> - 2009年11月11日 15:40:56
It's actually just a nice part of the python language, setattr(a,
> 'foo', 'bar') is the same code as a.foo = bar. When working with
> NetCDF, the only time I've needed to use setarr (or getattr) is when
> the name of the attribute I want isn't a valid python identifier (like
> if an attribute has a - in it, e.g. 'unit-type').
>
>
Slick! Another great reason for python. Thanks for the rapid response.
From: Ryan M. <rm...@gm...> - 2009年11月11日 15:34:27
On Wed, Nov 11, 2009 at 9:26 AM, John <was...@gm...> wrote:
> No problem.. just wanted to make sure it would work and is 'pythonic'.
>
> I guess the biggest concern is that for others using the netcdf file, say
> from matlab or somewhere else, will be able to access the attributes.
>
> It seemed so easy to do it this way, I was curious why the tutorials suggest
> using setattr(), and I wonder if perhaps what I'm setting is not 'global' or
> perhaps wouldn't match some ISO or otherwise NetCDF standard??
It's actually just a nice part of the python language, setattr(a,
'foo', 'bar') is the same code as a.foo = bar. When working with
NetCDF, the only time I've needed to use setarr (or getattr) is when
the name of the attribute I want isn't a valid python identifier (like
if an attribute has a - in it, e.g. 'unit-type').
Ryan
-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
From: John <was...@gm...> - 2009年11月11日 15:26:45
No problem.. just wanted to make sure it would work and is 'pythonic'.
I guess the biggest concern is that for others using the netcdf file, say
from matlab or somewhere else, will be able to access the attributes.
It seemed so easy to do it this way, I was curious why the tutorials suggest
using setattr(), and I wonder if perhaps what I'm setting is not 'global' or
perhaps wouldn't match some ISO or otherwise NetCDF standard??
Thanks!
On Wed, Nov 11, 2009 at 4:03 PM, Ryan May <rm...@gm...> wrote:
> On Wed, Nov 11, 2009 at 7:31 AM, John [H2O] <was...@gm...> wrote:
> >
> > Hello, I'm trying to write a function to create a 'vanilla' NetCDF file
> to
> > which I can add data.
> >
> > So far I have created the following, which is designed to set up a netcdf
> > file for the addition of global or at least lat/lon datasets. My question
> > has to do with attribute setting. Is it valid to do what I'm doing below
> > "nco.attribute = attributevalue" or do you have to use the setattr
> function
> > as outlined in some tutorials?
> >
> > Thanks!
> >
> > def default_netcdf(nco_filename,
> > lon0=-179.5,lat0=-89.5,
> > nx=720,ny=360,
> > dx=0.5,dy=0.5):
> > """ add default attributes and dimensions to the nc file """
> > nco = NetCDFFile(nco_filename,'w')
> > nco.author = "Some One"
> > nco.createdate = dt.datetime.now().ctime()
> > nco.contact = "som...@py..."
> > nco.Conventions = "CF-1.4"
> >
> > nco.createDimension('lon',nx)
> > nco.createDimension('lat',ny)
> > nco.createVariable('lat','d',('lat',))
> > nco.createVariable('lon','d',('lon',))
> > lon = np.arange(lon0,lon0+(nx*dx),dx)
> > lat = np.arange(lat0,lat0+(ny*dy),dy)
> > nco.variables['lat'][:] = lat
> > nco.variables['lon'][:] = lon
> > nco.createVariable('data','d',('lon','lat'))
> >
> > return nco
>
> That should work fine for settings attributes. Are you having a
> problem? If so, can you paste the actual traceback?
>
> Ryan
>
> --
> Ryan May
> Graduate Research Assistant
> School of Meteorology
> University of Oklahoma
>
-- 
Configuration
``````````````````````````
Plone 2.5.3-final,
CMF-1.6.4,
Zope (Zope 2.9.7-final, python 2.4.4, linux2),
Five 1.4.1,
Python 2.4.4 (#1, Jul 3 2007, 22:58:17) [GCC 4.1.1 20070105 (Red Hat
4.1.1-51)],
PIL 1.1.6
Mailman 2.1.9
Postfix 2.4.5
Procmail v3.22 2001年09月10日
From: Ryan M. <rm...@gm...> - 2009年11月11日 15:04:00
On Wed, Nov 11, 2009 at 7:31 AM, John [H2O] <was...@gm...> wrote:
>
> Hello, I'm trying to write a function to create a 'vanilla' NetCDF file to
> which I can add data.
>
> So far I have created the following, which is designed to set up a netcdf
> file for the addition of global or at least lat/lon datasets. My question
> has to do with attribute setting. Is it valid to do what I'm doing below
> "nco.attribute = attributevalue" or do you have to use the setattr function
> as outlined in some tutorials?
>
> Thanks!
>
> def default_netcdf(nco_filename,
>          lon0=-179.5,lat0=-89.5,
>          nx=720,ny=360,
>          dx=0.5,dy=0.5):
>  """ add default attributes and dimensions to the nc file """
>  nco = NetCDFFile(nco_filename,'w')
>  nco.author = "Some One"
>  nco.createdate = dt.datetime.now().ctime()
>  nco.contact = "som...@py..."
>  nco.Conventions = "CF-1.4"
>
>  nco.createDimension('lon',nx)
>  nco.createDimension('lat',ny)
>  nco.createVariable('lat','d',('lat',))
>  nco.createVariable('lon','d',('lon',))
>  lon = np.arange(lon0,lon0+(nx*dx),dx)
>  lat = np.arange(lat0,lat0+(ny*dy),dy)
>  nco.variables['lat'][:] = lat
>  nco.variables['lon'][:] = lon
>  nco.createVariable('data','d',('lon','lat'))
>
>  return nco
That should work fine for settings attributes. Are you having a
problem? If so, can you paste the actual traceback?
Ryan
-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
From: Mike A. <mba...@wi...> - 2009年11月11日 14:54:09
Hi all,
Previously I was a user of gnuplot but have been giving matplotlib a 
try. One thing I've run in to right away is that matplotlib appears 
to be significantly slower.
A script to produce a dozen plots was taking me ~1 second with 
gnuplot, and now takes me ~18 seconds with matplotlib.
I'm curious if anyone knows how to speed things up. To figure out 
what is taking most of the time, I've used cProfile and pstats and 
below is the top 15 functions taking the most time.
 (note: "plotStackedJobsVsTime" is my function that uses matplotlib.)
----------------------------------------
Wed Nov 11 08:43:52 2009 fooprof
 3069840 function calls (3009711 primitive calls) in 17.658 
CPU seconds
 Ordered by: cumulative time
 List reduced from 873 to 15 due to restriction <15>
 ncalls tottime percall cumtime percall filename:lineno(function)
 1 0.000 0.000 17.658 17.658 <string>:1(<module>)
 1 0.007 0.007 17.658 17.658 /cms/cmsprod/bin/ 
prodJobMonitorPlots_matplotlib.py:151(main)
 13 0.620 0.048 17.647 1.357 /cms/cmsprod/bin/ 
prodJobMonitorPlots_matplotlib.py:54(plotStackedJobsVsTime)
 13 0.000 0.000 10.087 0.776 /afs/hep.wisc.edu/cms/ 
sw/python/x86_64/2.5.4/lib/python2.5/site-packages/ 
matplotlib-0.99.1.1_r0-py2.5-linux-x86_64.egg/matplotlib/figure.py:959 
(savefig)
 13 0.028 0.002 10.086 0.776 /afs/hep.wisc.edu/cms/ 
sw/python/x86_64/2.5.4/lib/python2.5/site-packages/ 
matplotlib-0.99.1.1_r0-py2.5-linux-x86_64.egg/matplotlib/ 
backend_bases.py:1372(print_figure)
 13 0.028 0.002 9.847 0.757 /afs/hep.wisc.edu/cms/ 
sw/python/x86_64/2.5.4/lib/python2.5/site-packages/ 
matplotlib-0.99.1.1_r0-py2.5-linux-x86_64.egg/matplotlib/backends/ 
backend_agg.py:357(print_png)
 13 0.000 0.000 9.243 0.711 /afs/hep.wisc.edu/cms/ 
sw/python/x86_64/2.5.4/lib/python2.5/site-packages/ 
matplotlib-0.99.1.1_r0-py2.5-linux-x86_64.egg/matplotlib/backends/ 
backend_agg.py:307(draw)
 3206/13 0.040 0.000 9.222 0.709 /afs/hep.wisc.edu/cms/ 
sw/python/x86_64/2.5.4/lib/python2.5/site-packages/ 
matplotlib-0.99.1.1_r0-py2.5-linux-x86_64.egg/matplotlib/artist.py:44 
(draw_wrapper)
 13 0.001 0.000 9.222 0.709 /afs/hep.wisc.edu/cms/ 
sw/python/x86_64/2.5.4/lib/python2.5/site-packages/ 
matplotlib-0.99.1.1_r0-py2.5-linux-x86_64.egg/matplotlib/figure.py:729 
(draw)
 13 0.005 0.000 9.200 0.708 /afs/hep.wisc.edu/cms/ 
sw/python/x86_64/2.5.4/lib/python2.5/site-packages/ 
matplotlib-0.99.1.1_r0-py2.5-linux-x86_64.egg/matplotlib/axes.py:1632 
(draw)
 26 0.029 0.001 5.624 0.216 /afs/hep.wisc.edu/cms/ 
sw/python/x86_64/2.5.4/lib/python2.5/site-packages/ 
matplotlib-0.99.1.1_r0-py2.5-linux-x86_64.egg/matplotlib/axis.py:727 
(draw)
1533/1325 0.078 0.000 3.663 0.003 /afs/hep.wisc.edu/cms/sw/ 
python/x86_64/2.5.4/lib/python2.5/site-packages/matplotlib-0.99.1.1_r0- 
py2.5-linux-x86_64.egg/matplotlib/axis.py:61(__init__)
 811 0.035 0.000 3.057 0.004 /afs/hep.wisc.edu/cms/ 
sw/python/x86_64/2.5.4/lib/python2.5/site-packages/ 
matplotlib-0.99.1.1_r0-py2.5-linux-x86_64.egg/matplotlib/axis.py:181 
(draw)
 13 0.001 0.000 2.619 0.201 /afs/hep.wisc.edu/cms/ 
sw/python/x86_64/2.5.4/lib/python2.5/site-packages/ 
matplotlib-0.99.1.1_r0-py2.5-linux-x86_64.egg/matplotlib/legend.py:342 
(draw)
 1065/961 0.012 0.000 2.543 0.003 /afs/hep.wisc.edu/cms/ 
sw/python/x86_64/2.5.4/lib/python2.5/site-packages/ 
matplotlib-0.99.1.1_r0-py2.5-linux-x86_64.egg/matplotlib/axis.py:1207 
(_get_tick)
----------------------------------------
My script, for the curious, is at
 http://www.hep.wisc.edu/cms/comp/routerqMonitor/prodJobMonitorPlots_matplotlib.py
and produces these plots:
 http://www.hep.wisc.edu/cms/comp/routerqMonitor/index.html
Any hints at what I can do to speed up my script? Or is it out of my 
hands because it's all in matplotlib?
Thanks for any help,
Mike
From: John [H2O] <was...@gm...> - 2009年11月11日 14:05:58
Hello, I'm trying to write a function to create a 'vanilla' NetCDF file to
which I can add data.
So far I have created the following, which is designed to set up a netcdf
file for the addition of global or at least lat/lon datasets. My question
has to do with attribute setting. Is it valid to do what I'm doing below
"nco.attribute = attributevalue" or do you have to use the setattr function
as outlined in some tutorials?
Thanks!
def default_netcdf(nco_filename,
 lon0=-179.5,lat0=-89.5,
 nx=720,ny=360,
 dx=0.5,dy=0.5):
 """ add default attributes and dimensions to the nc file """
 nco = NetCDFFile(nco_filename,'w')
 nco.author = "Some One"
 nco.createdate = dt.datetime.now().ctime()
 nco.contact = "som...@py..."
 nco.Conventions = "CF-1.4"
 
 nco.createDimension('lon',nx)
 nco.createDimension('lat',ny)
 nco.createVariable('lat','d',('lat',))
 nco.createVariable('lon','d',('lon',))
 lon = np.arange(lon0,lon0+(nx*dx),dx)
 lat = np.arange(lat0,lat0+(ny*dy),dy)
 nco.variables['lat'][:] = lat
 nco.variables['lon'][:] = lon
 nco.createVariable('data','d',('lon','lat'))
 
 return nco
-- 
View this message in context: http://old.nabble.com/function-to-create-netcdf-file-tp26301238p26301238.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Jeff W. <jef...@no...> - 2009年11月11日 13:02:39
On 2009年11月10日 13:13 -0500, "George Bonev"
<geo...@gm...> wrote:
 Hello,
 I am plotting a fig in Basemap, but I don't need the extra
 while space on the sides of the figure when I use savfig(). I
 tried axes([0,0,1,1]) but that just gave me a blank white
 screen with some ticks on the sides. Is there another way to
 do it with Basemap? Please help!
 Thank you,
 George B.
George: If you want to preserve the aspect ratio of the map, you
need to calculate it ahead of time and make sure that you create
a figure with the same aspect ratio and define an axes with no
white space. For example, for a global cylindrical equidistant
projection, the aspect ration should be 2:1, so you would create
a figure like this
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure(figsize=(10,5))
ax = plt.axes([0,0,1,1])
m = Basemap(projection='cyl',lon_0=180)
m.drawcoastlines()
m.fillcontinents()
m.drawparallels(np.arange(-60,61,30))
m.drawmeridians(np.arange(60,301,60))
plt.savefig('nowhite.png')
plt.show()
Note that you need to create the axes instance before the Basemap
instance.
If you don't care about the aspect ratio of the map being
correct, you can set fix_aspect='False', create a map of any size
you like, and use an axes with no white space. For example,
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure(figsize=(8,8))
ax = plt.axes([0,0,1,1])
m = Basemap(projection='cyl',lon_0=180,fix_aspect=False)
m.drawcoastlines()
m.fillcontinents()
m.drawparallels(np.arange(-60,61,30))
m.drawmeridians(np.arange(60,301,60))
plt.savefig('nowhite2.png')
plt.show()
If you don't set fix_aspect=False in this example, you'll get a
map with a 2:1 aspect ratio and lots of white space on the top
and bottom of the plot.
-Jeff
------
Jeffrey S. Whitaker
Phone: (303)497-6313
FAX: (303)497-6449
NOAA/OAR/CDC R/CDC1 
325 Broadway, Boulder, CO, USA 80305-3328 
http://www.cdc.noaa.gov/people/jeffrey.s.whitaker

Showing results of 27

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