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

Skip to content

Commit 37470b0

Browse files
committed
Remove the "markup" kwarg and rcParam everywhere and replace it with
an automatic detection of math markup. svn path=/trunk/matplotlib/; revision=3757
1 parent fed68f8 commit 37470b0

22 files changed

+58
-85
lines changed

examples/accented_text.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
plot(range(10))
1515

16-
title(r'$\ddot{o}\acute{e}\grave{e}\hat{O}\breve{i}\bar{A}\tilde{n}\vec{q}$', fontsize=20, markup="tex")
16+
title(r'$\ddot{o}\acute{e}\grave{e}\hat{O}\breve{i}\bar{A}\tilde{n}\vec{q}$', fontsize=20)
1717
# shorthand is also supported and curly's are optional
18-
xlabel(r"""$\"o\ddot o \'e\`e\~n\.x\^y$""", fontsize=20, markup="tex")
18+
xlabel(r"""$\"o\ddot o \'e\`e\~n\.x\^y$""", fontsize=20)
1919

2020

2121
show()

examples/arrow_demo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def make_arrow_plot(data, size=4, display='length', shape='right', \
5252
min_text_size = size
5353
label_text_size = size*2.5
5454
text_params={'ha':'center', 'va':'center', 'family':'sans-serif',\
55-
'fontweight':'bold', 'markup': 'tex'}
55+
'fontweight':'bold'}
5656
r2 = sqrt(2)
5757

5858
deltas = {\
@@ -211,7 +211,7 @@ def draw_arrow(pair, alpha=alpha, ec=ec, labelcolor=labelcolor):
211211
label = '$%s_{_{\mathrm{%s}}}$' % (orig_label[0], orig_label[1:])
212212

213213
text(x, y, label, size=label_text_size, ha='center', va='center', \
214-
color=labelcolor or fc, markup='tex')
214+
color=labelcolor or fc)
215215

216216
for p in positions.keys():
217217
draw_arrow(p)

examples/dannys_example.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,31 @@
2929
pylab.plot((-delta / 2, -delta / 2 + offset * 2), (height, height + offset), 'k', linewidth = 2)
3030
pylab.plot((delta / 2, delta / 2 - offset * 2), (height, height - offset), 'k', linewidth = 2)
3131
pylab.plot((delta / 2, delta / 2 - offset * 2), (height, height + offset), 'k', linewidth = 2)
32-
pylab.text(-0.06, height - 0.06, r'$\delta$', {'color' : 'k', 'fontsize' : 24}, markup = 'tex')
32+
pylab.text(-0.06, height - 0.06, r'$\delta$', {'color' : 'k', 'fontsize' : 24})
3333

3434
## X-axis label
3535
pylab.xticks((-1, 0, 1), ('-1', '0', '1'), color = 'k', size = 20)
3636

3737
## Left Y-axis labels
3838
pylab.ylabel(r'\bf{phase field} $\phi$', {'color' : 'b',
39-
'fontsize' : 20 }, markup='tex')
39+
'fontsize' : 20 })
4040
pylab.yticks((0, 0.5, 1), ('0', '.5', '1'), color = 'k', size = 20)
4141

4242
## Right Y-axis labels
4343
pylab.text(1.05, 0.5, r"\bf{level set} $\phi$", {'color' : 'g', 'fontsize' : 20},
4444
horizontalalignment = 'left',
4545
verticalalignment = 'center',
4646
rotation = 90,
47-
clip_on = False,
48-
markup = 'tex')
47+
clip_on = False)
4948
pylab.text(1.01, -0.02, "-1", {'color' : 'k', 'fontsize' : 20})
5049
pylab.text(1.01, 0.98, "1", {'color' : 'k', 'fontsize' : 20})
5150
pylab.text(1.01, 0.48, "0", {'color' : 'k', 'fontsize' : 20})
5251

5352
## level set equations
54-
pylab.text(0.1, 0.85, r'$|\nabla\phi| = 1,$ \newline $ \frac{\partial \phi}{\partial t} + U|\nabla \phi| = 0$', {'color' : 'g', 'fontsize' : 20}, markup='tex')
53+
pylab.text(0.1, 0.85, r'$|\nabla\phi| = 1,$ \newline $ \frac{\partial \phi}{\partial t} + U|\nabla \phi| = 0$', {'color' : 'g', 'fontsize' : 20})
5554

