diff --git a/examples/pylab_examples/font_table_ttf_sgskip.py b/examples/text_labels_and_annotations/font_table_ttf_sgskip.py similarity index 95% rename from examples/pylab_examples/font_table_ttf_sgskip.py rename to examples/text_labels_and_annotations/font_table_ttf_sgskip.py index 9a2153d01d4c..880453b55089 100644 --- a/examples/pylab_examples/font_table_ttf_sgskip.py +++ b/examples/text_labels_and_annotations/font_table_ttf_sgskip.py @@ -55,8 +55,8 @@ tab = plt.table(cellText=chars, rowLabels=labelr, colLabels=labelc, - rowColours=[lightgrn]*16, - colColours=[lightgrn]*16, + rowColours=[lightgrn] * 16, + colColours=[lightgrn] * 16, cellColours=colors, cellLoc='center', loc='upper left') diff --git a/examples/pylab_examples/fonts_demo.py b/examples/text_labels_and_annotations/fonts_demo.py similarity index 100% rename from examples/pylab_examples/fonts_demo.py rename to examples/text_labels_and_annotations/fonts_demo.py diff --git a/examples/pylab_examples/fonts_demo_kw.py b/examples/text_labels_and_annotations/fonts_demo_kw.py similarity index 100% rename from examples/pylab_examples/fonts_demo_kw.py rename to examples/text_labels_and_annotations/fonts_demo_kw.py diff --git a/examples/pylab_examples/mathtext_demo.py b/examples/text_labels_and_annotations/mathtext_demo.py similarity index 92% rename from examples/pylab_examples/mathtext_demo.py rename to examples/text_labels_and_annotations/mathtext_demo.py index 2dc02813f0cd..e2b03da638b9 100644 --- a/examples/pylab_examples/mathtext_demo.py +++ b/examples/text_labels_and_annotations/mathtext_demo.py @@ -25,6 +25,7 @@ ax.legend([r"$\sqrt{x^2}$"]) -ax.set_title(r'$\Delta_i^j \hspace{0.4} \mathrm{versus} \hspace{0.4} \Delta_{i+1}^j$', fontsize=20) +ax.set_title(r'$\Delta_i^j \hspace{0.4} \mathrm{versus} \hspace{0.4} ' + r'\Delta_{i+1}^j$', fontsize=20) show() diff --git a/examples/pylab_examples/mathtext_examples.py b/examples/text_labels_and_annotations/mathtext_examples.py similarity index 89% rename from examples/pylab_examples/mathtext_examples.py rename to examples/text_labels_and_annotations/mathtext_examples.py index 37776beec442..86c349f10d11 100644 --- a/examples/pylab_examples/mathtext_examples.py +++ b/examples/text_labels_and_annotations/mathtext_examples.py @@ -59,9 +59,9 @@ def doall(): # Colors used in mpl online documentation. - mpl_blue_rvb = (191./255., 209./256., 212./255.) - mpl_orange_rvb = (202/255., 121/256., 0./255.) - mpl_grey_rvb = (51./255., 51./255., 51./255.) + mpl_blue_rvb = (191. / 255., 209. / 256., 212. / 255.) + mpl_orange_rvb = (202. / 255., 121. / 256., 0. / 255.) + mpl_grey_rvb = (51. / 255., 51. / 255., 51. / 255.) # Creating figure and axis. plt.figure(figsize=(6, 7)) @@ -79,25 +79,25 @@ def doall(): # Plotting header demonstration formula full_demo = mathext_demos[0] plt.annotate(full_demo, - xy=(0.5, 1. - 0.59*line_axesfrac), + xy=(0.5, 1. - 0.59 * line_axesfrac), xycoords='data', color=mpl_orange_rvb, ha='center', fontsize=20) # Plotting features demonstration formulae for i_line in range(1, n_lines): - baseline = 1. - (i_line)*line_axesfrac - baseline_next = baseline - line_axesfrac*1. + baseline = 1 - (i_line) * line_axesfrac + baseline_next = baseline - line_axesfrac title = mathtext_titles[i_line] + ":" fill_color = ['white', mpl_blue_rvb][i_line % 2] plt.fill_between([0., 1.], [baseline, baseline], [baseline_next, baseline_next], color=fill_color, alpha=0.5) plt.annotate(title, - xy=(0.07, baseline - 0.3*line_axesfrac), + xy=(0.07, baseline - 0.3 * line_axesfrac), xycoords='data', color=mpl_grey_rvb, weight='bold') demo = mathext_demos[i_line] plt.annotate(demo, - xy=(0.05, baseline - 0.75*line_axesfrac), + xy=(0.05, baseline - 0.75 * line_axesfrac), xycoords='data', color=mpl_grey_rvb, fontsize=16) @@ -106,6 +106,7 @@ def doall(): print(i, s) plt.show() + if '--latex' in sys.argv: # Run: python mathtext_examples.py --latex # Need amsmath and amssymb packages. diff --git a/examples/pylab_examples/stix_fonts_demo.py b/examples/text_labels_and_annotations/stix_fonts_demo.py similarity index 100% rename from examples/pylab_examples/stix_fonts_demo.py rename to examples/text_labels_and_annotations/stix_fonts_demo.py diff --git a/examples/pylab_examples/text_rotation_relative_to_line.py b/examples/text_labels_and_annotations/text_rotation_relative_to_line.py similarity index 100% rename from examples/pylab_examples/text_rotation_relative_to_line.py rename to examples/text_labels_and_annotations/text_rotation_relative_to_line.py diff --git a/examples/pylab_examples/titles_demo.py b/examples/text_labels_and_annotations/titles_demo.py similarity index 100% rename from examples/pylab_examples/titles_demo.py rename to examples/text_labels_and_annotations/titles_demo.py diff --git a/examples/pylab_examples/usetex_baseline_test.py b/examples/text_labels_and_annotations/usetex_baseline_test.py similarity index 95% rename from examples/pylab_examples/usetex_baseline_test.py rename to examples/text_labels_and_annotations/usetex_baseline_test.py index d626f660af7f..1a222b61a912 100644 --- a/examples/pylab_examples/usetex_baseline_test.py +++ b/examples/text_labels_and_annotations/usetex_baseline_test.py @@ -37,6 +37,7 @@ def draw(self, renderer): plt.rcParams["text.usetex"] = usetex plt.rcParams["text.latex.preview"] = preview + subplot = maxes.subplot_class_factory(Axes) @@ -46,7 +47,6 @@ def test_window_extent(ax, usetex, preview): ax.xaxis.set_visible(False) ax.yaxis.set_visible(False) - #t = ax.text(0., 0., r"mlp", va="baseline", size=150) text_kw = dict(va=va, size=50, bbox=dict(pad=0., ec="k", fc="none")) @@ -67,7 +67,7 @@ def test_window_extent(ax, usetex, preview): ax.set_title("usetex=%s\npreview=%s" % (str(usetex), str(preview))) -fig = plt.figure(figsize=(2.*3, 6.5)) +fig = plt.figure(figsize=(2 * 3, 6.5)) for i, usetex, preview in [[0, False, False], [1, True, False], diff --git a/examples/pylab_examples/usetex_demo.py b/examples/text_labels_and_annotations/usetex_demo.py similarity index 60% rename from examples/pylab_examples/usetex_demo.py rename to examples/text_labels_and_annotations/usetex_demo.py index 7a0df3b4c5aa..86d4587c6dc4 100644 --- a/examples/pylab_examples/usetex_demo.py +++ b/examples/text_labels_and_annotations/usetex_demo.py @@ -13,14 +13,14 @@ N = 500 delta = 0.6 X = np.linspace(-1, 1, N) -plt.plot(X, (1 - np.tanh(4.*X/delta))/2, # phase field tanh profiles - X, (X + 1)/2, # level set distance function - X, (1.4 + np.tanh(4.*X/delta))/4, # composition profile - X, X < 0, 'k--', # sharp interface - ) +plt.plot(X, (1 - np.tanh(4 * X / delta)) / 2, # phase field tanh profiles + X, (X + 1) / 2, # level set distance function + X, (1.4 + np.tanh(4 * X / delta)) / 4, # composition profile + X, X < 0, 'k--') # sharp interface # legend -plt.legend(('phase field', 'level set', 'composition', 'sharp interface'), shadow=True, loc=(0.01, 0.55)) +plt.legend(('phase field', 'level set', 'composition', 'sharp interface'), + shadow=True, loc=(0.01, 0.55)) ltext = plt.gca().get_legend().get_texts() plt.setp(ltext[0], fontsize=20) @@ -32,42 +32,45 @@ height = 0.1 offset = 0.02 plt.plot((-delta / 2., delta / 2), (height, height), 'k', linewidth=2) -plt.plot((-delta / 2, -delta / 2 + offset * 2), (height, height - offset), 'k', linewidth=2) -plt.plot((-delta / 2, -delta / 2 + offset * 2), (height, height + offset), 'k', linewidth=2) -plt.plot((delta / 2, delta / 2 - offset * 2), (height, height - offset), 'k', linewidth=2) -plt.plot((delta / 2, delta / 2 - offset * 2), (height, height + offset), 'k', linewidth=2) +plt.plot((-delta / 2, -delta / 2 + offset * 2), (height, height - offset), + 'k', linewidth=2) +plt.plot((-delta / 2, -delta / 2 + offset * 2), (height, height + offset), + 'k', linewidth=2) +plt.plot((delta / 2, delta / 2 - offset * 2), (height, height - offset), + 'k', linewidth=2) +plt.plot((delta / 2, delta / 2 - offset * 2), (height, height + offset), + 'k', linewidth=2) plt.text(-0.06, height - 0.06, r'$\delta$', {'color': 'k', 'fontsize': 24}) # X-axis label plt.xticks((-1, 0, 1), ('-1', '0', '1'), color='k', size=20) # Left Y-axis labels -plt.ylabel(r'\bf{phase field} $\phi$', {'color': 'b', - 'fontsize': 20}) +plt.ylabel(r'\bf{phase field} $\phi$', {'color': 'b', 'fontsize': 20}) plt.yticks((0, 0.5, 1), ('0', '.5', '1'), color='k', size=20) # Right Y-axis labels plt.text(1.05, 0.5, r"\bf{level set} $\phi$", {'color': 'g', 'fontsize': 20}, - horizontalalignment='left', - verticalalignment='center', - rotation=90, - clip_on=False) + horizontalalignment='left', + verticalalignment='center', + rotation=90, + clip_on=False) plt.text(1.01, -0.02, "-1", {'color': 'k', 'fontsize': 20}) plt.text(1.01, 0.98, "1", {'color': 'k', 'fontsize': 20}) plt.text(1.01, 0.48, "0", {'color': 'k', 'fontsize': 20}) # level set equations plt.text(0.1, 0.85, - r'$|\nabla\phi| = 1,$ \newline $ \frac{\partial \phi}{\partial t}' - r'+ U|\nabla \phi| = 0$', - {'color': 'g', 'fontsize': 20}) + r'$|\nabla\phi| = 1,$ \newline $ \frac{\partial \phi}{\partial t}' + r'+ U|\nabla \phi| = 0$', + {'color': 'g', 'fontsize': 20}) # phase field equations plt.text(0.2, 0.15, - r'$\mathcal{F} = \int f\left( \phi, c \right) dV,$ \newline ' - r'$ \frac{ \partial \phi } { \partial t } = -M_{ \phi } ' - r'\frac{ \delta \mathcal{F} } { \delta \phi }$', - {'color': 'b', 'fontsize': 20}) + r'$\mathcal{F} = \int f\left( \phi, c \right) dV,$ \newline ' + r'$ \frac{ \partial \phi } { \partial t } = -M_{ \phi } ' + r'\frac{ \delta \mathcal{F} } { \delta \phi }$', + {'color': 'b', 'fontsize': 20}) # these went wrong in pdf in a previous version plt.text(-.9, .42, r'gamma: $\gamma$', {'color': 'r', 'fontsize': 20}) diff --git a/tutorials/01_introductory/sample_plots.py b/tutorials/01_introductory/sample_plots.py index bc9bb9f12276..c4fedcbc4cbd 100644 --- a/tutorials/01_introductory/sample_plots.py +++ b/tutorials/01_introductory/sample_plots.py @@ -319,8 +319,8 @@ and the DejaVu, BaKoMa computer modern, or `STIX `_ fonts. See the :mod:`matplotlib.mathtext` module for additional details. -.. figure:: ../../gallery/pylab_examples/images/sphx_glr_mathtext_examples_001.png - :target: ../../gallery/pylab_examples/mathtext_examples.html +.. figure:: ../../gallery/text_labels_and_annotations/images/sphx_glr_mathtext_examples_001.png + :target: ../../gallery/text_labels_and_annotations/mathtext_examples.html :align: center :scale: 50