Skip to content

Commit 2cdf863

Browse files
committed
draw markers to backend
svn path=/trunk/matplotlib/; revision=938
1 parent eb36353 commit 2cdf863

File tree

11 files changed

+664
-132
lines changed

11 files changed

+664
-132
lines changed

API_CHANGES

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ API CHANGES in matplotlib-0.72
2525

2626
subs=none now does autosubbing in the tick locator.
2727

28+
removed BBoxTransformation
29+
2830
API CHANGES in matplotlib-0.71
2931

3032
Significant numerix namespace changes, introduced to resolve

CHANGELOG

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
New entries should be added at the top
22

3+
2005-02-07 Added newstyle path drawing for markers - only implemented
4+
in agg currently - JDH
5+
36
2005-02-05 Some superscript text optimizations for ticking log plots
47

58
2005-02-05 Added some default key press events to pylab figures: 'g'

TODO

+4-2
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ square). All displayed area is white.
671671
- measuring ruler? (see gnuplot's 'r' hotkey in X11).
672672

673673
- button to add text labels easily anywhere on the plot. A few drawing
674-
buttons as well for simple things? Circle/ellipse, box, arrows, etc.
674+
buttons as well for simple things? Circle/ellipse, box, arrows, etc.
675675

676676
- toggle log/linear shows strange accumulation of ticks on y axis
677677

@@ -682,4 +682,6 @@ buttons as well for simple things? Circle/ellipse, box, arrows, etc.
682682
#set(gca(), xscale='log')
683683
show()
684684

685-
--pyparsing a performance bottleneck for log ticks
685+
-- DONE pyparsing a performance bottleneck for log ticks
686+
687+
-- draw point and draw pixel currently broken for new style markers

examples/backend_driver.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def drive(backend, python='python2.3'):
106106
#backends = ['Agg', 'Cairo', 'GDK', 'PS', 'SVG', 'Template']
107107
#backends = ['Agg', 'PS', 'SVG', 'Template']
108108
#backends = [ 'GTK', 'WX', 'TkAgg']
109-
backends = ['Agg']
109+
backends = ['Agg', 'PS']
110110
python = 'python2.3'
111111
for backend in backends:
112112
print 'testing %s' % backend

examples/simple_plot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
title('About as simple as it gets, folks')
1313
grid(True)
1414
#axis([0,1,-1,1])
15-
#savefig('simple_plot')
15+
savefig('simple_plot')
1616

1717
show()

lib/matplotlib/backends/backend_ps.py

+45
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,51 @@ def draw_line(self, gc, x0, y0, x1, y1):
281281
ps = '%1.3f %1.3f m %1.3f %1.3f l'%(x0, y0, x1, y1)
282282
self._draw_ps(ps, gc, None, "line")
283283

284+
def _draw_markers(self, gc, path, x, y, transform):
285+
"""
286+
Draw the markers defined by path at each of the positions in x
287+
and y. path coordinates are points, x and y coords will be
288+
transformed by the transform
289+
"""
290+
if debugPS:
291+
self._pswriter.write("% markers\n")
292+
293+
if transform.need_nonlinear():
294+
x,y = transform.nonlinear_only_numerix(x, y)
295+
296+
# the a,b,c,d,tx,ty affine which transforms x and y
297+
vec6 = transform.as_vec6_val()
298+
# this defines a single vertex. We need to define this as ps
299+
# function, properly stroked and filled with linewidth etc,
300+
# and then simply iterate over the x and y and call this
301+
# function at each position. Eg, this is the path that is
302+
# relative to each x and y offset.
303+
ps = []
304+
for p in path:
305+
code = p[0]
306+
if code==MOVETO:
307+
mx, my = p[1:]
308+
ps.append('%1.3f %1.3f m')
309+
elif code==LINETO:
310+
mx, my = p[1:]
311+
ps.append('%1.3f %1.3f l')
312+
elif code==ENDPOLY:
313+
fill = p[1]
314+
if fill: # we can get the fill color here
315+
rgba = p[2:]
316+
317+
vertfunc = 'some magic ps function that draws the marker relative to an x,y point'
318+
# the gc contains the stroke width and color as always
319+
for i in xrange(len(x)):
320+
# for large numbers of markers you may need to chunk the
321+
# output, eg dump the ps in 1000 marker batches
322+
thisx = x[i]
323+
thisy = y[i]
324+
# apply affine transform x and y to define marker center
325+
#draw_marker_here
326+
327+
print 'I did nothing!'
328+
284329
def _draw_lines(self, gc, points):
285330
"""
286331
Draw many lines. 'points' is a list of point coordinates.

0 commit comments

Comments
 (0)