Skip to content

Commit 3eec157

Browse files
committed
added delimiter to pylab save
svn path=/trunk/matplotlib/; revision=1966
1 parent 787a38f commit 3eec157

File tree

10 files changed

+101
-31
lines changed

10 files changed

+101
-31
lines changed

.cvsignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ dist
33
docs
44
*.pyc
55
.project
6-
matplotlibrc

CHANGELOG

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1+
2+
2006-01-18 Added comma delimiter for pylab save
3+
4+
2006-01-12 Added Ryan's legend patch - JDH
5+
6+
17
2006-1-12 Fixed numpy / numeric to use .dtype.char to keep in SYNC with numpy SVN
28

9+
10+
===============================================================
11+
2006-1-11 0.86.1 released
12+
313
2006-1-11 Fixed setup.py for win32 build and added rc template to the MANIFEST.in
414

515
2006-1-10 Added xpdf distiller option. matplotlibrc ps.usedistiller can now be

TODO

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,4 +737,6 @@ ZeroDivisionError: SeparableTransformation::eval_scalars yin interval is zero; c
737737

738738
-- handle lineprops.glade install file
739739

740-
-- support zoom to rect in x or y only
740+
-- support zoom to rect in x or y only
741+
742+
-- add Ryan's patch

examples/simple_plot.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/usr/bin/env python
2-
2+
"""
3+
Example: simple line plot.
4+
Show how to make and save a simple line plot with labels, title and grid
5+
"""
36
from pylab import *
47

58
t = arange(0.0, 1.0+0.01, 0.01)

lib/matplotlib/__init__.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,20 @@ def __call__(self, s):
811811

812812
'polaraxes.grid' : [True, validate_bool], # display polar grid or not
813813

814+
#legend properties
815+
'legend.isaxes' : [True,validate_bool],
816+
'legend.numpoints' : [ 4,validate_int], # the number of points in the legend line
817+
'legend.fontsize' : ["small",validate_fontsize],
818+
'legend.pad' : [ 0.2, validate_float], # the fractional whitespace inside the legend border
819+
'legend.markerscale' : [ 0.6, validate_float], # the relative size of legend markers vs. original
820+
# the following dimensions are in axes coords
821+
'legend.labelsep' : [ 0.005, validate_float], # the vertical space between the legend entries
822+
'legend.handlelen' : [ 0.05, validate_float], # the length of the legend lines
823+
'legend.handletextsep' : [ 0.02, validate_float], # the space between the legend line and legend text
824+
'legend.axespad' : [ 0.02, validate_float], # the border between the axes and legend edge
825+
'legend.shadow' : [ False, validate_bool ],
826+
827+
814828
# tick properties
815829
'xtick.major.size' : [5, validate_float], # major xtick size in points
816830
'xtick.minor.size' : [2, validate_float], # minor xtick size in points
@@ -1179,3 +1193,30 @@ def tk_window_focus():
11791193
verbose.report('interactive is %s'%rcParams['interactive'])
11801194
verbose.report('platform is %s'%sys.platform)
11811195
verbose.report('loaded modules: %s'%sys.modules.keys(), 'debug')
1196+
1197+
class ExampleInfo:
1198+
pass
1199+
1200+
class ExampleManager:
1201+
baseurl = 'http://matplotlib.sf.net'
1202+
urls = ['%s/%s'%(baseurl, subdir) for subdir in
1203+
( 'examples', 'examples/widgets')]
1204+
1205+
def get_examples(self):
1206+
import urllib, re
1207+
rgx = re.compile('.*<A HREF="([^.]+\.py)">.*')
1208+
examples = []
1209+
for url in urls:
1210+
lines = urllib.urlopen(url).readlines()
1211+
for line in lines:
1212+
m = rgx.match(line)
1213+
if m is not None:
1214+
examples.append('%s/%s'%(url, m.group(1)))
1215+
return examples
1216+
1217+
def get_info(self, s):
1218+
"""
1219+
return an ExampleInfo instance from s, the string content of
1220+
an example
1221+
"""
1222+
pass

lib/matplotlib/legend.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from numerix import array, ones, Float
2626

2727

28-
from matplotlib import verbose
28+
from matplotlib import verbose, rcParams
2929
from artist import Artist
3030
from cbook import enumerate, is_string_like, iterable, silent_list
3131
from font_manager import FontProperties
@@ -110,18 +110,18 @@ class Legend(Artist):
110110

111111

