SourceForge logo
SourceForge logo
Menu

matplotlib-checkins — Commit notification. DO NOT POST to this list, just subscribe to it.

You can subscribe to this list here.

2007 Jan
Feb
Mar
Apr
May
Jun
Jul
(115)
Aug
(120)
Sep
(137)
Oct
(170)
Nov
(461)
Dec
(263)
2008 Jan
(120)
Feb
(74)
Mar
(35)
Apr
(74)
May
(245)
Jun
(356)
Jul
(240)
Aug
(115)
Sep
(78)
Oct
(225)
Nov
(98)
Dec
(271)
2009 Jan
(132)
Feb
(84)
Mar
(74)
Apr
(56)
May
(90)
Jun
(79)
Jul
(83)
Aug
(296)
Sep
(214)
Oct
(76)
Nov
(82)
Dec
(66)
2010 Jan
(46)
Feb
(58)
Mar
(51)
Apr
(77)
May
(58)
Jun
(126)
Jul
(128)
Aug
(64)
Sep
(50)
Oct
(44)
Nov
(48)
Dec
(54)
2011 Jan
(68)
Feb
(52)
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
(1)
2018 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S





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






Showing 1 results of 1

From: <ef...@us...> - 2009年05月03日 00:09:14
Revision: 7078
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7078&view=rev
Author: efiring
Date: 2009年05月03日 00:09:06 +0000 (2009年5月03日)
Log Message:
-----------
Added options to plotfile
Modified Paths:
--------------
 trunk/matplotlib/CHANGELOG
 trunk/matplotlib/examples/pylab_examples/plotfile_demo.py
 trunk/matplotlib/lib/matplotlib/pyplot.py
Added Paths:
-----------
 trunk/matplotlib/examples/data/data_x_x2_x3.csv
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG	2009年05月01日 19:04:06 UTC (rev 7077)
+++ trunk/matplotlib/CHANGELOG	2009年05月03日 00:09:06 UTC (rev 7078)
@@ -1,4 +1,7 @@
 ======================================================================
+2009年05月02日 Added options to plotfile based on question from
+ Joseph Smidt and patch by Matthias Michler. - EF
+
 2009年05月01日 Changed add_artist and similar Axes methods to
 return their argument. - EF
 
Added: trunk/matplotlib/examples/data/data_x_x2_x3.csv
===================================================================
--- trunk/matplotlib/examples/data/data_x_x2_x3.csv	 (rev 0)
+++ trunk/matplotlib/examples/data/data_x_x2_x3.csv	2009年05月03日 00:09:06 UTC (rev 7078)
@@ -0,0 +1,11 @@
+ 0 0 0
+ 1 1 1
+ 2 4 8
+ 3 9 27
+ 4 16 64
+ 5 25 125
+ 6 36 216
+ 7 49 343
+ 8 64 512
+ 9 81 729
+10 100 1000
Modified: trunk/matplotlib/examples/pylab_examples/plotfile_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/plotfile_demo.py	2009年05月01日 19:04:06 UTC (rev 7077)
+++ trunk/matplotlib/examples/pylab_examples/plotfile_demo.py	2009年05月03日 00:09:06 UTC (rev 7078)
@@ -1,6 +1,7 @@
-from pylab import plotfile, show
+from pylab import plotfile, show, gca
 
 fname = '../data/msft.csv'
+fname2 = '../data/data_x_x2_x3.csv'
 
 # test 1; use ints
 plotfile(fname, (0,5,6))
@@ -14,7 +15,20 @@
 # test 4; use semilogy for volume
 plotfile(fname, (0,5,6), plotfuncs={5:'semilogy'})
 
-# test 5; use bar for volume
+#test 5; single subplot
+plotfile(fname, ('date', 'open', 'high', 'low', 'close'), subplots=False)
+
+# test 6; labeling, if no names in csv-file
+plotfile(fname2, cols=(0,1,2), delimiter=' ',
+ names=['$x$', '$f(x)=x^2$', '$f(x)=x^3$'])
+
+# test 7; more than one file per figure--illustrated here with a single file
+plotfile(fname2, cols=(0, 1), delimiter=' ')
+plotfile(fname2, cols=(0, 2), newfig=False, delimiter=' ') # use current figure
+gca().set_xlabel(r'$x$')
+gca().set_ylabel(r'$f(x) = x^2, x^3$')
+
+# test 8; use bar for volume
 plotfile(fname, (0,5,6), plotfuncs={5:'bar'})
 
 show()
