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

Showing results of 30

1 2 > >> (Page 1 of 2)
From: Friedrich R. <fri...@gm...> - 2010年07月22日 23:46:02
2010年7月20日 Tommy Grav <tg...@ma...>:
> I am trying to compile matplotlib for ActiveState 2.7.0.1 - 64bit on mac os x.
> I have installed numpy 1.4.1 and scipy 0.8.0 from source. Compiling matplotlib
> using
>
> sudo make -f make.osx fetch deps mpl_build mpl_install
>
> works fine, but
>
> sudo python setup.py build
>
> yields the error below. Anyone know how to fix this problem?
>
> Cheers
> Tommy
>       freetype2: found, but unknown version (no pkg-config)
>            * WARNING: Could not find 'freetype2' headers in any
>            * of '.', './freetype2'.
This is the culprit, I think when issuing setup.py via the make.osx
script it adds some sugar telling where to find libraries. You have
to add at least '/usr/local' to the list in setupext.py where there is
'darwin' in front.
> OPTIONAL BACKEND DEPENDENCIES
>        libpng: found, but unknown version (no pkg-config)
>            * Could not find 'libpng' headers in any of '.'
Same thing.
> src/ft2font.h:14:22: error: ft2build.h: No such file or directory
Here you see it clearly. On my system ft2build.h resides in
/usr/local/include, and that is where the make.osx build should put it
too.
> src/ft2font.h:15:10: error: #include expects "FILENAME" or <FILENAME>
> src/ft2font.h:16:10: error: #include expects "FILENAME" or <FILENAME>
> src/ft2font.h:17:10: error: #include expects "FILENAME" or <FILENAME>
> src/ft2font.h:18:10: error: #include expects "FILENAME" or <FILENAME>
> src/ft2font.h:19:10: error: #include expects "FILENAME" or <FILENAME>
blah blah blah
> In file included from src/ft2font.cpp:1:
> src/ft2font.h:33: error: ‘FT_Bitmap’ has not been declared
> src/ft2font.h:33: error: ‘FT_Int’ has not been declared
blah blah blah .......
> src/ft2font.h:33: error: ‘FT_Int’ has not been declared
> src/ft2font.h:89: error: expected ‘,’ or ‘...’ before ‘&’ token
> src/ft2font.h:89: error: ISO C++ forbids declaration of ‘FT_Face’ with no type
> src/ft2font.h:95: error: expected ‘,’ or ‘...’ before ‘&’ token
> src/ft2font.h:95: error: ISO C++ forbids declaration of ‘FT_Face’ with no type
> src/ft2font.h:137: error: ‘FT_Face’ does not name a type
> src/ft2font.h:138: error: ‘FT_Matrix’ does not name a type
> src/ft2font.h:139: error: ‘FT_Vector’ does not name a type
> src/ft2font.h:140: error: ‘FT_Error’ does not name a type
> src/ft2font.h:141: error: ‘FT_Glyph’ was not declared in this scope
> src/ft2font.h:141: error: template argument 1 is invalid
> src/ft2font.h:141: error: template argument 2 is invalid
> src/ft2font.h:142: error: ‘FT_Vector’ was not declared in this scope
> src/ft2font.h:142: error: template argument 1 is invalid
> src/ft2font.h:142: error: template argument 2 is invalid
> src/ft2font.h:148: error: ‘FT_BBox’ does not name a type
> src/ft2font.cpp:45: error: ‘FT_Library’ does not name a type
> src/ft2font.cpp:108: error: variable or field ‘draw_bitmap’ declared void
> src/ft2font.cpp:108: error: ‘FT_Bitmap’ was not declared in this scope
> src/ft2font.cpp:108: error: ‘bitmap’ was not declared in this scope
> src/ft2font.cpp:109: error: ‘FT_Int’ was not declared in this scope
> src/ft2font.cpp:110: error: ‘FT_Int’ was not declared in this scope
> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include/numpy/__multiarray_api.h:1187: warning: ‘int _import_array()’ defined but not used
> cc1plus: warning: command line option "-Wstrict-prototypes" is valid for C/ObjC but not for C++
> In file included from src/ft2font.cpp:1:
> src/ft2font.h:14:22: error: ft2build.h: No such file or directory
Again.
> src/ft2font.h:15:10: error: #include expects "FILENAME" or <FILENAME>
> src/ft2font.h:16:10: error: #include expects "FILENAME" or <FILENAME>
> src/ft2font.h:17:10: error: #include expects "FILENAME" or <FILENAME>
> src/ft2font.h:18:10: error: #include expects "FILENAME" or <FILENAME>
> src/ft2font.h:19:10: error: #include expects "FILENAME" or <FILENAME>
> In file included from src/ft2font.cpp:1:
> src/ft2font.h:33: error: ‘FT_Bitmap’ has not been declared
> src/ft2font.h:33: error: ‘FT_Int’ has not been declared
> src/ft2font.h:33: error: ‘FT_Int’ has not been declared
> src/ft2font.h:89: error: expected ‘,’ or ‘...’ before ‘&’ token
> src/ft2font.h:89: error: ISO C++ forbids declaration of ‘FT_Face’ with no type
> src/ft2font.h:95: error: expected ‘,’ or ‘...’ before ‘&’ token
> src/ft2font.h:95: error: ISO C++ forbids declaration of ‘FT_Face’ with no type
> src/ft2font.h:137: error: ‘FT_Face’ does not name a type
> src/ft2font.h:138: error: ‘FT_Matrix’ does not name a type
> src/ft2font.h:139: error: ‘FT_Vector’ does not name a type
> src/ft2font.h:140: error: ‘FT_Error’ does not name a type
> src/ft2font.h:141: error: ‘FT_Glyph’ was not declared in this scope
> src/ft2font.h:141: error: template argument 1 is invalid
> src/ft2font.h:141: error: template argument 2 is invalid
> src/ft2font.h:142: error: ‘FT_Vector’ was not declared in this scope
> src/ft2font.h:142: error: template argument 1 is invalid
> src/ft2font.h:142: error: template argument 2 is invalid
> src/ft2font.h:148: error: ‘FT_BBox’ does not name a type
> src/ft2font.cpp:45: error: ‘FT_Library’ does not name a type
> src/ft2font.cpp:108: error: variable or field ‘draw_bitmap’ declared void
> src/ft2font.cpp:108: error: ‘FT_Bitmap’ was not declared in this scope
> src/ft2font.cpp:108: error: ‘bitmap’ was not declared in this scope
> src/ft2font.cpp:109: error: ‘FT_Int’ was not declared in this scope
> src/ft2font.cpp:110: error: ‘FT_Int’ was not declared in this scope
> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include/numpy/__multiarray_api.h:1187: warning: ‘int _import_array()’ defined but not used
> lipo: can't figure out the architecture type of: /var/tmp//cc1zVbyh.out
> error: command 'gcc' failed with exit status 1
sure, it fails with bailing out after such a bunch of errors. But it
tries hard to compile even without proper include files doesn't it :-)
Friedrich
From: Friedrich R. <fri...@gm...> - 2010年07月22日 23:24:08
2010年7月20日 Søren Nielsen <sor...@gm...>:
> Hi,
>
> I'm creating a stand alone program on my mac with OSX 10.4 and it seems to
> work great on it. However, if I transfer my program to a snow leopard (10.6)
> mac, I get the error:
>
> dlopen(/Volumes/KINGSTON/Mac/RAW.app/Contents/Resources/lib/python2.6/matplotlib/ft2font.so,
> 2): Symbol not found: _FT_Load_Glyph
>    Referenced from:
> /Volumes/KINGSTON/Mac/RAW.app/Contents/Resources/lib/python2.6/matplotlib/ft2font.so
>   Expected in: dynamic lookup
This looks to me like a compiler issue, but I'm not 100% sure either.
My guess is that your /opt/local/lib/libfreetype.6.dylib is compiled
for 10.6, i.e., using gcc-4.2, but your matplotlib files shipped with
your .app are compiled with gcc-4.0, as usual on 10.4. I don't know
why py2app doesn't pick up the files in /opt to ship it with your app,
I mean, noone can expect other users to have MacPorts installed when
they run your app. Maybe it's also some precedence issue, but I'm
neither a MacPorts nor a py2app expert :-(
It's good that you provide directly the otool info:
> /opt/local/lib/libfreetype.6.dylib (compatibility version 11.0.0, current
> version 11.0.0)
I guess the following indents/non-indents are unintentional and are
without meaning.
>     /opt/local/lib/libz.1.dylib (compatibility version 1.0.0, current
> version 1.2.4)
>     /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current
> version 7.4.0)
>     /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
> version 88.3.3)
>
> /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
> (compatibility version 1.0.0, current version 18.0.0)
>
> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices
> (compatibility version 1.0.0, current version 22.0.0)
>     /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current
> version 1.0.0)
>     /usr/lib/libmx.A.dylib (compatibility version 1.0.0, current version
> 47.1.0)
hth so far,
Friedrich
From: Christopher B. <Chr...@no...> - 2010年07月22日 23:16:19
Jim Vickroy wrote:
> The attachment is a simple script that creates a 2D array of unsigned, 
> 8-bit integers and uses matplotlib to save it as a PNG file.
> 
> Unfortunately, the PNG file is much larger than expected -- apparently 
> because it is True-Color; on my MS Windows machine, bit depth, for the 
> file, is listed as 32 rather than the expected 8.
> Can matplotlib be used to accomplish this? If so, could someone direct 
> me to where this is discussed?
I don't think so directly. MPL uses a 32 bit image buffer internally, 
and that's what gets saved out in the PNG.
You can post-process the image with something like ImageMagick.
Another alternative is to use PIL -- you can grab the matplotlib buffer, 
make a PIL image out of it, and use PIL to convert to an 8-bit palleted 
image.
For that matter, you could probably bypass MPL, and use numpy to create 
the 8-bit image you want, and PIL to save it as a PNG.
-Chris
-- 
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chr...@no...
From: Aman T. <ama...@gm...> - 2010年07月22日 17:49:30
Sorry, that was a silly question. I just set the clip_on to True to fix
this.
On Thu, Jul 22, 2010 at 1:45 PM, Aman Thakral <ama...@gm...>wrote:
> Hi all,
>
> The text draws outside the plotting area when you zoom in. Sample code is
> attached. To re-create the issue, just use the zoom rect function on the
> plot.
>
> Is there a way to fix this?
>
> Thanks,
> Aman
>
-- 
Aman Thakral
B.Eng & Biosci, M.Eng Design
From: Benjamin R. <ben...@ou...> - 2010年07月22日 17:11:22
On Thu, Jul 22, 2010 at 3:30 AM, aliko <ali...@gm...> wrote:
> Could please anyone help me to get axises autoscaling in following
> example? I took it from the examples and slightly modified it to remove
> all unecessary things trying to make it as short as possible.
>
> Thanks in advance!
>
> import sys
>
> from matplotlib.figure import Figure
> from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as
> FigureCanvas
>
> from PyQt4 import QtGui
>
> import numpy as np
> import time
>
> class BlitQT(FigureCanvas):
> def __init__(self):
> FigureCanvas.__init__(self, Figure())
>
> self.ax = self.figure.add_subplot(111)
> self.ax.grid()
> self.draw()
>
> self.ax_background = self.copy_from_bbox(self.ax.bbox)
> self.cnt = 0
>
> self.x = np.arange(0,2*np.pi,0.01)
> self.sin_line, = self.ax.plot(self.x, np.sin(self.x),
> animated=True)
> self.cos_line, = self.ax.plot(self.x, np.cos(self.x),
> animated=True)
>
> self.tstart = time.time()
> self.startTimer(10)
>
> def timerEvent(self, evt):
> self.restore_region(self.ax_background, bbox=self.ax.bbox)
>
> # update the data
> self.sin_line.set_ydata(np.sin(self.x+self.cnt/10.0))
> self.cos_line.set_ydata((self.x+self.cnt)/50.0)
> # just draw the animated artist
> self.ax.draw_artist(self.sin_line)
> self.ax.draw_artist(self.cos_line)
> # just redraw the axes rectangle
> self.blit(self.ax.bbox)
>
> if self.cnt == 0:
> self.draw()
> self.cnt += 1
>
> app = QtGui.QApplication(sys.argv)
> widget = BlitQT()
> widget.show()
>
> sys.exit(app.exec_())
>
>
>
The problem here is probably with the blitting. You make a copy of the
background before plotting the data. Before you plot the data, the axes
have no clue what's its limits are supposed to be. In your example, it
won't know until you do the plotting. Then when you restore the background,
it is restoring the background that never knew the limits.
I suggest calling ax.set_xlim() and ax.set_ylim() before doing the
copy_from_bbox().
I hope that helps,
Ben Root
From: Michael D. <md...@st...> - 2010年07月22日 16:58:39
Which backend are you using? Can you provide a short script that 
reproduces the bug?
Mike
On 07/22/2010 11:18 AM, Tobias Winchen wrote:
> Dear all,
>
> in matplotlib version 0.99.0 when drawing images with imshow into figures with
> hammer or aitoff axes the images are clipped to the axes. Now this has changed
> in and the images are drawn also outside the axes (version 0.99.3) or not
> drawn at all (version 1.0.0). How can I clip them again to the axes?
>
> Best regards,
>
> Tobias
>
> 
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
From: Tobias W. <wi...@ph...> - 2010年07月22日 15:18:31
Dear all,
in matplotlib version 0.99.0 when drawing images with imshow into figures with 
hammer or aitoff axes the images are clipped to the axes. Now this has changed 
in and the images are drawn also outside the axes (version 0.99.3) or not 
drawn at all (version 1.0.0). How can I clip them again to the axes?
Best regards,
Tobias
From: Jenna L. <je...@as...> - 2010年07月22日 15:17:14
No, I don't think the issue is a flip in the y-axis. I have a number
of different examples of this, and many in which the contour is an
ellipse so I can tell that the overall positioning is correct. It
seems like something is going wrong only when I save the image...
Thanks for the suggestion though!
Jenna
On Wed, Jul 21, 2010 at 3:40 PM, Jenna Lemonias
<je...@as...>wrote <je...@as...%3Ewrote>:
> I am trying to save a matplotlib 2d array image with an overlaid contour as
> an eps file. The contour appears to be shifted with respect to the image
> underneath in the eps file, particularly when I zoom in on the image. This
> shift is not noticeable in the plot within matplotlib.
>
> I am using imshow to display the image. The contour is created by plotting
> a list of closely-spaced x,y coordinates. The attached file matplotlib.png
> is a screenshot of the (zoomed-in) image as displayed by matplotlib. The
> attached file epsfile.png is a screenshot of the (zoomed-in) eps file. When
> I save this image as an eps file, it is actually 1 of 20 subplots and the
> shift is noticeable in each subplot.
>
> Thanks in advance for your help!
>
> Jenna
>
>
Just as a wild guess, could this actually be an issue with how imshow uses
the upper-left corner for (0,0)? I have seen 1-pixel shifts before, but
this shift is a little dramatic and I am left wondering if what we are
really seeing is that the contour that is desired should actually be fliped
in the y-axis?
Maybe you could try another example where you try to draw a contour further
away from the center of the image and see if it still goes in the spot you
expect it to be?
Ben Root
From: mdekauwe <mde...@gm...> - 2010年07月22日 14:34:41
Hi Jeff,
That sounds like the perfect solution as I do have the lat, lons - I'll give
that a go!
Thanks again,
Martin
Jeff Whitaker wrote:
> 
> On 7/22/10 8:08 AM, mdekauwe wrote:
>> Hi Jeff,
>>
>> Yes you are right! Apologies. Whilst it is easy enough to define the grid
>> in
>> this case as it is a regular lat,long grid. If it was for example a
>> geostationary grid, I think this might be more difficult. Is there a way
>> to
>> return the grid for example from the basemap call, which can then be used
>> in
>> the contour call?
>>
>> I hope that makes sense.
>>
>> Thanks again.
> 
> If you have the lats and lons of the data grid, you can convert to map 
> projection coordinates by calling the Basemap instance, i.e.
> 
> map = Basemap(....)
> x,y = map(lons,lats)
> 
> you can then use the x,y values in contour
> 
> map.contourf(x,y,data)
> 
> Does that help?
> 
> -Jeff
> 
> 
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
-- 
View this message in context: http://old.nabble.com/Basemap-%2B-contour-layer--tp29235080p29237609.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Jeff W. <js...@fa...> - 2010年07月22日 14:30:20
On 7/22/10 8:08 AM, mdekauwe wrote:
> Hi Jeff,
>
> Yes you are right! Apologies. Whilst it is easy enough to define the grid in
> this case as it is a regular lat,long grid. If it was for example a
> geostationary grid, I think this might be more difficult. Is there a way to
> return the grid for example from the basemap call, which can then be used in
> the contour call?
>
> I hope that makes sense.
>
> Thanks again.
If you have the lats and lons of the data grid, you can convert to map 
projection coordinates by calling the Basemap instance, i.e.
map = Basemap(....)
x,y = map(lons,lats)
you can then use the x,y values in contour
map.contourf(x,y,data)
Does that help?
-Jeff
From: mdekauwe <mde...@gm...> - 2010年07月22日 14:08:49
Hi Jeff,
Yes you are right! Apologies. Whilst it is easy enough to define the grid in
this case as it is a regular lat,long grid. If it was for example a
geostationary grid, I think this might be more difficult. Is there a way to
return the grid for example from the basemap call, which can then be used in
the contour call? 
I hope that makes sense.
Thanks again.
 