112112
def __init__(self, parent, handles, labels, loc,
113-
isaxes=True,
114-
numpoints = 4, # the number of points in the legend line
115-
prop = FontProperties(size='smaller'),
116-
pad = 0.2, # the fractional whitespace inside the legend border
117-
markerscale = 0.6, # the relative size of legend markers vs. original
113+
isaxes= None,
114+
numpoints = None, # the number of points in the legend line
115+
prop = None,
116+
pad = None, # the fractional whitespace inside the legend border
117+
markerscale = None, # the relative size of legend markers vs. original
118118
# the following dimensions are in axes coords
119-
labelsep = 0.005, # the vertical space between the legend entries
120-
handlelen = 0.05, # the length of the legend lines
121-
handletextsep = 0.02, # the space between the legend line and legend text
122-
axespad = 0.02, # the border between the axes and legend edge
119+
labelsep = None, # the vertical space between the legend entries
120+
handlelen = None, # the length of the legend lines
121+
handletextsep = None, # the space between the legend line and legend text
122+
axespad = None, # the border between the axes and legend edge
123123

124-
shadow=False,
124+
shadow= None,
125125
):
126126
"""
127127
parent # the artist that contains the legend
@@ -146,19 +146,19 @@ def __init__(self, parent, handles, labels, loc,
146146
warnings.warn('Unrecognized location %s. Falling back on upper right; valid locations are\n%s\t' %(loc, '\n\t'.join(self.codes.keys())))
147147
if is_string_like(loc): loc = self.codes.get(loc, 1)
148148

149-
self.numpoints = numpoints
150-
self.prop = prop
151-
self.fontsize = prop.get_size_in_points()
152-
self.pad = pad
153-
self.markerscale = markerscale
154-
self.labelsep = labelsep
155-
self.handlelen = handlelen
156-
self.handletextsep = handletextsep
157-
self.axespad = axespad
158-
self.shadow = shadow
159-
160-
self.isaxes = isaxes
161-
if isaxes: # parent is an Axes
149+
proplist=[numpoints, pad, markerscale, labelsep, handlelen, handletextsep, axespad, shadow, isaxes]
150+
propnames=['numpoints', 'pad', 'markerscale', 'labelsep', 'handlelen', 'handletextsep', 'axespad', 'shadow', 'isaxes']
151+
for name, value in zip(propnames,proplist):
152+
if value is None:
153+
value=rcParams["legend."+name]
154+
setattr(self,name,value)
155+
if prop is None:
156+
self.prop=FontProperties(size=rcParams["legend.fontsize"])
157+
else:
158+
self.prop=prop
159+
self.fontsize = self.prop.get_size_in_points()
160+
161+
if self.isaxes: # parent is an Axes
162162
self.set_figure(parent.figure)
163163
else: # parent is a Figure
164164
self.set_figure(parent)

lib/matplotlib/numerix/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
numerix imports either Numeric or numarray based on various selectors.
33
4-
0. If the value "--numarray" or "--Numeric" is specified on the
4+
0. If the value "--numpy","--numarray" or "--Numeric" is specified on the
55
command line, then numerix imports the specified
66
array package.
77

lib/matplotlib/pylab.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ def rcdefaults():
10251025
if matplotlib.rcdefaults.__doc__ is not None:
10261026
rcdefaults.__doc__ = _shift_string(matplotlib.rcdefaults.__doc__)
10271027

1028-
def save(fname, X, fmt='%.18e'):
1028+
def save(fname, X, fmt='%.18e',delimiter=' '):
10291029
"""
10301030
Save the data in X to file fname using fmt string to convert the
10311031
data to strings
@@ -1041,6 +1041,8 @@ def save(fname, X, fmt='%.18e'):
10411041
save('test2.out', x) # x is 1D
10421042
save('test3.out', x, fmt='%1.4e') # use exponential notation
10431043
1044+
delimiter is used to separate the fields, eg delimiter ',' for
1045+
comma-separated values
10441046
"""
10451047

10461048
if is_string_like(fname):
@@ -1061,7 +1063,7 @@ def save(fname, X, fmt='%.18e'):
10611063
origShape = X.shape
10621064
X.shape = len(X), 1
10631065
for row in X:
1064-
fh.write(' '.join([fmt%val for val in row]) + '\n')
1066+
fh.write(delimiter.join([fmt%val for val in row]) + '\n')
10651067

10661068
if origShape is not None:
10671069
X.shape = origShape

matplotlibrc.template

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,19 @@ grid.color : black # grid color
165165
grid.linestyle : : # dotted
166166
grid.linewidth : 0.5 # in points
167167

168+
### Legend
169+
legend.isaxes : True
170+
legend.numpoints : 4 # the number of points in the legend line
171+
legend.fontsize : 14
172+
legend.pad : 0.2 # the fractional whitespace inside the legend border
173+
legend.markerscale : 1.0 # the relative size of legend markers vs. original
174+
# the following dimensions are in axes coords
175+
legend.labelsep : 0.010 # the vertical space between the legend entries
176+
legend.handlelen : 0.05 # the length of the legend lines
177+
legend.handletextsep : 0.02 # the space between the legend line and legend text
178+
legend.axespad : 0.02 # the border between the axes and legend edge
179+
legend.shadow : False
180+
168181
### FIGURE
169182
# See http://matplotlib.sourceforge.net/matplotlib.figure.html#Figure
170183
figure.figsize : 8, 6 # figure size in inches

src/_image.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ _image_module::frombuffer(const Py::Tuple& args) {
12781278
imo->rbufIn->attach(buffer, imo->colsIn, imo->rowsIn, imo->colsIn*imo->BPP);
12791279
}
12801280

1281-
return Py::Object();
1281+
return Py::asObject(imo);
12821282
}
12831283

12841284

0 commit comments

Comments
 (0)