5655
## phase field equations
57-
pylab.text(0.2, 0.15, r'$\mathcal{F} = \int f\left( \phi, c \right) dV,$ \newline $ \frac{ \partial \phi } { \partial t } = -M_{ \phi } \frac{ \delta \mathcal{F} } { \delta \phi }$', {'color' : 'b', 'fontsize' : 20}, markup='tex')
56+
pylab.text(0.2, 0.15, r'$\mathcal{F} = \int f\left( \phi, c \right) dV,$ \newline $ \frac{ \partial \phi } { \partial t } = -M_{ \phi } \frac{ \delta \mathcal{F} } { \delta \phi }$', {'color' : 'b', 'fontsize' : 20})
5857

5958
pylab.savefig('pfm-lsm.png')
6059
pylab.show()

examples/histogram_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
xlabel('Smarts')
1717
ylabel('Probability')
18-
title(r'$\mathrm{Histogram\ of\ IQ:}\ \mu=100,\ \sigma=15$', markup='tex')
18+
title(r'$\mathrm{Histogram\ of\ IQ:}\ \mu=100,\ \sigma=15$')
1919
axis([40, 160, 0, 0.03])
2020
grid(True)
2121

examples/histogram_demo_canvasagg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
ax.set_xlabel('Smarts')
3535
ax.set_ylabel('Probability')
36-
ax.set_title(r'$\mathrm{Histogram of IQ: }\mu=100, \sigma=15$', markup='tex')
36+
ax.set_title(r'$\mathrm{Histogram of IQ: }\mu=100, \sigma=15$')
3737

3838
ax.set_xlim( (40, 160))
3939
ax.set_ylim( (0, 0.03))

examples/integral_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def func(x):
2323

2424
text(0.5 * (a + b), 30,
2525
r"$\int_a^b f(x)\mathrm{d}x$", horizontalalignment='center',
26-
fontsize=20, markup='tex')
26+
fontsize=20)
2727

2828
axis([0,10, 0, 180])
2929
figtext(0.9, 0.05, 'x')

examples/legend_auto.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ def fig_6():
5151
def fig_7():
5252
figure(7)
5353
xx = x - (N/2.0)
54-
plot(xx, (xx*xx)-1225, 'bo', label='$y=x^2$', markup='tex')
55-
plot(xx, 25*xx, 'go', label='$y=25x$', markup='tex')
56-
plot(xx, -25*xx, 'mo', label='$y=-25x$', markup='tex')
54+
plot(xx, (xx*xx)-1225, 'bo', label='$y=x^2$')
55+
plot(xx, 25*xx, 'go', label='$y=25x$')
56+
plot(xx, -25*xx, 'mo', label='$y=-25x$')
5757
legend()
5858

5959
def fig_8():

examples/mathtext_demo.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313
x = npy.arange(0.0, 3.0, 0.1)
1414

1515
ax.grid(True)
16-
ax.set_xlabel(r'$\Delta_i^j$', fontsize=20, markup="tex")
17-
ax.set_ylabel(r'$\Delta_{i+1}^j$', fontsize=20, markup="tex")
16+
ax.set_xlabel(r'$\Delta_i^j$', fontsize=20)
17+
ax.set_ylabel(r'$\Delta_{i+1}^j$', fontsize=20)
1818
tex = r'$\mathcal{R}\prod_{i=\alpha_{i+1}}^\infty a_i\sin(2 \pi f x_i)$'
1919

20-
ax.text(1, 1.6, tex, fontsize=20, va='bottom', markup="tex")
20+
ax.text(1, 1.6, tex, fontsize=20, va='bottom')
21+
22+
ax.legend(("Foo", "Testing $x^2$"))
2123

2224
#title(r'$\Delta_i^j \hspace{0.4} \rm{versus} \hspace{0.4} \Delta_{i+1}^j$', fontsize=20)
2325
fig.savefig('mathtext_demo')

examples/mathtext_examples.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22

33
import os, sys, re
44

