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 6 results of 6

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.

Showing 6 results of 6

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