Jeff Whitaker wrote:
> 
> On 7/22/10 7:48 AM, mdekauwe wrote:
>> import numpy as np
>> from mpl_toolkits.basemap import Basemap
>> import matplotlib.pyplot as plt
>>
>> # generate some random data - i.e. what would be an image of the world,
>> say
>> different
>> # land covers
>> data = np.random.randint(10,27,100*67).reshape(100, 67)
>>
>> # I want to draw a boundary round each land cover type, so
>> # classify a new array
>> data2 = np.where(data == 10, 1, data)
>> data2 = np.where(data == 11, 1, data)
>> data2 = np.where(data == 13, 2, data)
>> data2 = np.where(data == 14, 2, data)
>> data2 = np.where(data == 15, 2, data)
>> data2 = np.where(data == 16, 2, data)
>> data2 = np.where(data == 18, 3, data)
>> data2 = np.where(data == 19, 3, data)
>> data2 = np.where(data == 20, 3, data)
>> data2 = np.where(data == 26, 4, data)
>> data2 = np.where(data == 27, 4, data)
>>
>> plt.contour(data2)
>> plt.show()
>> sys.exit()
>>
>> this pops up a contour plot...
>>
>> Now what if as I do I want to overlay this on a basemap plot...
>>
>> import numpy as np
>> from mpl_toolkits.basemap import Basemap
>> import matplotlib.pyplot as plt
>>
>> # generate some random data - i.e. what would be an image of the world,
>> say
>> different
>> # land covers
>> data = np.random.randint(10,27,100*67).reshape(100, 67)
>>
>> # I want to draw a boundary round each land cover type, so
>> # classify a new array
>> data2 = np.where(data == 10, 1, data)
>> data2 = np.where(data == 11, 1, data)
>> data2 = np.where(data == 13, 2, data)
>> data2 = np.where(data == 14, 2, data)
>> data2 = np.where(data == 15, 2, data)
>> data2 = np.where(data == 16, 2, data)
>> data2 = np.where(data == 18, 3, data)
>> data2 = np.where(data == 19, 3, data)
>> data2 = np.where(data == 20, 3, data)
>> data2 = np.where(data == 26, 4, data)
>> data2 = np.where(data == 27, 4, data)
>>
>> fig = plt.figure(figsize=(8, 6))
>> m = Basemap(llcrnrlon=1.5, llcrnrlat=10.5, urcrnrlon=3.5, urcrnrlat=13.5,
>> resolution='c', projection='cyl')
>> ax = fig.add_axes([0.1, 0.1, 0.6, 0.7])
>> m.ax = ax
>>
>> delta = 0.03
>> x = np.arange(1.5, 3.5, delta)
>> y = np.arange(10.5, 13.5, delta)
>> X, Y = np.meshgrid(x, y)
>>
>> im = m.imshow(data, interpolation='nearest', cmap=plt.cm.jet)
>> m.contour(data2, X, Y, color='black')
>> 
> 
> Martin: This needs to be
> 
> m.contour(X, Y, data2, colors='black')
> 
> (the data goes after the coordinate arrays, and the keyword is 'colors',
> not 'color')
> 
> 
> -Jeff
> 
> 
>> plt.show()
>>
>> This only plots the basemap without the contours?
>>
>> Many thanks,
>>
>> Martin
>>
>>
>> 
> 
> 
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
-- 
View this message in context: http://old.nabble.com/Basemap-%2B-contour-layer--tp29235080p29237306.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Jeff W. <js...@fa...> - 2010年07月22日 14:01:08
On 7/22/10 7:48 AM, mdekauwe wrote:
> import numpy as np
> from mpl_toolkits.basemap import Basemap
> import matplotlib.pyplot as plt
>
> # generate some random data - i.e. what would be an image of the world, say
> different
> # land covers
> data = np.random.randint(10,27,100*67).reshape(100, 67)
>
> # I want to draw a boundary round each land cover type, so
> # classify a new array
> data2 = np.where(data == 10, 1, data)
> data2 = np.where(data == 11, 1, data)
> data2 = np.where(data == 13, 2, data)
> data2 = np.where(data == 14, 2, data)
> data2 = np.where(data == 15, 2, data)
> data2 = np.where(data == 16, 2, data)
> data2 = np.where(data == 18, 3, data)
> data2 = np.where(data == 19, 3, data)
> data2 = np.where(data == 20, 3, data)
> data2 = np.where(data == 26, 4, data)
> data2 = np.where(data == 27, 4, data)
>
> plt.contour(data2)
> plt.show()
> sys.exit()
>
> this pops up a contour plot...
>
> Now what if as I do I want to overlay this on a basemap plot...
>
> import numpy as np
> from mpl_toolkits.basemap import Basemap
> import matplotlib.pyplot as plt
>
> # generate some random data - i.e. what would be an image of the world, say
> different
> # land covers
> data = np.random.randint(10,27,100*67).reshape(100, 67)
>
> # I want to draw a boundary round each land cover type, so
> # classify a new array
> data2 = np.where(data == 10, 1, data)
> data2 = np.where(data == 11, 1, data)
> data2 = np.where(data == 13, 2, data)
> data2 = np.where(data == 14, 2, data)
> data2 = np.where(data == 15, 2, data)
> data2 = np.where(data == 16, 2, data)
> data2 = np.where(data == 18, 3, data)
> data2 = np.where(data == 19, 3, data)
> data2 = np.where(data == 20, 3, data)
> data2 = np.where(data == 26, 4, data)
> data2 = np.where(data == 27, 4, data)
>
> fig = plt.figure(figsize=(8, 6))
> m = Basemap(llcrnrlon=1.5, llcrnrlat=10.5, urcrnrlon=3.5, urcrnrlat=13.5,
> resolution='c', projection='cyl')
> ax = fig.add_axes([0.1, 0.1, 0.6, 0.7])
> m.ax = ax
>
> delta = 0.03
> x = np.arange(1.5, 3.5, delta)
> y = np.arange(10.5, 13.5, delta)
> X, Y = np.meshgrid(x, y)
>
> im = m.imshow(data, interpolation='nearest', cmap=plt.cm.jet)
> m.contour(data2, X, Y, color='black')
> 
Martin: This needs to be
m.contour(X, Y, data2, colors='black')
(the data goes after the coordinate arrays, and the keyword is 'colors', not 'color')
-Jeff
> plt.show()
>
> This only plots the basemap without the contours?
>
> Many thanks,
>
> Martin
>
>
> 
From: Benjamin R. <ben...@ou...> - 2010年07月22日 13:54:41
On Wed, Jul 21, 2010 at 3:40 PM, Jenna Lemonias <je...@as...>wrote:
> I am trying to save a matplotlib 2d array image with an overlaid contour as
> an eps file. The contour appears to be shifted with respect to the image
> underneath in the eps file, particularly when I zoom in on the image. This
> shift is not noticeable in the plot within matplotlib.
>
> I am using imshow to display the image. The contour is created by plotting
> a list of closely-spaced x,y coordinates. The attached file matplotlib.png
> is a screenshot of the (zoomed-in) image as displayed by matplotlib. The
> attached file epsfile.png is a screenshot of the (zoomed-in) eps file. When
> I save this image as an eps file, it is actually 1 of 20 subplots and the
> shift is noticeable in each subplot.
>
> Thanks in advance for your help!
>
> Jenna
>
>
Just as a wild guess, could this actually be an issue with how imshow uses
the upper-left corner for (0,0)? I have seen 1-pixel shifts before, but
this shift is a little dramatic and I am left wondering if what we are
really seeing is that the contour that is desired should actually be fliped
in the y-axis?
Maybe you could try another example where you try to draw a contour further
away from the center of the image and see if it still goes in the spot you
expect it to be?
Ben Root
From: mdekauwe <mde...@gm...> - 2010年07月22日 13:49:01
Ok... how about this?
import numpy as np
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
# generate some random data - i.e. what would be an image of the world, say
different
# land covers
data = np.random.randint(10,27,100*67).reshape(100, 67)
# I want to draw a boundary round each land cover type, so 
# classify a new array
data2 = np.where(data == 10, 1, data)
data2 = np.where(data == 11, 1, data)
data2 = np.where(data == 13, 2, data)
data2 = np.where(data == 14, 2, data)
data2 = np.where(data == 15, 2, data)
data2 = np.where(data == 16, 2, data)
data2 = np.where(data == 18, 3, data)
data2 = np.where(data == 19, 3, data)
data2 = np.where(data == 20, 3, data)
data2 = np.where(data == 26, 4, data)
data2 = np.where(data == 27, 4, data)
plt.contour(data2)
plt.show()
sys.exit()
this pops up a contour plot...
Now what if as I do I want to overlay this on a basemap plot...
import numpy as np
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
# generate some random data - i.e. what would be an image of the world, say
different
# land covers
data = np.random.randint(10,27,100*67).reshape(100, 67)
# I want to draw a boundary round each land cover type, so 
# classify a new array
data2 = np.where(data == 10, 1, data)
data2 = np.where(data == 11, 1, data)
data2 = np.where(data == 13, 2, data)
data2 = np.where(data == 14, 2, data)
data2 = np.where(data == 15, 2, data)
data2 = np.where(data == 16, 2, data)
data2 = np.where(data == 18, 3, data)
data2 = np.where(data == 19, 3, data)
data2 = np.where(data == 20, 3, data)
data2 = np.where(data == 26, 4, data)
data2 = np.where(data == 27, 4, data)
fig = plt.figure(figsize=(8, 6))
m = Basemap(llcrnrlon=1.5, llcrnrlat=10.5, urcrnrlon=3.5, urcrnrlat=13.5, 
 resolution='c', projection='cyl')