Modified: trunk/matplotlib/lib/matplotlib/pyplot.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pyplot.py	2009年05月01日 19:04:06 UTC (rev 7077)
+++ trunk/matplotlib/lib/matplotlib/pyplot.py	2009年05月03日 00:09:06 UTC (rev 7078)
@@ -1448,7 +1448,8 @@
 return ret
 
 def plotfile(fname, cols=(0,), plotfuncs=None,
- comments='#', skiprows=0, checkrows=5, delimiter=',',
+ comments='#', skiprows=0, checkrows=5, delimiter=',', names=None,
+ subplots=True, newfig=True,
 **kwargs):
 """
 Plot the data in *fname*
@@ -1464,18 +1465,28 @@
 
 - If len(*cols*) > 1, the first element will be an identifier for
 data for the *x* axis and the remaining elements will be the
- column indexes for multiple subplots
+ column indexes for multiple subplots if *subplots* is *True*
+ (the default), or for lines in a single subplot if *subplots*
+ is *False*.
 
 *plotfuncs*, if not *None*, is a dictionary mapping identifier to
 an :class:`~matplotlib.axes.Axes` plotting function as a string.
 Default is 'plot', other choices are 'semilogy', 'fill', 'bar',
 etc. You must use the same type of identifier in the *cols*
 vector as you use in the *plotfuncs* dictionary, eg., integer
- column numbers in both or column names in both.
+ column numbers in both or column names in both. If *subplots*
+ is *False*, then including any function such as 'semilogy'
+ that changes the axis scaling will set the scaling for all
+ columns.
 
- *comments*, *skiprows*, *checkrows*, and *delimiter* are all passed on to
- :func:`matplotlib.pylab.csv2rec` to load the data into a record array.
+ *comments*, *skiprows*, *checkrows*, *delimiter*, and *names*
+ are all passed on to :func:`matplotlib.pylab.csv2rec` to
+ load the data into a record array.
 
+ If *newfig* is *True*, the plot always will be made in a new figure;
+ if *False*, it will be made in the current figure if one exists,
+ else in a new figure.
+
 kwargs are passed on to plotting functions.
 
 Example usage::
@@ -1484,17 +1495,26 @@
 plotfile(fname, (0,1,3))
 
 # plot using column names; specify an alternate plot type for volume
- plotfile(fname, ('date', 'volume', 'adj_close'), plotfuncs={'volume': 'semilogy'})
+ plotfile(fname, ('date', 'volume', 'adj_close'),
+ plotfuncs={'volume': 'semilogy'})
+
+ Note: plotfile is intended as a convenience for quickly plotting
+ data from flat files; it is not intended as an alternative
+ interface to general plotting with pyplot or matplotlib.
 """
 
- fig = figure()
+ if newfig:
+ fig = figure()
+ else:
+ fig = gcf()
+
 if len(cols)<1:
 raise ValueError('must have at least one column of data')
 
 if plotfuncs is None:
 plotfuncs = dict()
- r = mlab.csv2rec(fname, comments=comments,
- skiprows=skiprows, checkrows=checkrows, delimiter=delimiter)
+ r = mlab.csv2rec(fname, comments=comments, skiprows=skiprows,
+ checkrows=checkrows, delimiter=delimiter, names=names)
 
 def getname_val(identifier):
 'return the name and column data for identifier'
@@ -1507,36 +1527,44 @@
 raise TypeError('identifier must be a string or integer')
 
 xname, x = getname_val(cols[0])
+ ynamelist = []
 
 if len(cols)==1:
 ax1 = fig.add_subplot(1,1,1)
 funcname = plotfuncs.get(cols[0], 'plot')
 func = getattr(ax1, funcname)
 func(x, **kwargs)
- ax1.set_xlabel(xname)
+ ax1.set_ylabel(xname)
 else:
 N = len(cols)
 for i in range(1,N):
- if i==1:
- ax = ax1 = fig.add_subplot(N-1,1,i)
- ax.grid(True)
- else:
- ax = fig.add_subplot(N-1,1,i, sharex=ax1)
- ax.grid(True)
+ if subplots:
+ if i==1:
+ ax = ax1 = fig.add_subplot(N-1,1,i)
+ else:
+ ax = fig.add_subplot(N-1,1,i, sharex=ax1)
+ elif i==1:
+ ax = fig.add_subplot(1,1,1)
 
+ ax.grid(True)
 
+
 yname, y = getname_val(cols[i])
+ ynamelist.append(yname)
 
 funcname = plotfuncs.get(cols[i], 'plot')
 func = getattr(ax, funcname)
 
 func(x, y, **kwargs)
- ax.set_ylabel(yname)
+ if subplots:
+ ax.set_ylabel(yname)
 if ax.is_last_row():
 ax.set_xlabel(xname)
 else:
 ax.set_xlabel('')
 
+ if not subplots:
+ ax.legend(ynamelist, loc='best')
 
 if xname=='date':
 fig.autofmt_xdate()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

Showing 1 results of 1

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