5+
import gc
6+
57
stests = [
68
r'Kerning: AVA $AVA$',
9+
r'\$100.00 $\alpha$',
10+
r'$\frac{\$100.00}{y}$',
711
r'$x y$',
812
r'$x+y\ x=y\ x<y\ x:y\ x,y\ x@y$',
913
r'$100\%y\ x*y\ x/y x\$y$',
1014
r'$x\leftarrow y\ x\forall y\ x-y$',
1115
r'$x \sf x \bf x {\cal X} \rm x$',
12-
r'$x\ x\,x\;x\quad x\qquad x\!x\hspace{0.5}y$',
16+
r'$x\ x\,x\;x\quad x\qquad x\!x\hspace{ 0.5 }y$',
1317
r'$\{ \rm braces \}$',
1418
r'$\left[\left\lfloor\frac{5}{\frac{\left(3\right)}{4}} y\right)\right]$',
1519
r'$\left(x\right)$',
@@ -59,10 +63,10 @@ def doall():
5963
yticks(arange(len(tests)) * -1)
6064
for i, s in enumerate(tests):
6165
print "%02d: %s" % (i, s)
62-
text(0.1, -i, s, fontsize=20, markup="tex")
66+
text(0.1, -i, s, fontsize=20)
6367

6468
savefig('mathtext_example')
65-
figure()
69+
close('all')
6670

6771
if '--latex' in sys.argv:
6872
fd = open("mathtext_examples.ltx", "w")

examples/quiver_demo.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
figure()
1919
Q = quiver( U, V)
2020
qk = quiverkey(Q, 0.5, 0.92, 2, r'$2 \frac{m}{s}$', labelpos='W',
21-
fontproperties={'weight': 'bold'},
22-
markup="tex")
21+
fontproperties={'weight': 'bold'})
2322
l,r,b,t = axis()
2423
dx, dy = r-l, t-b
2524
axis([l-0.05*dx, r+0.05*dx, b-0.05*dy, t+0.05*dy])
@@ -32,16 +31,15 @@
3231
qk = quiverkey(Q, 0.9, 0.95, 2, r'$2 \frac{m}{s}$',
3332
labelpos='E',
3433
coordinates='figure',
35-
fontproperties={'weight': 'bold'},
36-
markup="tex")
34+
fontproperties={'weight': 'bold'})
3735
axis([-1, 7, -1, 7])
3836
title('scales with plot width, not view')
3937

4038
#3
4139
figure()
4240
Q = quiver( X[::3, ::3], Y[::3, ::3], U[::3, ::3], V[::3, ::3],
4341
pivot='mid', color='r', units='inches' )
44-
qk = quiverkey(Q, 0.5, 0.03, 1, r'$1 \frac{m}{s}$', fontproperties={'weight': 'bold'}, markup="tex")
42+
qk = quiverkey(Q, 0.5, 0.03, 1, r'$1 \frac{m}{s}$', fontproperties={'weight': 'bold'})
4543
plot( X[::3, ::3], Y[::3, ::3], 'k.')
4644
axis([-1, 7, -1, 7])
4745
title("pivot='mid'; every third arrow; units='inches'")
@@ -52,8 +50,7 @@
5250
Q = quiver( X, Y, U, V, M, units='x', pivot='tip', width=0.022, scale=1/0.15)
5351
qk = quiverkey(Q, 0.9, 1.05, 1, r'$1 \frac{m}{s}$',
5452
labelpos='E',
55-
fontproperties={'weight': 'bold'},
56-
markup="tex")
53+
fontproperties={'weight': 'bold'})
5754
plot(X, Y, 'k.')
5855
axis([-1, 7, -1, 7])
5956
title("scales with x view; pivot='tip'")
@@ -63,7 +60,7 @@
6360
Q = quiver( X[::3, ::3], Y[::3, ::3], U[::3, ::3], V[::3, ::3],
6461
color='r', units='x',
6562
linewidths=(2,), edgecolors=('k'), headaxislength=5 )
66-
qk = quiverkey(Q, 0.5, 0.03, 1, r'$1 \frac{m}{s}$', fontproperties={'weight': 'bold'}, markup="tex")
63+
qk = quiverkey(Q, 0.5, 0.03, 1, r'$1 \frac{m}{s}$', fontproperties={'weight': 'bold'})
6764
axis([-1, 7, -1, 7])
6865
title("triangular head; scale with x view; black edges")
6966