ax = fig.add_axes([0.1, 0.1, 0.6, 0.7])
m.ax = ax
delta = 0.03
x = np.arange(1.5, 3.5, delta) 
y = np.arange(10.5, 13.5, delta)
X, Y = np.meshgrid(x, y)
im = m.imshow(data, interpolation='nearest', cmap=plt.cm.jet)
m.contour(data2, X, Y, color='black')
plt.show()
This only plots the basemap without the contours?
Many thanks,
Martin
-- 
View this message in context: http://old.nabble.com/Basemap-%2B-contour-layer--tp29235080p29237074.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: John H. <jd...@gm...> - 2010年07月22日 13:36:19
Attachments: gcview2.py
On Thu, Jul 22, 2010 at 8:07 AM, John Hunter <jd...@gm...> wrote:
> On Thu, Jul 22, 2010 at 7:58 AM, alberttresens <alb...@gm...> wrote:
>>
>> http://old.nabble.com/file/p29236565/gcview.py gcview.py
>> http://old.nabble.com/file/p29236565/gc.log gc.log
>>
>> Hi here the files you were asking for.
>
> Works fine for me -- most likely one of my suggestions in the previous
> post will help you.
Attached is the simplest solution -- uses the pyplot namspace, calls
figure before plotting, use the API calls for plotting and labelsing,
and calls plt.show afterwords to raise the figure.
From: Jeff W. <js...@fa...> - 2010年07月22日 13:24:31
On 7/22/10 3:53 AM, mdekauwe wrote:
> Hi,
>
> I am trying to plot an image using basemap and overlay another image plotted
> as a contour and I am a bit stuck.
>
> e.g.
>
> I have a small image of the world for example (10.5-13.5N, 1.5-3.5E, regular
> lat long grid). And I saw what was posted previously
> here...http://www.mail-archive.com/mat...@li.../msg01961.html
> but I am still stuck.
>
> I plot my original image...
>
> im = m.imshow(image, norm=norm, interpolation='nearest', cmap=colour_map)
>
> then I tried to build the info for the contour plot
>
> delta = 0.03
> x = np.arange(1.5, 3.5, delta)
> y = np.arange(10.5, 13.5, delta)
> X, Y = np.meshgrid(x, y)
> m.contour(image2, X, Y, color='black')
>
> plt.show()
>
> but that only plots the first image? The images arrays are identically sized
> and of the same area, is there a way to grab the grid from the first plot
> perhaps?
>
> No idea what I am doing wrong.
> 
Nor do I - it would help to have a self-contained example to run that 
demonstrates your problem.
-Jeff
> Many thanks,
>
> Martin
> 
From: John H. <jd...@gm...> - 2010年07月22日 13:07:35
On Thu, Jul 22, 2010 at 7:58 AM, alberttresens <alb...@gm...> wrote:
>
> http://old.nabble.com/file/p29236565/gcview.py gcview.py
> http://old.nabble.com/file/p29236565/gc.log gc.log
>
> Hi here the files you were asking for.
Works fine for me -- most likely one of my suggestions in the previous
post will help you.
JDH
From: alberttresens <alb...@gm...> - 2010年07月22日 12:58:59
http://old.nabble.com/file/p29236565/gcview.py gcview.py 
http://old.nabble.com/file/p29236565/gc.log gc.log 
Hi here the files you were asking for. 
-- 
View this message in context: http://old.nabble.com/Plot%28%29-%3A-IndexError%3A-index-out-of-range-for-array-tp29226333p29236565.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: John H. <jd...@gm...> - 2010年07月22日 12:44:31
On Thu, Jul 22, 2010 at 3:48 AM, alberttresens <alb...@gm...> wrote:
>
> Might be usefull, that is the script I am trying to run. I has some checks,
> but is basiclly from Salmon Run Blog:
We can't run this because when you pasted the text into the browser it
was line wrapped and would require significant editing to make it
syntactically correct. When posting code, it helps to attach it as
well to avoid these kinds of problems. Also, the script requires a gc
logfile which we do not have, so for us to be able to run it we would
need the input as well. It is much easier for us to debug code that
we can actually run.
So I will haxard a guess based on a quick inspection. You are
probably running and rerunning this code in an environment with a
persistent python session, like Idle, ipython or some other IDE. The
calls to "plot" you are making my default replot into the same figure
and axes, and that figure contains some bad data from an earlier run
that is messing subsequent runs up. This problem should go away if
you run your script in a clean environment, eg from the shell command
line with a new python session. Alternatively, in a running session,
just do
 plt.close('all')
