Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6a4d343

Browse files
committed
added daisha patch
svn path=/trunk/matplotlib/; revision=1372
1 parent 698b8d6 commit 6a4d343

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+548
-111
lines changed

API_CHANGES

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
API CHANGES in matplotlib-0.81
22

3+
pylab and artist "set" functions renamed to setp to avoid clash with
4+
python2.4 built-in set. Current version will issue a deprecation
5+
warning which will be removed in future versions
6+
37
imshow interpolation arguments changes for advanced interpolation
48
schemes. See help imshow, particularly the interpolation,
59
filternorm and filterrad kwargs

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
New entries should be added at the top
22

3+
2005-05-26 Added Daisha text with dash patch -- see examples/dashtick.py
4+
35
2005-05-26 Moved backend_latex functionality into backend_ps. If
46
text.usetex=True, the PostScript backend will use LaTeX to
57
generate the .ps or .eps file. Ghostscript is required for

agg23/include/agg_math_stroke.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,8 @@ namespace agg
247247
dx2 = dy1;
248248
dy2 = dx1;
249249
}
250-
double dx = dx1 - dx2;
251-
double dy = dy1 - dy2;
252-
out_vertices.add(coord_type(v0.x - dx, v0.y + dy));
253-
out_vertices.add(coord_type(v0.x + dx, v0.y - dy));
250+
out_vertices.add(coord_type(v0.x - dx1 - dx2, v0.y + dy1 - dy2));
251+
out_vertices.add(coord_type(v0.x + dx1 - dx2, v0.y - dy1 - dy2));
254252
}
255253
else
256254
{

examples/anscombe.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,27 @@ def fit(x):
2626
subplot(221)
2727
plot(x,y1,'ks', xfit, fit(xfit), 'r-', lw=2)
2828
axis([2,20,2,14])
29-
set(gca(), xticklabels=[], yticks=(4,8,12), xticks=(0,10,20))
29+
setp(gca(), xticklabels=[], yticks=(4,8,12), xticks=(0,10,20))
3030
text(3,12, 'I', fontsize=20)
3131

3232
subplot(222)
3333
plot(x,y2,'ks', xfit, fit(xfit), 'r-', lw=2)
3434
axis([2,20,2,14])
35-
set(gca(), xticklabels=[], yticks=(4,8,12), yticklabels=[], xticks=(0,10,20))
35+
setp(gca(), xticklabels=[], yticks=(4,8,12), yticklabels=[], xticks=(0,10,20))
3636
text(3,12, 'II', fontsize=20)
3737

3838
subplot(223)
3939
plot(x,y3,'ks', xfit, fit(xfit), 'r-', lw=2)
4040
axis([2,20,2,14])
4141
text(3,12, 'IIII', fontsize=20)
42-
set(gca(), yticks=(4,8,12), xticks=(0,10,20))
42+
setp(gca(), yticks=(4,8,12), xticks=(0,10,20))
4343

4444
subplot(224)
4545

4646
xfit = array([amin(x4),amax(x4)])
4747
plot(x4,y4,'ks', xfit, fit(xfit), 'r-', lw=2)
4848
axis([2,20,2,14])
49-
set(gca(), yticklabels=[], yticks=(4,8,12), xticks=(0,10,20))
49+
setp(gca(), yticklabels=[], yticks=(4,8,12), xticks=(0,10,20))
5050
text(3,12, 'IV', fontsize=20)
5151

5252
#verify the stats

examples/arctest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ def f(t):
1111

1212

1313
l = plot(t1, f(t1), 'ro')
14-
set(l, 'markersize', 30)
15-
set(l, 'markerfacecolor', 'b')
14+
setp(l, 'markersize', 30)
15+
setp(l, 'markerfacecolor', 'b')
1616
#savefig('arctest', dpi=150)
1717
show()
1818

examples/axes_demo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
a = axes([.65, .6, .2, .2], axisbg='y')
2121
n, bins, patches = hist(s, 400, normed=1)
2222
title('Probability')
23-
set(a, xticks=[], yticks=[])
23+
setp(a, xticks=[], yticks=[])
2424

2525
# this is another inset axes over the main axes
2626
a = axes([0.2, 0.6, .2, .2], axisbg='y')
2727
plot(t[:len(r)], r)
2828
title('Impulse response')
29-
set(a, xlim=(0,.2), xticks=[], yticks=[])
29+
setp(a, xlim=(0,.2), xticks=[], yticks=[])
3030

3131
#savefig('../figures/axes_demo.eps')
3232
#savefig('../figures/axes_demo.png')

examples/axes_props.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
xticklabels = get(gca(), 'xticklabels')
1919
yticklabels = get(gca(), 'yticklabels')
2020

21-
set(xticklines, 'linewidth', 3)
22-
set(yticklines, 'linewidth', 3)
23-
set(xgridlines, 'linestyle', '-')
24-
set(ygridlines, 'linestyle', '-')
25-
set(yticklabels, 'color', 'r', fontsize='medium')
26-
set(xticklabels, 'color', 'r', fontsize='medium')
21+
setp(xticklines, 'linewidth', 3)
22+
setp(yticklines, 'linewidth', 3)
23+
setp(xgridlines, 'linestyle', '-')
24+
setp(ygridlines, 'linestyle', '-')
25+
setp(yticklabels, 'color', 'r', fontsize='medium')
26+
setp(xticklabels, 'color', 'r', fontsize='medium')
2727

2828
# keyword args are legal too
2929
#set(xticklabels, color='r', fontsize='medium')

examples/color_by_yvalue.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# use masked arrays to plot a line with different colors by y-value
2+
import matplotlib.numerix.ma as ma
3+
from matplotlib.numerix import logical_or
4+
from pylab import plot, show, arange, sin, pi
5+
6+
t = arange(0.0, 2.0, 0.01)
7+
s = sin(2*pi*t)
8+
9+
upper = 0.77
10+
lower = -0.77
11+
12+
13+
supper = ma.masked_where(s < upper, s)
14+
slower = ma.masked_where(s > lower, s)
15+
smiddle = ma.masked_where(logical_or(s<lower, s>upper), s)
16+
17+
plot(t, slower, 'r', t, smiddle, 'b', t, supper, 'g')
18+
show()

examples/contour_image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
contour(Z, levels, hold='on', colors = 'k', origin='image', extent=extent)
8888
axis(v)
8989
ylim = get(gca(), 'ylim')
90-
set(gca(), ylim=ylim[::-1])
90+
setp(gca(), ylim=ylim[::-1])
9191
title("Image, origin from rc, reversed y-axis")
9292

9393
#savefig('contour_image')

examples/dashtick.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Matplotlib xaxis label tweak
2+
3+
import sys
4+
import matplotlib
5+
from matplotlib import pylab, ticker
6+
7+
ROTATION=75
8+
DASHROTATION=75
9+
DASHBASE=10
10+
DASHLEN=35
11+
DASHSTAGGER=3
12+
FONTSIZE=6
13+
14+
def dashlen(step):
15+
return DASHBASE+(DASHLEN*(step%DASHSTAGGER))
16+
17+
def test_dashticklabel():
18+
pylab.clf()
19+
x = [0.0, 1.0, 1.1, 5.0, 5.1, 6.0]
20+
y = [1, 3, 2, 5, 1, 2]
21+
labels = ['foo', 'bar', 'baz', 'alpha', 'beta', 'gamma']
22+
locator = ticker.FixedLocator(x)
23+
formatter = ticker.FixedFormatter(labels)
24+
axis = pylab.axes([0.3, 0.3, 0.4, 0.4])
25+
axis.xaxis.set_major_locator(locator)
26+
axis.xaxis.set_major_formatter(formatter)
27+
axis.yaxis.set_major_locator(locator)
28+
axis.yaxis.set_major_formatter(formatter)
29+
for tick in axis.xaxis.get_major_ticks():
30+
tick.label2On = True
31+
for tick in axis.yaxis.get_major_ticks():
32+
tick.label2On = True
33+
step = 0
34+
for label in axis.get_xticklabels():
35+
pylab.set(label,
36+
rotation=ROTATION,
37+
dashlength=dashlen(step),
38+
dashrotation=DASHROTATION,
39+
fontsize=FONTSIZE,
40+
)
41+
step += 1
42+
step = 0
43+
for label in axis.get_yticklabels():
44+
pylab.set(label,
45+
rotation=90-ROTATION,
46+
dashlength=dashlen(step),
47+
dashrotation=90-DASHROTATION,
48+
fontsize=FONTSIZE,
49+
)
50+
step += 1
51+
pylab.xlabel('X Label')
52+
pylab.ylabel('Y Label')
53+
pylab.plot(x, y)
54+
axis.set_xlim((0.0, 6.0))
55+
axis.set_ylim((0.0, 6.0))
56+
pylab.savefig('dashticklabel')
57+
pylab.show()
58+
59+
if __name__ == '__main__':
60+
test_dashticklabel()

examples/date_demo2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#ax.xaxis.grid(True, 'minor')
3838

3939
labels = ax.get_xticklabels()
40-
set(labels, rotation=45)
40+
setp(labels, rotation=45)
4141

4242
grid(True)
4343
savefig('date_demo2')

examples/date_demo_rrule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
ax.xaxis.set_major_locator(loc)
2828
ax.xaxis.set_major_formatter(formatter)
2929
labels = ax.get_xticklabels()
30-
set(labels, rotation=30, fontsize=10)
30+
setp(labels, rotation=30, fontsize=10)
3131

3232

3333
show()

examples/fill_between.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
y = concatenate( (y1,y2[::-1]) )
1212

1313
p = fill(x, y, facecolor='g')
14-
set(p, alpha=0.5)
14+
setp(p, alpha=0.5)
1515
show()
1616

examples/finance_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#plot_day_summary(ax, quotes, ticksize=3)
3131
candlestick(ax, quotes, width=0.6)
3232

33-
set( gca().get_xticklabels(), rotation=45, horizontalalignment='right')
33+
setp( gca().get_xticklabels(), rotation=45, horizontalalignment='right')
3434

3535
show()
3636

examples/ganged_plots.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
# off xtick labels on all but the lower plot
2121
ax1 = axes([0.1, 0.1, 0.8, 0.25]) # lower
2222
ax2 = axes([0.1, 0.35, 0.8, 0.25], sharex=ax1) # middle
23-
set(ax2.get_xticklabels(), visible=False)
23+
setp(ax2.get_xticklabels(), visible=False)
2424
ax3 = axes([0.1, 0.6, 0.8, 0.25], sharex=ax1) # upper
25-
set(ax3.get_xticklabels(), visible=False)
25+
setp(ax3.get_xticklabels(), visible=False)
2626

2727

2828
ax1.plot(t,s1)

examples/gdtest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def f(t):
1616
if 1:
1717
subplot(211)
1818
l = plot(t1, f(t1), 'k-^')
19-
set(l, 'markerfacecolor', 'r')
19+
setp(l, 'markerfacecolor', 'r')
2020
xlim(0,5)
2121
#set(l, 'markeredgecolor', 'r')
2222
title('A tale of 2 subplots', fontsize=12)

examples/histogram_demo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66

77
# the histogram of the data
88
n, bins, patches = hist(x, 50, normed=1)
9-
set(patches, 'facecolor', 'g', 'alpha', 0.75)
9+
setp(patches, 'facecolor', 'g', 'alpha', 0.75)
1010

1111
# add a 'best fit' line
1212
y = normpdf( bins, mu, sigma)
1313
l = plot(bins, y, 'r--')
14-
set(l, 'linewidth', 1)
14+
setp(l, 'linewidth', 1)
1515

1616
xlabel('Smarts')
1717
ylabel('Probability')

examples/image_demo2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
bar(arange(w), x)
2929
xlim(0,h-1)
3030
ylabel('density')
31-
set(gca(), 'xticklabels', [])
31+
setp(gca(), 'xticklabels', [])
3232

3333
#savefig('image_demo2')
3434
show()

examples/legend_demo.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
xlabel('Model complexity --->')
2424
ylabel('Message length --->')
2525
title('Minimum Message Length')
26-
set(gca(), 'yticklabels', [])
27-
set(gca(), 'xticklabels', [])
26+
setp(gca(), 'yticklabels', [])
27+
setp(gca(), 'xticklabels', [])
2828

2929
# set some legend properties. All the code below is optional. The
3030
# defaults are usually sensible but if you need more control, this
@@ -37,8 +37,8 @@
3737
# see text.Text, lines.Line2D, and patches.Rectangle for more info on
3838
# the settable properties of lines, text, and rectangles
3939
frame.set_facecolor(0.80) # set the frame face color to light gray
40-
set(ltext, fontsize='small') # the legend text fontsize
41-
set(llines, linewidth=1.5) # the legend linewidth
40+
setp(ltext, fontsize='small') # the legend text fontsize
41+
setp(llines, linewidth=1.5) # the legend linewidth
4242
#leg.draw_frame(False) # don't draw the legend frame
4343
#savefig('legend_demo')
4444
show()

examples/line_styles.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
plot(t,s, style + color)
1919
# turn off the ticklabels if not first row or first col
2020
if not gca().is_first_col():
21-
set(gca(), 'yticklabels', [])
21+
setp(gca(), 'yticklabels', [])
2222
if not gca().is_last_row():
23-
set(gca(), 'xticklabels', [])
23+
setp(gca(), 'xticklabels', [])
2424

2525
#savefig('line_styles', dpi=300)
2626
show()

examples/logo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
transform = ax.transAxes,
1919
)
2020
axis([1, 1.72,-60, 10])
21-
set(gca(), 'xticklabels', [])
22-
set(gca(), 'yticklabels', [])
21+
setp(gca(), 'xticklabels', [])
22+
setp(gca(), 'yticklabels', [])
2323
#savefig('logo2.png', dpi=300)
2424
show()

