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



Showing results of 339

<< < 1 .. 12 13 14 (Page 14 of 14)
From: John J. <jw...@gm...> - 2011年11月02日 17:12:55
Thanks Ben! 
I just updated my Macports and it brought in v1.1.0 so I will check it out
for easier animation.
In the meantime I notice that with MPL v1.1.0 the program crashes at the end
a most of my old MPL example programs (I use the GTKAgg backend for all of
them). A typical way to end the program is:
 gtk.main_quit()
 raise SystemExit
and it crashes on the call the ''raise SystemExit". A typical output is
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/si
te-packages/matplotlib/backends/backend_gtk.py:552: GtkWarning:
gtk_widget_unrealize: assertion `GTK_IS_WIDGET (widget)' failed
 self.toolbar.destroy()
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/si
te-packages/matplotlib/backends/backend_gtk.py:552: GtkWarning:
gtk_widget_is_toplevel: assertion `GTK_IS_WIDGET (widget)' failed
 self.toolbar.destroy()
Any thoughts are appreciated!
thanks again,
john
From: Benjamin R. <ben...@ou...> - 2011年11月02日 17:11:57
I have seen situations when using datetimes for the x axis where if all the
data being viewed is masked (or nans, or whatever) then it errors out
because the axis range can't be determined. Maybe that is what is
happening here?
Ben Root
On Wed, Nov 2, 2011 at 11:48 AM, Michael Droettboom <md...@st...> wrote:
> matplotlib should handle both masked arrays and arrays with NaNs and
> treat both the same. Can you reduce the script to something that can be
> run independently without data? It's not clear to me yet why this is
> failing.
>
> Mike
>
>
> On 11/01/2011 05:24 PM, questions anon wrote:
>
> Hi All,
> I am trying to plot time against mean daily temperature values. The
> problem is temperature contains no data in a few areas. I want to be able
> to ignore this and continue plotting.
> When I run the below script on my data that has all normal numbers it
> works fine but when I run the script on my data that has sections of 'no
> data' I receive the below error and the graph will not plot the trendline.
> Any suggestions on how I could fix this.
> Thanks
>
> *Warning (from warnings module):
> File "C:\Python27\lib\site-packages\numpy\ma\core.py", line 3785
> warnings.warn("Warning: converting a masked element to nan.")
> UserWarning: Warning: converting a masked element to nan.*
>
>
> from netCDF4 import Dataset
> import matplotlib.pyplot as plt
> import numpy as N
> from mpl_toolkits.basemap import Basemap
> from netcdftime import utime
> from datetime import datetime
> import os
> from numpy import *
> import matplotlib.dates as mdates
> from numpy import ma as MA
>
> TSFCmeanall=[]
> timeall=[]
> time_intall=[]
>
> MainFolder=r"E:/GriddedData/T_SFC/1987/"
> for (path, dirs, files) in os.walk(MainFolder):
> for dir in dirs:
> print dir
> path=path+'/'
>
> for ncfile in files:
> if ncfile[-3:]=='.nc':
> ncfile=os.path.join(path,ncfile)
> ncfile=Dataset(ncfile, 'r+', 'NETCDF4')
> TSFC=ncfile.variables['T_SFC'][0:20]
> TIME=ncfile.variables['time'][0:20]
>
> fillvalue=ncfile.variables['T_SFC']._FillValue
> TSFC=MA.masked_values(TSFC, fillvalue)
> ncfile.close()
>
> for TSFC, TIME in
> zip((TSFC[:]),(TIME[:])):
> cdftime=utime('seconds since
> 1970年01月01日 00:00:00')
> ncfiletime=cdftime.num2date(TIME)
> timestr=str(ncfiletime)
> d = datetime.strptime(timestr,
> '%Y-%m-%d %H:%M:%S')
> date_string =
> d.strftime('%Y%m%d%H')
> time_int=int(date_string)
>
> TSFCmean=N.mean(TSFC)
>
> TSFCmeanall.append(TSFCmean)
> timeall.append(ncfiletime)
> time_intall.append(time_int)
>
> x=timeall
> y=TSFCmeanall
> x2=time_intall
>
> fig, ax=plt.subplots(1)
>
> z=N.polyfit(x2,y,1)
> p=N.poly1d(z)
>
> plt.plot(x,y)
> plt.plot(x,p(x2),'r--') #add trendline to plot
>
> fig.autofmt_xdate()
> ax.fmt_xdata=mdates.DateFormatter('%Y-%m-%d %H:%M:%S')
> plt.ylabel("Temperature C")
> plt.title("Mean Daily Temp")
> plt.show()
>
>
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> RSA&#174; Conference 2012
> Save 700ドル by Nov 18
> Register now&#33;http://p.sf.net/sfu/rsa-sfdev2dev1
>
>
>
> _______________________________________________
> Matplotlib-users mailing lis...@li...https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
>
> ------------------------------------------------------------------------------
> RSA&#174; Conference 2012
> Save 700ドル by Nov 18
> Register now&#33;
> http://p.sf.net/sfu/rsa-sfdev2dev1
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: Michael D. <md...@st...> - 2011年11月02日 16:51:38
On 11/02/2011 10:53 AM, Mads Ipsen wrote:
> Hi,
>
> I am trying to build MPL 1.1.0 with VS 2008 on Windows XP 32. I have 
> installed
>
> * Python 2.7.2
> * Numpy 1.6
>
> In the docs it says
>
> Windows users only need the first two (python and numpy) since the 
> others are built into the matplotlib Windows installers available for 
> download at the sourceforge site. OK, so I also downloaded 
> matplotlib-1.1.0.win32-py2.7.exe and installed that.
>
> Now I cd to the matplotlib-1.1.0 directory and issue
>
> python setup.py build
>
> and get the following error.
>
> C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo 
> /Ox /MD /W
> 3 /GS- /DNDEBUG -DPY_ARRAY_UNIQUE_SYMBOL=MPL_ARRAY_API 
> -DPYCXX_ISO_CPP_LIB=1 -Ic
> :\Python27\lib\site-packages\numpy\core\include -I. 
> -Ic:\Python27\lib\site-packa
> ges\numpy\core\include\freetype2 -I.\freetype2 -Ic:\Python27\include 
> -Ic:\Python
> 27\PC /Tpsrc/ft2font.cpp /Fobuild\temp.win32-2.7\Release\src/ft2font.obj
> ft2font.cpp
> C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocale(342) : 
> warning C
> 4530: C++ exception handler used, but unwind semantics are not 
> enabled. Specify
> /EHsc
> c:\cygwin\home\mads ipsen\matplotlib-1.1.0\src\ft2font.h(16) : fatal 
> error C1083
> : Cannot open include file: 'ft2build.h': No such file or directory
> error: command '"C:\Program Files\Microsoft Visual Studio 
> 9.0\VC\BIN\cl.exe"' fa
> iled with exit status 2
>
>
> Any clues to why ft2build.h cannot be located. The above docs says it 
> should be part of the binary installer.
The binary for freetype is included with the installer, but the headers 
(needed to build, but not to run) are not. Do you need to build 
matplotlib from source, or just use it?
Mike
From: Michael D. <md...@st...> - 2011年11月02日 16:48:57
matplotlib should handle both masked arrays and arrays with NaNs and 
treat both the same. Can you reduce the script to something that can be 
run independently without data? It's not clear to me yet why this is 
failing.
Mike
On 11/01/2011 05:24 PM, questions anon wrote:
> Hi All,
> I am trying to plot time against mean daily temperature values. The 
> problem is temperature contains no data in a few areas. I want to be 
> able to ignore this and continue plotting.
> When I run the below script on my data that has all normal numbers it 
> works fine but when I run the script on my data that has sections of 
> 'no data' I receive the below error and the graph will not plot the 
> trendline. Any suggestions on how I could fix this.
> Thanks
>
> /Warning (from warnings module):
> File "C:\Python27\lib\site-packages\numpy\ma\core.py", line 3785
> warnings.warn("Warning: converting a masked element to nan.")
> UserWarning: Warning: converting a masked element to nan./
>
>
> from netCDF4 import Dataset
> import matplotlib.pyplot as plt
> import numpy as N
> from mpl_toolkits.basemap import Basemap
> from netcdftime import utime
> from datetime import datetime
> import os
> from numpy import *
> import matplotlib.dates as mdates
> from numpy import ma as MA
>
> TSFCmeanall=[]
> timeall=[]
> time_intall=[]
>
> MainFolder=r"E:/GriddedData/T_SFC/1987/"
> for (path, dirs, files) in os.walk(MainFolder):
> for dir in dirs:
> print dir
> path=path+'/'
>
> for ncfile in files:
> if ncfile[-3:]=='.nc':
> ncfile=os.path.join(path,ncfile)
> ncfile=Dataset(ncfile, 'r+', 
> 'NETCDF4')
> TSFC=ncfile.variables['T_SFC'][0:20]
> TIME=ncfile.variables['time'][0:20]
> 
> fillvalue=ncfile.variables['T_SFC']._FillValue
> TSFC=MA.masked_values(TSFC, fillvalue)
> ncfile.close()
>
> for TSFC, TIME in 
> zip((TSFC[:]),(TIME[:])):
> cdftime=utime('seconds since 
> 1970年01月01日 00:00:00')
> ncfiletime=cdftime.num2date(TIME)
> timestr=str(ncfiletime)
> d = datetime.strptime(timestr, 
> '%Y-%m-%d %H:%M:%S')
> date_string = 
> d.strftime('%Y%m%d%H')
> time_int=int(date_string)
>
> TSFCmean=N.mean(TSFC)
>
> TSFCmeanall.append(TSFCmean)
> timeall.append(ncfiletime)
> time_intall.append(time_int)
>
> x=timeall
> y=TSFCmeanall
> x2=time_intall
>
> fig, ax=plt.subplots(1)
>
> z=N.polyfit(x2,y,1)
> p=N.poly1d(z)
>
> plt.plot(x,y)
> plt.plot(x,p(x2),'r--') #add trendline to plot
>
> fig.autofmt_xdate()
> ax.fmt_xdata=mdates.DateFormatter('%Y-%m-%d %H:%M:%S')
> plt.ylabel("Temperature C")
> plt.title("Mean Daily Temp")
> plt.show()
>
>
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> RSA&#174; Conference 2012
> Save 700ドル by Nov 18
> Register now&#33;
> http://p.sf.net/sfu/rsa-sfdev2dev1
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Mads I. <mad...@gm...> - 2011年11月02日 14:53:20
Hi,
I am trying to build MPL 1.1.0 with VS 2008 on Windows XP 32. I have 
installed
* Python 2.7.2
* Numpy 1.6
In the docs it says
Windows users only need the first two (python and numpy) since the 
others are built into the matplotlib Windows installers available for 
download at the sourceforge site. OK, so I also downloaded 
matplotlib-1.1.0.win32-py2.7.exe and installed that.
Now I cd to the matplotlib-1.1.0 directory and issue
python setup.py build
and get the following error.
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo 
/Ox /MD /W
3 /GS- /DNDEBUG -DPY_ARRAY_UNIQUE_SYMBOL=MPL_ARRAY_API 
-DPYCXX_ISO_CPP_LIB=1 -Ic
:\Python27\lib\site-packages\numpy\core\include -I. 
-Ic:\Python27\lib\site-packa
ges\numpy\core\include\freetype2 -I.\freetype2 -Ic:\Python27\include 
-Ic:\Python
27\PC /Tpsrc/ft2font.cpp /Fobuild\temp.win32-2.7\Release\src/ft2font.obj
ft2font.cpp
C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocale(342) : 
warning C
4530: C++ exception handler used, but unwind semantics are not enabled. 
Specify
/EHsc
c:\cygwin\home\mads ipsen\matplotlib-1.1.0\src\ft2font.h(16) : fatal 
error C1083
: Cannot open include file: 'ft2build.h': No such file or directory
error: command '"C:\Program Files\Microsoft Visual Studio 
9.0\VC\BIN\cl.exe"' fa
iled with exit status 2
Any clues to why ft2build.h cannot be located. The above docs says it 
should be part of the binary installer.
Best regards,
Mads
-- 
+-----------------------------------------------------+
| Mads Ipsen |
+----------------------+------------------------------+
| Gåsebæksvej 7, 4. tv | |
| DK-2500 Valby | phone: +45-29716388 |
| Denmark | email: mad...@gm... |
+----------------------+------------------------------+
From: yelena <som...@in...> - 2011年11月02日 12:48:36
It works!
Thank you very much! :)
Dale Chayes wrote:
> 
> Attached is a very simple version.
> It assumes your sample data is in a file.
> 
> The first line is "magic" and makes significant assumptions about where
> python is installed on your system. This may or may not be the right
> answer for your system.
> 
> Plotting requires matplotlib which you may need to install.
> 
> 
> ------------
> #!/sw/bin/python
> 
> import numpy
> import matplotlib.pyplot as plt
> 
> dataset = numpy.genfromtxt(fname='readata.txt',skip_header=1)
> 
> print dataset
> 
> x=dataset[:,0]
> y=dataset[:,1]
> 
> plt.figure(1)
> plt.plot(x,y)
> plt.plot(x,y,'ro')
> plt.show()
> --------------
> 
> 
> On Nov 1, 2011, at 9:29 , yelena wrote:
> 
>> 
>> I have numpy.
>> I need the body of a program, which plots y dependence of x.
>> 
>> Maybe than I'll figure out how does it works...
>> 
>> 
>> Daniel Hyams wrote:
>>> 
>>> One quick way of doing this is to use numpy:
>>> 
>>> import numpy
>>> 
>>> dataset = numpy.genfromtxt(fname='yourfilename',skip_header=1)
>>> 
>>> http://docs.scipy.org/doc/numpy/reference/generated/numpy.genfromtxt.html
>>> 
>>> On Tue, Nov 1, 2011 at 8:50 AM, yelena <som...@in...> wrote:
>>>> 
>>>> Hi!
>>>> I'm new at Matplotlib, so I need a little help.
>>>> I was trying to load data from txt files with no luck.
>>>> I have 2 collumns in txt files and I need to plot a XY graph. Should I
>>>> modify txt file to other format?
>>>> 
>>>> Can someone give me a simple example for doing this?
>>>> 
>>>> In txt file could be such information:
>>>> Meters Seconds
>>>> 1 4
>>>> 2 8
>>>> 3 12
>>>> 4 16
>>>> 5 20
>>>> 
>>>> Thanks in advance!
>>>> 
>>>> --
>>>> View this message in context:
>>>> http://old.nabble.com/Loading-txt-files-tp32758393p32758393.html
>>>> Sent from the matplotlib - users mailing list archive at Nabble.com.
>>>> 
>>>> 
>>>> ------------------------------------------------------------------------------
>>>> RSA&reg; Conference 2012
>>>> Save &#36;700 by Nov 18
>>>> Register now
>>>> http://p.sf.net/sfu/rsa-sfdev2dev1
>>>> _______________________________________________
>>>> Matplotlib-users mailing list
>>>> Mat...@li...
>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>> 
>>> 
>>> 
>>> 
>>> -- 
>>> Daniel Hyams
>>> dh...@gm...
>>> 
>>> ------------------------------------------------------------------------------
>>> RSA&reg; Conference 2012
>>> Save &#36;700 by Nov 18
>>> Register now
>>> http://p.sf.net/sfu/rsa-sfdev2dev1
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Mat...@li...
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>> 
>>> 
>> 
>> -- 
>> View this message in context:
>> http://old.nabble.com/Loading-txt-files-tp32758393p32758620.html
>> Sent from the matplotlib - users mailing list archive at Nabble.com.
>> 
>> 
>> ------------------------------------------------------------------------------
>> RSA&reg; Conference 2012
>> Save &#36;700 by Nov 18
>> Register now
>> http://p.sf.net/sfu/rsa-sfdev2dev1
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
> ------------------------------------------------------------------------------
> RSA&reg; Conference 2012
> Save &#36;700 by Nov 18
> Register now
> http://p.sf.net/sfu/rsa-sfdev2dev1
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
-- 
View this message in context: http://old.nabble.com/Loading-txt-files-tp32758393p32765442.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Benjamin R. <ben...@ou...> - 2011年11月02日 05:58:49
On Wednesday, November 2, 2011, John Jameson <jw...@gm...> wrote:
> Hi,
> I am trying to do an animation in two axes (subplots) and I can get it to
work so-so if I do it the "wrong way" but when I do it the "right way" I
don't see anything in my second subplot.
> The first subplot (ax1) shows a bunch of moving line segments ("sticks")
and the second one (ax2) shows a low resolution (pixellated) view of the
first subplot. The latter (ax2) uses imshow() but when I update it through
setarray() and blit it onto the canvas it doesn't show up (although the
sticks in the ax1 show up fine). However, if I insert the line
canvas.draw() after the ax2 blit it works but it makes the ax1 animation
very jittery.
> Can someone tell me the correct way to do this? I'm still a tenderfoot
in Matplotlib ;-(
> thanks!
> John
>
>
>
>
>
>
> class Sticks_animator():
>
> x_offset = 0.0
>
> def __init__(self, n_sticks_tot, n_pixels_horizontal=0,
>
> n_pixels_vertical=0 ):
>
> .
> .
> .
> .
> .
>
> def reset(self):
>
> self.background1 = None
>
> self.background2 = None
>
> self.start = 1
>
> def draw_sticks(self):
>
> if self.start:
>
> self.poly = []
>
> for i in range( self.n_sticks_tot):
>
> x_stick = array([ [self.x1[i], self.y1[i]],
>
> [self.x2[i], self.y2[i]] ] )
>
>
>
> self.poly.append( Polygon( x_stick, animated=True,
>
> lw=2, fill=False) )
>
> self.ax1.add_patch(self.poly[i])
>
> self.ax1.draw_artist(self.poly[i])
>
>
>
> else:
>
> for i in range( self.n_sticks_tot):
>
> x_stick = array([ [self.x1[i], self.y1[i]],
>
> [self.x2[i], self.y2[i]] ] )
>
> self.poly[i].set_xy(x_stick)
>
> self.ax1.draw_artist(self.poly[i])
>
> def draw_retina(self):
>
> if self.start:
>
> self.img = self.ax2.imshow(self.inten,
interpolation='nearest')
>
> else:
>
> self.img.set_array(self.inten)
>
>
>
> def step_it(self):
>
> self.inten, self.n_sticks_tot, self.x1, self.y1, \
>
> self.x2, self.y2, done = self.stks.Step_it()
>
>
> # self.stks.Step_it() is finds all the stick coordinates
>
> # and inten is a NXN array of a pixellated (low res) view
>
> # of all the sticks
>
>
>
> if self.background1 is None:
>
> self.background1 = self.canvas.copy_from_bbox(self.ax1.bbox)
>
> self.canvas.restore_region(self.background1)
>
> self.draw_sticks()
>
> self.canvas.blit(self.ax1.bbox)
>
> if self.add_retina_view:
>
> self.draw_retina()
>
> self.canvas.blit(self.ax2.bbox)
>
> # self.canvas.draw() IF I UNCOMMENT THIS IT "WORKS"
>
> self.start = 0
>
>
>
> if done:
>
> gtk.main_quit()
>
> raise SystemExit
>
> return True
>
> def mainer( self, stks ):
>
> self.stks = stks
>
> if isinteractive():
>
> ioff()
>
> def start_anim(event):
>
> gobject.idle_add( self.step_it )
>
> self.canvas.mpl_disconnect(start_anim.cid)
>
>
>
> start_anim.cid = self.canvas.mpl_connect('draw_event', start_anim)
>
> plt.show()
>
Which version of mpl are you using? v1.1.0 comes with an animation module
to handle most of this for you. Check out the animation examples on the
website.
Note, very often, when blitting, the issue can be that the individual
artists were not sett as animated. Note that (counter-intuitively) the new
animation module does not fully work if animate=True, so I'd using
animate.py, don't set animate=True.
Hopefully, that wasn't too confusing...
Ben Root
From: John J. <jw...@gm...> - 2011年11月02日 05:34:43
Hi,
I am trying to do an animation in two axes (subplots) and I can get it to
work so-so if I do it the "wrong way" but when I do it the "right way" I
don't see anything in my second subplot.
The first subplot (ax1) shows a bunch of moving line segments ("sticks") and
the second one (ax2) shows a low resolution (pixellated) view of the first
subplot. The latter (ax2) uses imshow() but when I update it through
setarray() and blit it onto the canvas it doesn't show up (although the
sticks in the ax1 show up fine). However, if I insert the line canvas.draw()
after the ax2 blit it works but it makes the ax1 animation very jittery.
Can someone tell me the correct way to do this? I'm still a tenderfoot in
Matplotlib ;-(
thanks!
John
class Sticks_animator():
 x_offset = 0.0 
 def __init__(self, n_sticks_tot, n_pixels_horizontal=0,
 n_pixels_vertical=0 ):
.
.
.
.
.
 def reset(self):
 self.background1 = None
 self.background2 = None
 self.start = 1
 def draw_sticks(self):
 if self.start:
 self.poly = []
 for i in range( self.n_sticks_tot):
 x_stick = array([ [self.x1[i], self.y1[i]],
 [self.x2[i], self.y2[i]] ] )
 
 self.poly.append( Polygon( x_stick, animated=True,
 lw=2, fill=False) )
 self.ax1.add_patch(self.poly[i])
 self.ax1.draw_artist(self.poly[i])
 
 else:
 for i in range( self.n_sticks_tot):
 x_stick = array([ [self.x1[i], self.y1[i]],
 [self.x2[i], self.y2[i]] ] )
 self.poly[i].set_xy(x_stick)
 self.ax1.draw_artist(self.poly[i])
 def draw_retina(self):
 if self.start:
 self.img = self.ax2.imshow(self.inten, interpolation='nearest')
 else: 
 self.img.set_array(self.inten)
 
 def step_it(self):
 self.inten, self.n_sticks_tot, self.x1, self.y1, \
 self.x2, self.y2, done = self.stks.Step_it()
 
# self.stks.Step_it() is finds all the stick coordinates
# and inten is a NXN array of a pixellated (low res) view
# of all the sticks
 
if self.background1 is None:
 self.background1 = self.canvas.copy_from_bbox(self.ax1.bbox)
 self.canvas.restore_region(self.background1)
 self.draw_sticks()
 self.canvas.blit(self.ax1.bbox)
 if self.add_retina_view:
 self.draw_retina()
 self.canvas.blit(self.ax2.bbox)
# self.canvas.draw() IF I UNCOMMENT THIS IT "WORKS"
 self.start = 0
 
 if done:
 gtk.main_quit()
 raise SystemExit
 return True
 def mainer( self, stks ):
 self.stks = stks 
 if isinteractive():
 ioff()
 def start_anim(event):
 gobject.idle_add( self.step_it )
 self.canvas.mpl_disconnect(start_anim.cid)
 
 start_anim.cid = self.canvas.mpl_connect('draw_event', start_anim)
 plt.show()
From: gmail <mas...@gm...> - 2011年11月01日 23:10:07
hi all,
i'm tring to wrote some code to do a stem plot from a dictionary of array.
the code is :
 def multi_stem_plot(self, key, name, title="", time_min="", time_max=""):
 """ doc """
 rows = len(key)
 cols = 1
 gr = str(rows)+str(cols)
 for i in enumerate(key):
 ylabel = key[i[0]].keys()[0]
 data = key[i[0]][key[i[0]].keys()[0]]
 data[np.isnan(data)]=0
 nn = i[0] + 1
 ngr = str(gr)+str(nn)
 subplot(int(ngr))
 subplots_adjust(left=0.125, bottom=0.1, right=0.9, top=0.9, \
 wspace=0.2, hspace=0.5)
 x_p = data[0][np.where(data[1]>=0)[0]]
 y_p = data[1][np.where(data[1]>=0)[0]]
 x_n = data[0][np.where(data[1]<0)[0]]
 y_n = data[1][np.where(data[1]<0)[0]]
 markerline, stemlines, baseline = stem(x_p, y_p, 'r-')
 setp(markerline, 'markerfacecolor', 'b')
 setp(baseline, 'color', 'r', 'linewidth', 2)
 setp(stemlines, 'linewidth', 1)
 markerline, stemlines, baseline = stem(x_n, y_n, 'b-')
 setp(markerline, 'markerfacecolor', 'b')
 setp(baseline, 'color', 'r', 'linewidth', 2)
 setp(stemlines, 'linewidth', 1)
 setp(gca(), 'ylabel', ylabel)
 setp(gca(), 'title', 'Climate Indices : '+str(ylabel))
 grid()
 setp(gca(), 'xlabel', 'Year')
 #if time_min or time_min != "":
 # setp(gca(), 'xlim', [time_min,time_max])
 fig = name+'.png'
 savefig(fig)
 show()
this line :
 #if time_min or time_min != "":
 # setp(gca(), 'xlim', [time_min,time_max])
generate this error :
NotImplementedError: 'Not implemented for this type'
function main in Climate.py at line 178
Climate().multi_stem_plot(md, 'Climate Indices', data_min, data_max)
function multi_stem_plot in Climate.py at line 128
setp(gca(), 'xlim', [time_min,time_max])
function setp in pyplot.py at line 235
ret = _setp(*args, **kwargs)
function setp in artist.py at line 1209
ret.extend( [func(val)] )
function set_xlim in axes.py at line 2439
left, right = mtransforms.nonsingular(left, right, increasing=False)
function nonsingular in transforms.py at line 2282
if (not np.isfinite(vmin)) or (not np.isfinite(vmax)):
While this function works for a single plot :
 def stem_plot(self, data, name, time_min="", time_max=""):
 """ doc """
 data[np.isnan(data)]=0
 x_p = data[0][np.where(data[1]>=0)[0]]
 y_p = data[1][np.where(data[1]>=0)[0]]
 x_n = data[0][np.where(data[1]<0)[0]]
 y_n = data[1][np.where(data[1]<0)[0]]
 markerline, stemlines, baseline = stem(x_p, y_p, 'r-')
 setp(markerline, 'markerfacecolor', 'b')
 setp(baseline, 'color', 'r', 'linewidth', 2)
 setp(stemlines, 'linewidth', 1)
 markerline, stemlines, baseline = stem(x_n, y_n, 'b-')
 setp(markerline, 'markerfacecolor', 'b')
 setp(baseline, 'color', 'r', 'linewidth', 2)
 setp(stemlines, 'linewidth', 1)
 grid()
 if time_min or time_min != "":
 setp(gca(), 'xlim', [time_min,time_max])
 setp(gca(), 'xlabel', 'Year', 'ylabel', name)
 fig = name+'.png'
 savefig(fig)
 print 'indicator : ', name
 show(
Have you any clue on how to fix my error ?
Many thanks!
From: questions a. <que...@gm...> - 2011年11月01日 21:24:43
Hi All,
I am trying to plot time against mean daily temperature values. The problem
is temperature contains no data in a few areas. I want to be able to ignore
this and continue plotting.
When I run the below script on my data that has all normal numbers it works
fine but when I run the script on my data that has sections of 'no data' I
receive the below error and the graph will not plot the trendline. Any
suggestions on how I could fix this.
Thanks
*Warning (from warnings module):
 File "C:\Python27\lib\site-packages\numpy\ma\core.py", line 3785
 warnings.warn("Warning: converting a masked element to nan.")
UserWarning: Warning: converting a masked element to nan.*
from netCDF4 import Dataset
import matplotlib.pyplot as plt
import numpy as N
from mpl_toolkits.basemap import Basemap
from netcdftime import utime
from datetime import datetime
import os
from numpy import *
import matplotlib.dates as mdates
from numpy import ma as MA
TSFCmeanall=[]
timeall=[]
time_intall=[]
MainFolder=r"E:/GriddedData/T_SFC/1987/"
for (path, dirs, files) in os.walk(MainFolder):
 for dir in dirs:
 print dir
 path=path+'/'
 for ncfile in files:
 if ncfile[-3:]=='.nc':
 ncfile=os.path.join(path,ncfile)
 ncfile=Dataset(ncfile, 'r+', 'NETCDF4')
 TSFC=ncfile.variables['T_SFC'][0:20]
 TIME=ncfile.variables['time'][0:20]
fillvalue=ncfile.variables['T_SFC']._FillValue
 TSFC=MA.masked_values(TSFC, fillvalue)
 ncfile.close()
 for TSFC, TIME in
zip((TSFC[:]),(TIME[:])):
 cdftime=utime('seconds since
1970年01月01日 00:00:00')
 ncfiletime=cdftime.num2date(TIME)
 timestr=str(ncfiletime)
 d = datetime.strptime(timestr,
'%Y-%m-%d %H:%M:%S')
 date_string = d.strftime('%Y%m%d%H')
 time_int=int(date_string)
 TSFCmean=N.mean(TSFC)
 TSFCmeanall.append(TSFCmean)
 timeall.append(ncfiletime)
 time_intall.append(time_int)
x=timeall
y=TSFCmeanall
x2=time_intall
fig, ax=plt.subplots(1)
z=N.polyfit(x2,y,1)
p=N.poly1d(z)
plt.plot(x,y)
plt.plot(x,p(x2),'r--') #add trendline to plot
fig.autofmt_xdate()
ax.fmt_xdata=mdates.DateFormatter('%Y-%m-%d %H:%M:%S')
plt.ylabel("Temperature C")
plt.title("Mean Daily Temp")
plt.show()
From: Dale C. <da...@ld...> - 2011年11月01日 17:29:42
Attached is a very simple version.
It assumes your sample data is in a file.
The first line is "magic" and makes significant assumptions about where python is installed on your system. This may or may not be the right answer for your system.
Plotting requires matplotlib which you may need to install.
------------
#!/sw/bin/python
import numpy
import matplotlib.pyplot as plt
dataset = numpy.genfromtxt(fname='readata.txt',skip_header=1)
print dataset
x=dataset[:,0]
y=dataset[:,1]
plt.figure(1)
plt.plot(x,y)
plt.plot(x,y,'ro')
plt.show()
--------------
On Nov 1, 2011, at 9:29 , yelena wrote:
> 
> I have numpy.
> I need the body of a program, which plots y dependence of x.
> 
> Maybe than I'll figure out how does it works...
> 
> 
> Daniel Hyams wrote:
>> 
>> One quick way of doing this is to use numpy:
>> 
>> import numpy
>> 
>> dataset = numpy.genfromtxt(fname='yourfilename',skip_header=1)
>> 
>> http://docs.scipy.org/doc/numpy/reference/generated/numpy.genfromtxt.html
>> 
>> On Tue, Nov 1, 2011 at 8:50 AM, yelena <som...@in...> wrote:
>>> 
>>> Hi!
>>> I'm new at Matplotlib, so I need a little help.
>>> I was trying to load data from txt files with no luck.
>>> I have 2 collumns in txt files and I need to plot a XY graph. Should I
>>> modify txt file to other format?
>>> 
>>> Can someone give me a simple example for doing this?
>>> 
>>> In txt file could be such information:
>>> Meters Seconds
>>> 1 4
>>> 2 8
>>> 3 12
>>> 4 16
>>> 5 20
>>> 
>>> Thanks in advance!
>>> 
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Loading-txt-files-tp32758393p32758393.html
>>> Sent from the matplotlib - users mailing list archive at Nabble.com.
>>> 
>>> 
>>> ------------------------------------------------------------------------------
>>> RSA&reg; Conference 2012
>>> Save &#36;700 by Nov 18
>>> Register now
>>> http://p.sf.net/sfu/rsa-sfdev2dev1
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Mat...@li...
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>> 
>> 
>> 
>> 
>> -- 
>> Daniel Hyams
>> dh...@gm...
>> 
>> ------------------------------------------------------------------------------
>> RSA&reg; Conference 2012
>> Save &#36;700 by Nov 18
>> Register now
>> http://p.sf.net/sfu/rsa-sfdev2dev1
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>> 
>> 
> 
> -- 
> View this message in context: http://old.nabble.com/Loading-txt-files-tp32758393p32758620.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
> 
> 
> ------------------------------------------------------------------------------
> RSA&reg; Conference 2012
> Save &#36;700 by Nov 18
> Register now
> http://p.sf.net/sfu/rsa-sfdev2dev1
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: yelena <som...@in...> - 2011年11月01日 13:29:55
I have numpy.
I need the body of a program, which plots y dependence of x.
Maybe than I'll figure out how does it works...
Daniel Hyams wrote:
> 
> One quick way of doing this is to use numpy:
> 
> import numpy
> 
> dataset = numpy.genfromtxt(fname='yourfilename',skip_header=1)
> 
> http://docs.scipy.org/doc/numpy/reference/generated/numpy.genfromtxt.html
> 
> On Tue, Nov 1, 2011 at 8:50 AM, yelena <som...@in...> wrote:
>>
>> Hi!
>> I'm new at Matplotlib, so I need a little help.
>> I was trying to load data from txt files with no luck.
>> I have 2 collumns in txt files and I need to plot a XY graph. Should I
>> modify txt file to other format?
>>
>> Can someone give me a simple example for doing this?
>>
>> In txt file could be such information:
>> Meters  Seconds
>> 1      4
>> 2      8
>> 3      12
>> 4      16
>> 5      20
>>
>> Thanks in advance!
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Loading-txt-files-tp32758393p32758393.html
>> Sent from the matplotlib - users mailing list archive at Nabble.com.
>>
>>
>> ------------------------------------------------------------------------------
>> RSA&reg; Conference 2012
>> Save &#36;700 by Nov 18
>> Register now
>> http://p.sf.net/sfu/rsa-sfdev2dev1
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
> 
> 
> 
> -- 
> Daniel Hyams
> dh...@gm...
> 
> ------------------------------------------------------------------------------
> RSA&reg; Conference 2012
> Save &#36;700 by Nov 18
> Register now
> http://p.sf.net/sfu/rsa-sfdev2dev1
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
-- 
View this message in context: http://old.nabble.com/Loading-txt-files-tp32758393p32758620.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Daniel H. <dh...@gm...> - 2011年11月01日 13:06:15
One quick way of doing this is to use numpy:
import numpy
dataset = numpy.genfromtxt(fname='yourfilename',skip_header=1)
http://docs.scipy.org/doc/numpy/reference/generated/numpy.genfromtxt.html
On Tue, Nov 1, 2011 at 8:50 AM, yelena <som...@in...> wrote:
>
> Hi!
> I'm new at Matplotlib, so I need a little help.
> I was trying to load data from txt files with no luck.
> I have 2 collumns in txt files and I need to plot a XY graph. Should I
> modify txt file to other format?
>
> Can someone give me a simple example for doing this?
>
> In txt file could be such information:
> Meters  Seconds
> 1      4
> 2      8
> 3      12
> 4      16
> 5      20
>
> Thanks in advance!
>
> --
> View this message in context: http://old.nabble.com/Loading-txt-files-tp32758393p32758393.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> RSA&reg; Conference 2012
> Save &#36;700 by Nov 18
> Register now
> http://p.sf.net/sfu/rsa-sfdev2dev1
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
-- 
Daniel Hyams
dh...@gm...
From: yelena <som...@in...> - 2011年11月01日 12:51:08
Hi!
I'm new at Matplotlib, so I need a little help.
I was trying to load data from txt files with no luck.
I have 2 collumns in txt files and I need to plot a XY graph. Should I
modify txt file to other format?
Can someone give me a simple example for doing this?
In txt file could be such information:
Meters Seconds
1 4
2 8
3 12
4 16
5 20
Thanks in advance!
-- 
View this message in context: http://old.nabble.com/Loading-txt-files-tp32758393p32758393.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
8 messages has been excluded from this view by a project administrator.

Showing results of 339

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