to clear out all your old figures.
You can also insure that the plotting goes into a new figure by calling
 figure()
before any plotting commands.
It is usually a bad idea to rely on pyplot's manipulation of the
current figure and axes when embedding plotting code in a function,
since functions can be called in multiple contexts. I usually use the
API, and the following idiom for writing plotting functions
def somefunc(x, y, fig=None):
 """
 plot x vs y.
 fig is a matplotlib Figure instance; if None create a new pyplot figure
 The Figure instance is returned
 """
 if fig is None:
 # we import pyplot here and not at the top level so that
 # people who are managing their own figures, eg in a user
 # interface application, will not trigger the pyplot user
 # interface code which coul cause conflicts
 import matplotlib.pyplot as plt
 fig = plt.figure()
 # we explicitly instantiate our axes rather than rely on pyplot's
 # stateful management of current figure and axes
 ax = fig.add_subplot(111)
 ax.plot(x, y)
 ax.set_title('x vs y')
 ax.set_xlabel('x')
 ax.set_ylabel('y')
 ax.grid(True)
 return fig
From: mdekauwe <mde...@gm...> - 2010年07月22日 09:53:50
Hi,
I am trying to plot an image using basemap and overlay another image plotted
as a contour and I am a bit stuck.
e.g.
I have a small image of the world for example (10.5-13.5N, 1.5-3.5E, regular
lat long grid). And I saw what was posted previously
here...http://www.mail-archive.com/mat...@li.../msg01961.html
but I am still stuck.
I plot my original image...
im = m.imshow(image, norm=norm, interpolation='nearest', cmap=colour_map)
then I tried to build the info for the contour plot
delta = 0.03
x = np.arange(1.5, 3.5, delta) 
y = np.arange(10.5, 13.5, delta)
X, Y = np.meshgrid(x, y)
m.contour(image2, X, Y, color='black')
plt.show()
but that only plots the first image? The images arrays are identically sized
and of the same area, is there a way to grab the grid from the first plot
perhaps?
No idea what I am doing wrong.
Many thanks,
Martin
-- 
View this message in context: http://old.nabble.com/Basemap-%2B-contour-layer--tp29235080p29235080.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: alberttresens <alb...@gm...> - 2010年07月22日 08:48:10
Might be usefull, that is the script I am trying to run. I has some checks,
but is basiclly from Salmon Run Blog:
#!/usr/bin/python
import os
import sys
import re
import time
from stat import *
from pylab import *
from matplotlib import *
def parse(line): 
 """
 Parses an input line from gc.log into a set of tokens and
returns them.
 There are two patterns we have to look for:
 112829.094: [GC 695486K->557348K(806720K), 0.0191830 secs]
 112776.534: [Full GC 690522K->551411K(817408K), 1.8249860 secs
 """
 #pgre =