examples/scatter_demo2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
close = 0.003*intc.close[:-2]/0.003*intc.open[:-2]
1212
p = scatter(delta1[:-1], delta1[1:], c=close, s=volume, alpha=0.75)
1313

14-
xlabel(r'$\Delta_i$', size='x-large', markup='tex')
15-
ylabel(r'$\Delta_{i+1}$', size='x-large', markup='tex')
14+
xlabel(r'$\Delta_i$', size='x-large')
15+
ylabel(r'$\Delta_{i+1}$', size='x-large')
1616
title(r'Volume and percent change')
1717
grid(True)
1818
#savefig('scatter_demo2')

examples/tex_demo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
s = cos(2*2*pi*t)+2
2424
plot(t, s)
2525

26-
xlabel(r'\textbf{time (s)}', markup='tex')
27-
ylabel(r'\textit{voltage (mV)}',fontsize=16, markup='tex')
26+
xlabel(r'\textbf{time (s)}')
27+
ylabel(r'\textit{voltage (mV)}',fontsize=16)
2828
title(r"\TeX\ is Number $\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$!",
29-
fontsize=16, color='r', markup='tex')
29+
fontsize=16, color='r')
3030
grid(True)
3131
savefig('tex_demo')
3232

examples/tex_unicode_demo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
s = cos(2*2*pi*t)+2
1818
plot(t, s)
1919

20-
xlabel(r'\textbf{time (s)}', markup='tex')
20+
xlabel(r'\textbf{time (s)}')
2121
s = unicode(r'\textit{Velocity (°/sec)}','latin-1')
22-
ylabel(unicode(r'\textit{Velocity (°/sec)}','latin-1'),fontsize=16, markup='tex')
22+
ylabel(unicode(r'\textit{Velocity (°/sec)}','latin-1'),fontsize=16)
2323
title(r"\TeX\ is Number $\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$!",
24-
fontsize=16, color='r', markup='tex')
24+
fontsize=16, color='r')
2525
grid(True)
2626
savefig('tex_demo')
2727

examples/unicode_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
text( 0.5, 2.5, unicode('Institut für Festkörperphysik', 'latin-1'), rotation=45)
1010
text( 1, 1.5, u'AVA (check kerning)')
1111

12-
savefig('test.svg')
12+
savefig('test')
1313
show()

lib/matplotlib/config/mplconfig.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ class font(TConfig):
153153
class text(TConfig):
154154
color = T.Trait('black',mplT.ColorHandler())
155155
usetex = T.false
156-
markup = T.Trait('plain', 'plain', 'tex')
157156

158157
class latex(TConfig):
159158
unicode = T.false

lib/matplotlib/config/rcsetup.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,6 @@ def validate_font_properties(s):
203203
parse_fontconfig_pattern(s)
204204
return s
205205

206-
validate_markup = ValidateInStrings(
207-
'markup',
208-
['plain', 'tex'],
209-
ignorecase=True)
210-
211206
validate_verbose = ValidateInStrings('verbose',[
212207
'silent', 'helpful', 'debug', 'debug-annoying',
213208
])
@@ -363,7 +358,6 @@ def __call__(self, s):
363358
'text.fontvariant' : ['normal', str],
364359
'text.fontweight' : ['normal', str],
365360
'text.fontsize' : ['medium', validate_fontsize],
366-
'text.markup' : ['plain', validate_markup],
367361

368362
'mathtext.cal' : ['cursive', validate_font_properties],
369363
'mathtext.rm' : ['serif', validate_font_properties],

