Skip to content

Commit 34d8eb2

Browse files
committed
Use raw strings to avoid invalid escape sequences.
1 parent cdcb282 commit 34d8eb2

File tree

13 files changed

+16
-13
lines changed

13 files changed

+16
-13
lines changed

examples/lines_bars_and_markers/marker_reference.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def nice_repr(text):
3434

3535
def math_repr(text):
3636
tx = repr(text).lstrip('u').strip("'").strip("$")
37-
return "'\${}\$'".format(tx)
37+
return r"'\${}\$'".format(tx)
3838

3939

4040
def split_list(a_list):

examples/recipes/fill_between_alpha.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
ax.plot(t, mu2, lw=2, label='mean population 2', color='yellow')
8282
ax.fill_between(t, mu1+sigma1, mu1-sigma1, facecolor='blue', alpha=0.5)
8383
ax.fill_between(t, mu2+sigma2, mu2-sigma2, facecolor='yellow', alpha=0.5)
84-
ax.set_title('random walkers empirical $\mu$ and $\pm \sigma$ interval')
84+
ax.set_title(r'random walkers empirical $\mu$ and $\pm \sigma$ interval')
8585
ax.legend(loc='upper left')
8686
ax.set_xlabel('num steps')
8787
ax.set_ylabel('position')

examples/recipes/placing_text_boxes.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
mu = x.mean()
2121
median = np.median(x)
2222
sigma = x.std()
23-
textstr = '$\mu=%.2f$\n$\mathrm{median}=%.2f$\n$\sigma=%.2f$' % (mu, median, sigma)
23+
textstr = '\n'.join((
24+
r'$\mu=%.2f$' % (mu, ),
25+
r'$\mathrm{median}=%.2f$' % (median, ),
26+
r'$\sigma=%.2f$' % (sigma, )))
2427

2528
ax.hist(x, 50)
2629
# these are matplotlib.patch.Patch properties

examples/scales/power_norm.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
axes[0, 0].hist2d(data[:, 0], data[:, 1], bins=100)
2626

2727
for ax, gamma in zip(axes.flat[1:], gammas):
28-
ax.set_title('Power law $(\gamma=%1.1f)$' % gamma)
28+
ax.set_title(r'Power law $(\gamma=%1.1f)$' % gamma)
2929
ax.hist2d(data[:, 0], data[:, 1],
3030
bins=100, norm=mcolors.PowerNorm(gamma))
3131

examples/text_labels_and_annotations/arrow_demo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def draw_arrow(pair, alpha=alpha, ec=ec, labelcolor=labelcolor):
213213
coords = np.dot(orig_position, M) + [[x_pos, y_pos]]
214214
x, y = np.ravel(coords)
215215
orig_label = rate_labels[pair]
216-
label = '$%s_{_{\mathrm{%s}}}$' % (orig_label[0], orig_label[1:])
216+
label = r'$%s_{_{\mathrm{%s}}}$' % (orig_label[0], orig_label[1:])
217217

218218
plt.text(x, y, label, size=label_text_size, ha='center', va='center',
219219
color=labelcolor or fc)

examples/ticks_and_spines/spines_bounds.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# set ticks and tick labels
2323
ax.set_xlim((0, 2*np.pi))
2424
ax.set_xticks([0, np.pi, 2*np.pi])
25-
ax.set_xticklabels(['0', '$\pi$', '2$\pi$'])
25+
ax.set_xticklabels(['0', r'$\pi$', r'2$\pi$'])
2626
ax.set_ylim((-1.5, 1.5))
2727
ax.set_yticks([-1, 0, 1])
2828

lib/matplotlib/sphinxext/plot_directive.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def remove_coding(text):
340340
Remove the coding comment, which six.exec\_ doesn't like.
341341
"""
342342
cbook.warn_deprecated('3.0', name='remove_coding', removal='3.1')
343-
sub_re = re.compile("^#\s*-\*-\s*coding:\s*.*-\*-$", flags=re.MULTILINE)
343+
sub_re = re.compile(r"^#\s*-\*-\s*coding:\s*.*-\*-$", flags=re.MULTILINE)
344344
return sub_re.sub("", text)
345345

346346
#------------------------------------------------------------------------------

tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
category=DeprecationWarning)
3434
warnings.filterwarnings(
3535
'default',
36-
'.*inspect.getargspec\(\) is deprecated.*',
36+
r'.*inspect.getargspec\(\) is deprecated.*',
3737
category=DeprecationWarning)
3838

3939
from matplotlib import test

tutorials/text/annotations.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""
1+
r"""
22
Annotations
33
===========
44

tutorials/text/pgf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""
1+
r"""
22
*********************************
33
Typesetting With XeLaTeX/LuaLaTeX
44
*********************************

tutorials/text/usetex.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""
1+
r"""
22
*************************
33
Text rendering With LaTeX
44
*************************

tutorials/toolkits/axes_grid.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""
1+
r"""
22
==============================
33
Overview of axes_grid1 toolkit
44
==============================

tutorials/toolkits/axisartist.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""
1+
r"""
22
==============================
33
Overview of axisartist toolkit
44
==============================

0 commit comments

Comments
 (0)