re.compile("(\d+\.\d+):\s\[.+\]\s+(\d+)K->(\d+)K\((\d+)K\),\s(\d+\.\d+)\ssecs\]",re.IGNORECASE)
 #pgre =
re.compile("(\d+\.\d+):\s\[.+\]\s+(\d+)K->(\d+)K\((\d+)K\),\s(\d+\.\d+)\ssecs\]")
 fre =
re.compile("(\d+\.\d+):\s\[.+\]\s+(\d+)K->(\d+)K\((\d+)K\)\s\[.+\],\s(\d+\.\d+)\ssecs\]",re.IGNORECASE)
 pgre =
re.compile("(\d+\.\d+):\s\[.+\s+(\d+)K->(\d+)K\((\d+)K\)\s\[.+\],\s(\d+\.\d+)\ssecs\]
",re.IGNORECASE)
 test =
re.compile("(\d+\.\d+):\s\[.+\s+(\d+)K->(\d+)K\((\d+)K\),\s(\d+\.\d+)\ssecs\]")
 #pgre =
re.compile("(\d+\.\d+):\s\[.+\]\s+(\d+)K->(\d+)K\((\d+)K\),\s(\d+\.\d+)\ssecs\]")
 #fre =
re.compile("(\d+\.\d+):\s\[.+\]\s+(\d+)K->(\d+)K\((\d+)K\)\s\[.+\],\s(\d+\.\d+)\ssecs\]") 
 # First try matching with the partial GC pattern pgre
 isFullGc = False
 mo = pgre.match(line)
 print mo
 # Then match with the full GC pattern
 if (mo == None):
 #mo = fre.match(line)
 mo = test.match(line)
 print "after the fre.match"
 print line
 print mo
 #print mo.group(0)
 print "before group1"
 print mo.group(1)
 print "after group1"
 print mo.group(2)
 print mo.group(3)
 print mo.group(4)
 print mo.group(5)
 isFullGc = True
 print mo
 print float(mo.group(1))
 print "after float group(1)"
 
 # return tsoffset, heapUsedBeforeGc(Kb), heapUsedAfterGc(Kb),
elapsedTime(s), heapSize(Kb), isFullGc
 return float(mo.group(1)), int(mo.group(2)), int(mo.group(3)),
float(mo.group(5)), int(mo.group(4)), isFullGc
 #return float(mo.group(1)), int(mo.group(2)), int(mo.group(3)),
0.0191830 , int(mo.group(4)), isFullGc
def drawGraph(x1vals, y1vals, x2vals, y2vals, y3vals, x4vals, y4vals,
startTime, endTime, output):
 """
 Draws a graph of the GC behavior we are interested in. There are three 
 line graphs and one series of points.
 - Memory in use before GC happens (red line)
 - Memory in use after GC happens (green line)
 - Total JVM heap size (yellow line)
 - Times when full GC happens (blue dots on X-axis)
 - The Y-axis (for memory usage) numbers are shown in MB
 - The X-axis (for time) is plotted in minutes since start
 - The title contains the start and end times for this plot
 """
 print "-- In drawGraph--"
 print x1vals, y1vals, x2vals, y2vals, y3vals, x4vals, y4vals, startTime,
endTime, output
 xlabel("Time (minutes)")
 ylabel("Heap(Mb)")
 title("GC Log (" + startTime + " to " + endTime + ")")
 # Heap in use graph over time before garbage collection
 print "--before plot"
 print x1vals
 print y1vals
 print x2vals
 print y2vals
 print y3vals
 print x4vals
 print y4vals
 print startTime
 print endTime
 print output
 #plot([0.0, 0.048583333333333326, 0.10666666666666667,
0.12878333333333333],[1,2,3,4],'r')
 #pylab.plot([0, 1, 2, 3],[1,2,3,4],'r')
 #plot(arange(0,10),[9,4,5,2,3,5,7,12,2,3])
 #plot ( arange(0,10),[9,4,5,2,3,5,7,12,2,3],'.-',label='sample1' )
 plot([0],[0])
 #plot(x1vals, y1vals, 'r')
 # Heap in use graph over time after garbage collection
 #plot(x2vals, y2vals, 'g')
 # Total heap size over time
 #plot(x2vals, y3vals, 'y')
 # Full GC over time
 #plot(x4vals, y4vals, 'bo')
 savefig(output)