examples/masked_demo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
ym2 = M.masked_where(y2 < -0.5, y2)
1818

1919
lines = plot(x, y, 'r', x, ym1, 'g', x, ym2, 'bo')
20-
set(lines[0], linewidth = 4)
21-
set(lines[1], linewidth = 2)
22-
set(lines[2], markersize = 10)
20+
setp(lines[0], linewidth = 4)
21+
setp(lines[1], linewidth = 2)
22+
setp(lines[2], markersize = 10)
2323

2424
legend( ('No mask', 'Masked if > 0.5', 'Masked if < -0.5') ,
2525
loc = 'upper right')

examples/matplotlib_icon.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
axis([-.2, 2.2, -1.2, 1.2])
1717

1818
grid(True)
19-
set(gca(), xticklabels=[], yticklabels=[])
19+
setp(gca(), xticklabels=[], yticklabels=[])
2020
#savefig('../images/matplotlib.svg', facecolor=0.75)
2121

examples/mri_with_eeg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
xlim(0,10)
8181
xticks(arange(10))
8282

83-
set(gca(), 'yticklabels', ['PG3', 'PG5', 'PG7', 'PG9'])
83+
setp(gca(), 'yticklabels', ['PG3', 'PG5', 'PG7', 'PG9'])
8484

8585
# set the yticks to use axes coords on the y axis
8686
ax.set_yticks(ticklocs)