lib/matplotlib/legend.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ def __init__(self, parent, handles, labels,
123123
handletextsep = None, # the space between the legend line and legend text
124124
axespad = None, # the border between the axes and legend edge
125125

126-
shadow = None,
127-
markup = None
126+
shadow = None
128127
):
129128
"""
130129
parent # the artist that contains the legend
@@ -204,7 +203,7 @@ def __init__(self, parent, handles, labels,
204203
else:
205204
self._xdata = npy.linspace(left, left + self.handlelen, self.numpoints)
206205
textleft = left+ self.handlelen+self.handletextsep
207-
self.texts = self._get_texts(labels, textleft, top, markup)
206+
self.texts = self._get_texts(labels, textleft, top)
208207
self.legendHandles = self._get_handles(handles, self.texts)
209208

210209

@@ -405,7 +404,7 @@ def get_texts(self):
405404
'return a list of text.Text instance in the legend'
406405
return silent_list('Text', self.texts)
407406

408-
def _get_texts(self, labels, left, upper, markup):
407+
def _get_texts(self, labels, left, upper):
409408

410409
# height in axes coords
411410
HEIGHT = self._approx_text_height()
@@ -419,8 +418,7 @@ def _get_texts(self, labels, left, upper, markup):
419418
text=l,
420419
fontproperties=self.prop,
421420
verticalalignment='top',
422-
horizontalalignment='left',
423-
markup=markup
421+
horizontalalignment='left'
424422
)
425423
self._set_artist_props(text)
426424
ret.append(text)

lib/matplotlib/mathtext.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,7 +1982,7 @@ def __init__(self):
19821982
math_delim =(~bslash
19831983
+ Literal('$'))
19841984

1985-
non_math = Regex(r"(?:[^$]|(?:\\\$))*"
1985+
non_math = Regex(r"(?:(?:\\[$])|[^$])*"
19861986
).setParseAction(self.non_math).setName("non_math").leaveWhitespace()
19871987

19881988
self._expression << (
@@ -2056,7 +2056,8 @@ def math(self, s, loc, toks):
20562056

20572057
def non_math(self, s, loc, toks):
20582058
#~ print "non_math", toks
2059-
symbols = [Char(c, self.get_state()) for c in toks[0]]
2059+
s = toks[0].replace(r'\$', '$')
2060+
symbols = [Char(c, self.get_state()) for c in s]
20602061
hlist = Hlist(symbols)
20612062
# We're going into math now, so set font to 'it'
20622063
self.push_state()

lib/matplotlib/quiver.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,12 @@ def __init__(self, Q, X, Y, U, label, **kw):
173173
self.labelpos = kw.pop('labelpos', 'N')
174174
self.labelcolor = kw.pop('labelcolor', None)
175175
self.fontproperties = kw.pop('fontproperties', dict())
176-
self.markup = kw.pop('markup', None)
177176
self.kw = kw
178177
_fp = self.fontproperties
179178
self.text = text.Text(text=label,
180179
horizontalalignment=self.halign[self.labelpos],
181180
verticalalignment=self.valign[self.labelpos],
182-
fontproperties=font_manager.FontProperties(**_fp),
183-
markup=self.markup)
181+
fontproperties=font_manager.FontProperties(**_fp))
184182
if self.labelcolor is not None:
185183
self.text.set_color(self.labelcolor)
186184
self._initialized = False

lib/matplotlib/rcsetup.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,6 @@ def validate_font_properties(s):
203203
parse_fontconfig_pattern(s)
204204
return s
205205

206-
validate_markup = ValidateInStrings(
207-
'markup',
208-
['plain', 'tex'],
209-
ignorecase=True)
210-
211206
validate_verbose = ValidateInStrings('verbose',[
212207
'silent', 'helpful', 'debug', 'debug-annoying',
213208
])
@@ -363,7 +358,6 @@ def __call__(self, s):
363358
'text.fontvariant' : ['normal', str],
364359
'text.fontweight' : ['normal', str],
365360
'text.fontsize' : ['medium', validate_fontsize],
366-
'text.markup' : ['plain', validate_markup],
367361

368362
'mathtext.cal' : ['cursive', validate_font_properties],
369363
'mathtext.rm' : ['serif', validate_font_properties],

lib/matplotlib/table.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ def __init__(self, xy, width, height,
4747
fill=True,
4848
text='',
4949
loc=None,
50-
fontproperties=None,
51-
markup=None
50+
fontproperties=None
5251
):
5352

5453
# Call base
@@ -61,7 +60,7 @@ def __init__(self, xy, width, height,
6160
if loc is None: loc = 'right'
6261
self._loc = loc
6362
self._text = Text(x=xy[0], y=xy[1], text=text,
64-
fontproperties=fontproperties, markup=markup)
63+
fontproperties=fontproperties)
6564
self._text.set_clip_on(False)
6665

6766

0 commit comments

Comments
 (0)