def usage():
 """
 Prints the script's usage guide.
 """
 print "Usage: gcview.py input output [time-start] [time-end]"
 print "input = path to gc.log file"
 print "output = path to gc.png file"
 print "time-start = date in yyyy-MM-dd HH:mm format"
 print "time-end = date in yyyy-MM-dd HH:mm format"
 sys.exit(-1)
def convertISOToUnixTS(isots):
 """
 Takes a timestamp (supplied from the command line) in ISO format, ie
 yyyy-MM-dd HH:mm and converts it to seconds since the epoch.
 """
 isore = re.compile("(\d{4})-(\d{2})-(\d{2})\s(\d{2}):(\d{2})")
 mo = isore.match(isots)
 return time.mktime([int(mo.group(1)), int(mo.group(2)),
int(mo.group(3)), int(mo.group(4)), int(mo.group(5)), 0, 0, 0, -1])
def baseTimeStamp(logFile):
 """
 Since the timestamps in the gc.log file are probably in seconds since
 server startup, we want to get an indication of the time the first log
 line was written. We do this by getting the ctime of the gc.log file.
 """
 return os.lstat(logFile)[ST_CTIME]
def minutesElapsed(currentTS, baseTS):
 """
 Convert the timestamp (in seconds since JVM startup) to mins elapsed 
 since first timestamp entry.
 """
 return (currentTS - baseTS) / 60
