diff --git a/examples/api/power_norm.py b/examples/api/power_norm.py index 491792c1a4b1..025841a51751 100644 --- a/examples/api/power_norm.py +++ b/examples/api/power_norm.py @@ -25,7 +25,7 @@ axes[0, 0].hist2d(data[:, 0], data[:, 1], bins=100) for ax, gamma in zip(axes.flat[1:], gammas): - ax.set_title('Power law $(\gamma=%1.1f)$' % gamma) + ax.set_title(r'Power law $(\gamma=%1.1f)$' % gamma) ax.hist2d(data[:, 0], data[:, 1], bins=100, norm=mcolors.PowerNorm(gamma)) diff --git a/examples/recipes/fill_between_alpha.py b/examples/recipes/fill_between_alpha.py index 3a53841b33d7..eb7d503ee54a 100644 --- a/examples/recipes/fill_between_alpha.py +++ b/examples/recipes/fill_between_alpha.py @@ -81,7 +81,7 @@ ax.plot(t, mu2, lw=2, label='mean population 2', color='yellow') ax.fill_between(t, mu1+sigma1, mu1-sigma1, facecolor='blue', alpha=0.5) ax.fill_between(t, mu2+sigma2, mu2-sigma2, facecolor='yellow', alpha=0.5) -ax.set_title('random walkers empirical $\mu$ and $\pm \sigma$ interval') +ax.set_title(r'random walkers empirical $\mu$ and $\pm \sigma$ interval') ax.legend(loc='upper left') ax.set_xlabel('num steps') ax.set_ylabel('position') diff --git a/examples/recipes/placing_text_boxes.py b/examples/recipes/placing_text_boxes.py index 882839c502b7..7ec033df6e1a 100644 --- a/examples/recipes/placing_text_boxes.py +++ b/examples/recipes/placing_text_boxes.py @@ -20,7 +20,10 @@ mu = x.mean() median = np.median(x) sigma = x.std() -textstr = '$\mu=%.2f$\n$\mathrm{median}=%.2f$\n$\sigma=%.2f$' % (mu, median, sigma) +textstr = '\n'.join(( + r'$\mu=%.2f$' % (mu, ), + r'$\mathrm{median}=%.2f$' % (median, ), + r'$\sigma=%.2f$' % (sigma, ))) ax.hist(x, 50) # these are matplotlib.patch.Patch properties diff --git a/examples/shapes_and_collections/path_patch.py b/examples/shapes_and_collections/path_patch.py index dc07c2a5b004..aea628e6a835 100644 --- a/examples/shapes_and_collections/path_patch.py +++ b/examples/shapes_and_collections/path_patch.py @@ -1,4 +1,4 @@ -""" +r""" ================ PathPatch object ================ diff --git a/examples/text_labels_and_annotations/arrow_demo.py b/examples/text_labels_and_annotations/arrow_demo.py index 00d4a57f6fc0..49b07205d0c8 100644 --- a/examples/text_labels_and_annotations/arrow_demo.py +++ b/examples/text_labels_and_annotations/arrow_demo.py @@ -213,7 +213,7 @@ def draw_arrow(pair, alpha=alpha, ec=ec, labelcolor=labelcolor): coords = np.dot(orig_position, M) + [[x_pos, y_pos]] x, y = np.ravel(coords) orig_label = rate_labels[pair] - label = '$%s_{_{\mathrm{%s}}}$' % (orig_label[0], orig_label[1:]) + label = r'$%s_{_{\mathrm{%s}}}$' % (orig_label[0], orig_label[1:]) plt.text(x, y, label, size=label_text_size, ha='center', va='center', color=labelcolor or fc) diff --git a/examples/ticks_and_spines/spines_bounds.py b/examples/ticks_and_spines/spines_bounds.py index fd66eb5612bd..be4f9935e281 100644 --- a/examples/ticks_and_spines/spines_bounds.py +++ b/examples/ticks_and_spines/spines_bounds.py @@ -22,7 +22,7 @@ # set ticks and tick labels ax.set_xlim((0, 2*np.pi)) ax.set_xticks([0, np.pi, 2*np.pi]) -ax.set_xticklabels(['0', '$\pi$', '2$\pi$']) +ax.set_xticklabels(['0', r'$\pi$', r'2$\pi$']) ax.set_ylim((-1.5, 1.5)) ax.set_yticks([-1, 0, 1]) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index ae8b9af0f41d..6959de8d518c 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -1844,7 +1844,7 @@ def acorr(self, x, **kwargs): @_preprocess_data(replace_names=["x", "y"], label_namer="y") def xcorr(self, x, y, normed=True, detrend=mlab.detrend_none, usevlines=True, maxlags=10, **kwargs): - """ + r""" Plot the cross correlation between *x* and *y*. The correlation with lag k is defined as sum_n x[n+k] * conj(y[n]). @@ -5595,7 +5595,7 @@ def _pcolorargs(funcname, *args, **kw): @_preprocess_data(label_namer=None) @docstring.dedent_interpd def pcolor(self, *args, **kwargs): - """ + r""" Create a pseudocolor plot with a non-regular rectangular grid. Call signature:: diff --git a/lib/matplotlib/sphinxext/plot_directive.py b/lib/matplotlib/sphinxext/plot_directive.py index d7f03b881d9f..434bc50aee29 100644 --- a/lib/matplotlib/sphinxext/plot_directive.py +++ b/lib/matplotlib/sphinxext/plot_directive.py @@ -346,7 +346,7 @@ def remove_coding(text): r""" Remove the coding comment, which six.exec\_ doesn't like. """ - sub_re = re.compile("^#\s*-\*-\s*coding:\s*.*-\*-$", flags=re.MULTILINE) + sub_re = re.compile(r"^#\s*-\*-\s*coding:\s*.*-\*-$", flags=re.MULTILINE) return sub_re.sub("", text) #------------------------------------------------------------------------------ diff --git a/setupext.py b/setupext.py index d2ff239adaaf..93585262c88f 100644 --- a/setupext.py +++ b/setupext.py @@ -2051,7 +2051,7 @@ def check(self): output = check_output('latex -version', shell=True, stderr=subprocess.STDOUT) line = output.splitlines()[0].decode() - pattern = '(3\.1\d+)|(MiKTeX \d+.\d+)' + pattern = r'(3\.1\d+)|(MiKTeX \d+.\d+)' match = re.search(pattern, line) return "version %s" % match.group(0) except (IndexError, ValueError, AttributeError, subprocess.CalledProcessError): diff --git a/tests.py b/tests.py index 88d3e2195343..9bc83c91c3cb 100755 --- a/tests.py +++ b/tests.py @@ -33,7 +33,7 @@ category=DeprecationWarning) warnings.filterwarnings( 'default', - '.*inspect.getargspec\(\) is deprecated.*', + r'.*inspect.getargspec\(\) is deprecated.*', category=DeprecationWarning) from matplotlib import test diff --git a/tutorials/text/annotations.py b/tutorials/text/annotations.py index 5706e08cdc75..b9546582f089 100644 --- a/tutorials/text/annotations.py +++ b/tutorials/text/annotations.py @@ -1,4 +1,4 @@ -""" +r""" Annotations =========== diff --git a/tutorials/text/pgf.py b/tutorials/text/pgf.py index 27415528e160..36056ca85460 100644 --- a/tutorials/text/pgf.py +++ b/tutorials/text/pgf.py @@ -1,4 +1,4 @@ -""" +r""" ********************************* Typesetting With XeLaTeX/LuaLaTeX ********************************* diff --git a/tutorials/text/usetex.py b/tutorials/text/usetex.py index 00d7b8bf21e6..bcb558b3df3e 100644 --- a/tutorials/text/usetex.py +++ b/tutorials/text/usetex.py @@ -1,4 +1,4 @@ -""" +r""" ************************* Text rendering With LaTeX ************************* diff --git a/tutorials/toolkits/axes_grid.py b/tutorials/toolkits/axes_grid.py index 7b4ad9f3eda1..71935015d480 100644 --- a/tutorials/toolkits/axes_grid.py +++ b/tutorials/toolkits/axes_grid.py @@ -1,4 +1,4 @@ -""" +r""" ============================== Overview of axes_grid1 toolkit ============================== diff --git a/tutorials/toolkits/axisartist.py b/tutorials/toolkits/axisartist.py index 6807102f9550..bf9fb0e0c0d2 100644 --- a/tutorials/toolkits/axisartist.py +++ b/tutorials/toolkits/axisartist.py @@ -1,4 +1,4 @@ -""" +r""" ============================== Overview of axisartist toolkit ============================== diff --git a/versioneer.py b/versioneer.py index bef128c5dc55..aca3ce819433 100644 --- a/versioneer.py +++ b/versioneer.py @@ -469,7 +469,7 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False): print("unable to run %s (error)" % dispcmd) return None return stdout -LONG_VERSION_PY['git'] = ''' +LONG_VERSION_PY['git'] = r''' # This file helps to compute a version number in source trees obtained from # git-archive tarball (such as those provided by githubs download-from-tag # feature). Distribution tarballs (built by setup.py sdist) and build