examples/multiple_figs_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
figure(1)
2020
subplot(211)
2121
plot(t,s2, 'gs')
22-
set(gca(), 'xticklabels', [])
22+
setp(gca(), 'xticklabels', [])
2323

2424
#figure(1)
2525
#savefig('fig1')

examples/pstest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ def f(t):
1515
figure(1)
1616
subplot(211)
1717
l = plot(t1, f(t1), 'k^')
18-
set(l, 'markerfacecolor', 'k')
19-
set(l, 'markeredgecolor', 'r')
18+
setp(l, 'markerfacecolor', 'k')
19+
setp(l, 'markeredgecolor', 'r')
2020
#set(l, 'linewidth', 3)
2121
#set(l, 'markersize', 12)
2222
title('A tale of 2 subplots', fontsize=14, fontname='Courier')

examples/pythonic_matplotlib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
3434
The syntax of set is
3535
36-
set(object or sequence, somestring, attribute)
36+
setp(object or sequence, somestring, attribute)
3737
3838
if called with an object, set calls
3939

examples/scatter_demo2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
volume = (15*intc.volume[:-2]/intc.volume[0])**2
1111
close = 0.003*intc.close[:-2]/0.003*intc.open[:-2]
1212
p = scatter(delta1[:-1], delta1[1:], c=close, s=volume)
13-
set(p, 'alpha', 0.75)
13+
setp(p, 'alpha', 0.75)
1414
xlabel(r'$\Delta_i$', size='x-large')
1515
ylabel(r'$\Delta_{i+1}$', size='x-large')
1616
title(r'Volume and percent change')

0 commit comments

Comments
 (0)