def timeString(ts):
 """
 Return printable version of time represented by seconds since epoch
 """
 return time.strftime("%Y-%m-%d %H:%M", time.localtime(ts))
def main():
 """
 This is how we are called. Reads the command line args, reads the input
 file line by line, calling out to parse() for each line, processing and
 pushing the tokens into arrays that are passed into the drawGraph()
method.
 Example call:
 ./gcview.py ../tmp/gc.log gc-24h.png
 ./gcview.py ../tmp/gc.log gc-6h.png "2006-08-13 05:00" "2006-08-13
11:00"
 ./gcview.py ../tmp/gc.log gc-2h.png "2006-08-13 09:00" "2006-08-13
11:00"
 ./gcview.py ../tmp/gc.log gc-1h.png "2006-08-13 10:00" "2006-08-13
11:00"
 """
 if (len(sys.argv) != 3 and len(sys.argv) != 5):
 usage()
 input = sys.argv[1]
 output = sys.argv[2]
 # optional start and end times provided
 if (len(sys.argv) == 5):
 sliceLogFile = True
 startTime = convertISOToUnixTS(sys.argv[3])
 endTime = convertISOToUnixTS(sys.argv[4])
 else:
 sliceLogFile = False
 startTime = 0
 endTime = 0
 # The base time is the ctime for the log file
 baseTS = baseTimeStamp(input)
 # initialize local variables
 timeStampsBeforeGc = []
 usedBeforeGc = []
 timeStampsAfterGc = []
 usedAfterGc = []
 heapSizes = []
 timeStampsForFullGc = []
 fullGcIndicators = []
 gcStartTS = -1
 gcEndTS = -1
 # read input and parse line by line
 fin = open(input, 'r')
 while (True):
 line = fin.readline()
 if (line == ""):
 break 
 (tsoffset, usedBefore, usedAfter, elapsed, heapSize, isFullGc) =
parse(line.rstrip())
 # Set the first timestamp once for the very first record, and keep
 # updating the last timestamp until we run out of lines to read
 if (gcStartTS == -1):
 gcStartTS = tsoffset
 gcEndTS = tsoffset
 # If start and end times are specified, then we should ignore data
 # that are outside the range
 if (sliceLogFile):
 actualTime = baseTS - gcStartTS + tsoffset
 if (actualTime < startTime or actualTime > endTime):
 continue
 # X and Y arrays for before GC line, X will need postprocessing
 timeStampsBeforeGc.append(tsoffset)
 usedBeforeGc.append(usedBefore / 1024)
 # X and Y arrays for after GC line, X will need postprocessing
 timeStampsAfterGc.append(tsoffset + elapsed)
 usedAfterGc.append(usedAfter / 1024)
 # Y array for heap size (use minOffSetBeforeGC for X), will use
 # Y axis for after GC line
 heapSizes.append(heapSize / 1024)
 # X and Y arrays for Full GC line, X will need postprocessing
 if (isFullGc):
 timeStampsForFullGc.append(tsoffset)
 fullGcIndicators.append(1)
 fin.close()
 # Convert log start and end time stamps to printable format
 if (sliceLogFile):
 logStartTS = sys.argv[3]
 logEndTS = sys.argv[4]
 else:
 logStartTS = timeString(baseTS)
 logEndTS = timeString(baseTS + gcEndTS - gcStartTS)
 # convert timestamps from seconds since JVM startup to minutes elapsed
 # since first timestamp entry
 startTime = timeStampsBeforeGc[0]
 for i in range(len(timeStampsBeforeGc)):
 timeStampsBeforeGc[i] = minutesElapsed(timeStampsBeforeGc[i],
startTime)
 timeStampsAfterGc[i] = minutesElapsed(timeStampsAfterGc[i],
startTime)
 for i in range(len(timeStampsForFullGc)):
 timeStampsForFullGc[i] = minutesElapsed(timeStampsForFullGc[i],
startTime)
 # Send off to graph results
 drawGraph(timeStampsBeforeGc, usedBeforeGc, timeStampsAfterGc,
usedAfterGc, heapSizes, timeStampsForFullGc, fullGcIndicators, logStartTS,
logEndTS, output)
if __name__ == "__main__":
 main()
alberttresens wrote:
> 
> Hi,
> Thanks for the reply.
> I did already try it and still go the same trace back. I tried with long
> arrays [1,2,....,n] and with short ones. I also tried with single numbers. 
> How can it get an out of range array?
> 
> File "gcview.py", line 87, in drawGraph
> plot([0],[0])
> File "/usr/local/lib/python2.6/site-packages/matplotlib/pyplot.py", line
> 2287, in plot
> ret = ax.plot(*args, **kwargs)
> File "/usr/local/lib/python2.6/site-packages/matplotlib/axes.py", line
> 3776, in plot
> self.autoscale_view(scalex=scalex, scaley=scaley)
> File "/usr/local/lib/python2.6/site-packages/matplotlib/axes.py", line
> 1793, in autoscale_view
> x0, x1 = xlocator.view_limits(x0, x1)
> File "/usr/local/lib/python2.6/site-packages/matplotlib/ticker.py", line
> 1176, in view_limits
> return np.take(self.bin_boundaries(dmin, dmax), [0,-1])
> File "/usr/local/lib/python2.6/site-packages/numpy/core/fromnumeric.py",
> line 103, in take
> return take(indices, axis, out, mode)
> IndexError: index out of range for array
> 
> 
> 
> 
> John Hunter-4 wrote:
>> 
>> On Wed, Jul 21, 2010 at 10:05 AM, alberttresens
>> <alb...@gm...> wrote:
>>>
>>> I am getting this trace when trying to plot. I tried all possible
>>> combinations in the plot parameters, always the same. Can someone recon
>>> what
>>> is happening?
>>>
>>> Traceback (most recent call last):
>>> File "gcview.py", line 226, in <module>
>>>  main()
>>> File "gcview.py", line 222, in main
>>>  drawGraph(timeStatpsBeforeGc, usedBeforeGc, timeStampsAfterGc,
>>> usedAfterGc, heapSizes, timeStampsForFullGc, fullGcIndicators,
>>> logStartTS,
>>> logEndTS, output)
>>> File "gcview.py", line 87, in drawGraph
>>>  plot(0,0)
>> 
>> Recent versions of mpl support plotting of scalars, but older versions
>> require plotting sequences. Here you might try:
>> 
>> plot([0], [0])
>> 
>> instead of
>> 
>> plot(0, 0)
>> 
>> JDH
>> 
>> ------------------------------------------------------------------------------
>> This SF.net email is sponsored by Sprint
>> What will you do first with EVO, the first 4G phone?
>> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>> 
>> 
> 
> 
-- 
View this message in context: http://old.nabble.com/Plot%28%29-%3A-IndexError%3A-index-out-of-range-for-array-tp29226333p29234559.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: aliko <ali...@gm...> - 2010年07月22日 08:36:03
Could please anyone help me to get axises autoscaling in following 
example? I took it from the examples and slightly modified it to remove 
all unecessary things trying to make it as short as possible.
Thanks in advance!
import sys
from matplotlib.figure import Figure
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as 
FigureCanvas
from PyQt4 import QtGui
import numpy as np
import time
class BlitQT(FigureCanvas):
 def __init__(self):
 FigureCanvas.__init__(self, Figure())
 self.ax = self.figure.add_subplot(111)
 self.ax.grid()
 self.draw()
 self.ax_background = self.copy_from_bbox(self.ax.bbox)
 self.cnt = 0
 self.x = np.arange(0,2*np.pi,0.01)
 self.sin_line, = self.ax.plot(self.x, np.sin(self.x), 
animated=True)
 self.cos_line, = self.ax.plot(self.x, np.cos(self.x), 
animated=True)
 self.tstart = time.time()
 self.startTimer(10)
 def timerEvent(self, evt):
 self.restore_region(self.ax_background, bbox=self.ax.bbox)
 # update the data
 self.sin_line.set_ydata(np.sin(self.x+self.cnt/10.0))
 self.cos_line.set_ydata((self.x+self.cnt)/50.0)
 # just draw the animated artist
 self.ax.draw_artist(self.sin_line)
 self.ax.draw_artist(self.cos_line)
 # just redraw the axes rectangle
 self.blit(self.ax.bbox)
 if self.cnt == 0:
 self.draw()
 self.cnt += 1
app = QtGui.QApplication(sys.argv)
widget = BlitQT()
widget.show()
sys.exit(app.exec_())
From: alberttresens <alb...@gm...> - 2010年07月22日 08:35:56
Hi,
Thanks for the reply.
I did already try it and still go the same trace back. I tried with long
arrays [1,2,....,n] and with short ones. I also tried with single numbers. 
How can it get an out of range array?
 File "gcview.py", line 87, in drawGraph
 plot([0],[0])
 File "/usr/local/lib/python2.6/site-packages/matplotlib/pyplot.py", line
2287, in plot
 ret = ax.plot(*args, **kwargs)
 File "/usr/local/lib/python2.6/site-packages/matplotlib/axes.py", line
3776, in plot
 self.autoscale_view(scalex=scalex, scaley=scaley)
 File "/usr/local/lib/python2.6/site-packages/matplotlib/axes.py", line
1793, in autoscale_view
 x0, x1 = xlocator.view_limits(x0, x1)
 File "/usr/local/lib/python2.6/site-packages/matplotlib/ticker.py", line
1176, in view_limits
 return np.take(self.bin_boundaries(dmin, dmax), [0,-1])
 File "/usr/local/lib/python2.6/site-packages/numpy/core/fromnumeric.py",
line 103, in take
 return take(indices, axis, out, mode)
IndexError: index out of range for array
John Hunter-4 wrote:
> 
> On Wed, Jul 21, 2010 at 10:05 AM, alberttresens
> <alb...@gm...> wrote:
>>
>> I am getting this trace when trying to plot. I tried all possible
>> combinations in the plot parameters, always the same. Can someone recon
>> what
>> is happening?
>>
>> Traceback (most recent call last):
>> File "gcview.py", line 226, in <module>
>>  main()
>> File "gcview.py", line 222, in main
>>  drawGraph(timeStatpsBeforeGc, usedBeforeGc, timeStampsAfterGc,
>> usedAfterGc, heapSizes, timeStampsForFullGc, fullGcIndicators,
>> logStartTS,
>> logEndTS, output)
>> File "gcview.py", line 87, in drawGraph
>>  plot(0,0)
> 
> Recent versions of mpl support plotting of scalars, but older versions
> require plotting sequences. Here you might try:
> 
> plot([0], [0])
> 
> instead of
> 
> plot(0, 0)
> 
> JDH
> 
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
-- 
View this message in context: http://old.nabble.com/Plot%28%29-%3A-IndexError%3A-index-out-of-range-for-array-tp29226333p29234467.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Benjamin K. <sic...@gm...> - 2010年07月22日 06:38:29
Hello João,
this was really helpful. I really appreciate your work. 
Thanks so far,
Ben
On 2010年7月21日 13:19:21 +0100
João Luís Silva <js...@fc...> wrote:
> On 07/21/2010 12:27 PM, Benjamin Koep wrote:
> > Hello,
> >
> > I got a big problem currently and i really hope that someone here
> > can help me.
> >
> > I am working on some graphs that are integrated into a django app.
> > So far no problem. I had really no experience with matplotlib
> > before but i managed to create 2 of 3 graph types the way our
> > graphics designer wants them to be.
> >
> > The last variation is making me really sick because it has nothing
> > much to do with an ordinary graph (except the fact that is has
> > bars ;)).
> >
> > Please take a look at the attachment and give me a hint how i could
> > realize that. I would really appreciate that.
> >
> > Kind regards,
> >
> > Ben
> >
> 
> The attached example (adapted mostly from barchart_demo2.py) should 
> guide you in the right direction.
> 
> Regards,
> João Luís
From: Andreas <li...@hi...> - 2010年07月22日 06:04:59
>> Hi there,
>>
>> I try to install matplotlib 1.0 via easy install. But a simple
>>
>> easy_install -U matplotlib
>>
>> produces this, effectively installing 0.99.1
>>
>> Searching for matplotlib
>> Reading http://pypi.python.org/simple/matplotlib/
>> Reading http://matplotlib.sourceforge.net
>> Reading
>> http://sourceforge.net/project/showfiles.php?group_id=80706&package_id=82474
>> Reading
>> https://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.0
>> Reading
>> https://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-0.99.3/
>> Reading http://sourceforge.net/project/showfiles.php?group_id=80706
>> Reading
>> https://sourceforge.net/project/showfiles.php?group_id=80706&package_id=278194
>> Reading
>> https://sourceforge.net/project/showfiles.php?group_id=80706&package_id=82474
>> Reading
>> https://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-0.99.1/
>> Best match: matplotlib 0.91.1
>> Downloading
>> http://pypi.python.org/packages/source/m/matplotlib/matplotlib-0.91.1.tar.gz#md5=56a9344b077b5accbc4823be19f69dd6
>>
>> Why is that?
> 
> 
> What is your platform/OS and what version of python are you using and
> where did you get it from?
Linux antares 2.6.32-23-generic #37-Ubuntu SMP Fri Jun 11 08:03:28 UTC
2010 x86_64 GNU/Linux
Ubuntu 10.4 LTS amd64
Python 2.6.5 from Ubuntu repositories.
Cheers, A.
2 messages has been excluded from this view by a project administrator.

Showing results of 30

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