From 3cd3a687c82d4490c49e94060242113d5b3f2d74 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Sun, 17 Mar 2019 18:32:47 +0100 Subject: [PATCH 1/3] Remove What's new fancy example --- .flake8 | 2 +- doc/users/prev_whats_new/whats_new_0.98.4.rst | 13 ++- examples/pyplots/whats_new_98_4_fancy.py | 80 ------------------- .../shapes_and_collections/fancybox_demo.py | 2 + .../fancyarrow_demo.py | 16 ++++ 5 files changed, 29 insertions(+), 84 deletions(-) delete mode 100644 examples/pyplots/whats_new_98_4_fancy.py diff --git a/.flake8 b/.flake8 index 8db5b543e52b..1a156f2cc06e 100644 --- a/.flake8 +++ b/.flake8 @@ -182,7 +182,6 @@ per-file-ignores = examples/pyplots/text_commands.py: E231, E402 examples/pyplots/text_layout.py: E231, E402 examples/pyplots/whats_new_1_subplot3d.py: E402 - examples/pyplots/whats_new_98_4_fancy.py: E302, E402 examples/pyplots/whats_new_98_4_fill_between.py: E225, E402 examples/pyplots/whats_new_98_4_legend.py: E228, E402 examples/pyplots/whats_new_99_axes_grid.py: E402 @@ -229,6 +228,7 @@ per-file-ignores = examples/text_labels_and_annotations/annotation_demo.py: E501 examples/text_labels_and_annotations/demo_text_rotation_mode.py: E402 examples/text_labels_and_annotations/custom_legends.py: E402 + examples/text_labels_and_annotations/fancyarrow_demo.py: E402 examples/text_labels_and_annotations/font_family_rc_sgskip.py: E402 examples/text_labels_and_annotations/font_file.py: E402 examples/text_labels_and_annotations/legend.py: E402 diff --git a/doc/users/prev_whats_new/whats_new_0.98.4.rst b/doc/users/prev_whats_new/whats_new_0.98.4.rst index a7339d6027f6..e0be53ec4e13 100644 --- a/doc/users/prev_whats_new/whats_new_0.98.4.rst +++ b/doc/users/prev_whats_new/whats_new_0.98.4.rst @@ -49,12 +49,19 @@ boxes and connectors in annotations. See :class:`~matplotlib.patches.ArrowStyle`, and :class:`~matplotlib.patches.ConnectionStyle`. -.. figure:: ../../gallery/pyplots/images/sphx_glr_whats_new_98_4_fancy_001.png - :target: ../../gallery/pyplots/whats_new_98_4_fancy.html +.. figure:: ../../gallery/shapes_and_collections/images/sphx_glr_fancybox_demo_001.png + :target: ../../gallery/shapes_and_collections/fancybox_demo.html :align: center :scale: 50 - Whats New 98 4 Fancy + Fancybox Demo + +.. figure:: ../../gallery/text_labels_and_annotations/images/sphx_glr_fancyarrow_demo_001.png + :target: ../../gallery/text_labels_and_annotations/fancyarrow_demo.html + :align: center + :scale: 50 + + Fancyarrow Demo .. _psd-amplitude: diff --git a/examples/pyplots/whats_new_98_4_fancy.py b/examples/pyplots/whats_new_98_4_fancy.py deleted file mode 100644 index d611ba9417a1..000000000000 --- a/examples/pyplots/whats_new_98_4_fancy.py +++ /dev/null @@ -1,80 +0,0 @@ -""" -====================== -Whats New 0.98.4 Fancy -====================== - -Create fancy box and arrow styles. -""" -import matplotlib.patches as mpatch -import matplotlib.pyplot as plt - -figheight = 8 -fig = plt.figure(figsize=(9, figheight), dpi=80) -fontsize = 0.4 * fig.dpi - -def make_boxstyles(ax): - styles = mpatch.BoxStyle.get_styles() - - for i, (stylename, styleclass) in enumerate(sorted(styles.items())): - ax.text(0.5, (float(len(styles)) - 0.5 - i)/len(styles), stylename, - ha="center", - size=fontsize, - transform=ax.transAxes, - bbox=dict(boxstyle=stylename, fc="w", ec="k")) - -def make_arrowstyles(ax): - styles = mpatch.ArrowStyle.get_styles() - - ax.set_xlim(0, 4) - ax.set_ylim(0, figheight) - - for i, (stylename, styleclass) in enumerate(sorted(styles.items())): - y = (float(len(styles)) - 0.25 - i) # /figheight - p = mpatch.Circle((3.2, y), 0.2, fc="w") - ax.add_patch(p) - - ax.annotate(stylename, (3.2, y), - (2., y), - # xycoords="figure fraction", textcoords="figure fraction", - ha="right", va="center", - size=fontsize, - arrowprops=dict(arrowstyle=stylename, - patchB=p, - shrinkA=5, - shrinkB=5, - fc="w", ec="k", - connectionstyle="arc3,rad=-0.05", - ), - bbox=dict(boxstyle="square", fc="w")) - - ax.xaxis.set_visible(False) - ax.yaxis.set_visible(False) - - -ax1 = fig.add_subplot(121, frameon=False, xticks=[], yticks=[]) -make_boxstyles(ax1) - -ax2 = fig.add_subplot(122, frameon=False, xticks=[], yticks=[]) -make_arrowstyles(ax2) - - -plt.show() - -############################################################################# -# -# ------------ -# -# References -# """""""""" -# -# The use of the following functions, methods, classes and modules is shown -# in this example: - -import matplotlib -matplotlib.patches -matplotlib.patches.BoxStyle -matplotlib.patches.BoxStyle.get_styles -matplotlib.patches.ArrowStyle -matplotlib.patches.ArrowStyle.get_styles -matplotlib.axes.Axes.text -matplotlib.axes.Axes.annotate diff --git a/examples/shapes_and_collections/fancybox_demo.py b/examples/shapes_and_collections/fancybox_demo.py index a4b434c1b1c0..4521b8aabaca 100644 --- a/examples/shapes_and_collections/fancybox_demo.py +++ b/examples/shapes_and_collections/fancybox_demo.py @@ -210,3 +210,5 @@ def test_all(): matplotlib.patches.BoxStyle matplotlib.patches.BoxStyle.get_styles matplotlib.transforms.Bbox +matplotlib.figure.Figure.text +matplotlib.axes.Axes.text diff --git a/examples/text_labels_and_annotations/fancyarrow_demo.py b/examples/text_labels_and_annotations/fancyarrow_demo.py index 59262c81917d..cdeecc4086ce 100644 --- a/examples/text_labels_and_annotations/fancyarrow_demo.py +++ b/examples/text_labels_and_annotations/fancyarrow_demo.py @@ -52,3 +52,19 @@ def to_texstring(s): ax.yaxis.set_visible(False) plt.show() + +############################################################################# +# +# ------------ +# +# References +# """""""""" +# +# The use of the following functions, methods, classes and modules is shown +# in this example: + +import matplotlib +matplotlib.patches +matplotlib.patches.ArrowStyle +matplotlib.patches.ArrowStyle.get_styles +matplotlib.axes.Axes.annotate From 377f649dbae631b9542f5d7465e43aafc962fc8e Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Fri, 14 Jun 2019 02:23:05 +0200 Subject: [PATCH 2/3] Use original code in New in matplotllib 0.98.4 --- doc/users/prev_whats_new/whats_new_0.98.4.rst | 78 +++++++++++++++---- 1 file changed, 61 insertions(+), 17 deletions(-) diff --git a/doc/users/prev_whats_new/whats_new_0.98.4.rst b/doc/users/prev_whats_new/whats_new_0.98.4.rst index e0be53ec4e13..d364db9ed7af 100644 --- a/doc/users/prev_whats_new/whats_new_0.98.4.rst +++ b/doc/users/prev_whats_new/whats_new_0.98.4.rst @@ -23,7 +23,7 @@ submitted patches .. _legend-refactor: Legend enhancements --------------------- +------------------- Jae-Joon has rewritten the legend class, and added support for multiple columns and rows, as well as fancy box drawing. See @@ -40,7 +40,7 @@ multiple columns and rows, as well as fancy box drawing. See .. _fancy-annotations: Fancy annotations and arrows ------------------------------ +---------------------------- Jae-Joon has added lots of support to annotations for drawing fancy boxes and connectors in annotations. See @@ -49,25 +49,66 @@ boxes and connectors in annotations. See :class:`~matplotlib.patches.ArrowStyle`, and :class:`~matplotlib.patches.ConnectionStyle`. -.. figure:: ../../gallery/shapes_and_collections/images/sphx_glr_fancybox_demo_001.png - :target: ../../gallery/shapes_and_collections/fancybox_demo.html - :align: center - :scale: 50 +.. plot:: - Fancybox Demo + import matplotlib.patches as mpatch + import matplotlib.pyplot as plt -.. figure:: ../../gallery/text_labels_and_annotations/images/sphx_glr_fancyarrow_demo_001.png - :target: ../../gallery/text_labels_and_annotations/fancyarrow_demo.html - :align: center - :scale: 50 + figheight = 8 + fig = plt.figure(figsize=(9, figheight), dpi=80) + fontsize = 0.4 * fig.dpi - Fancyarrow Demo + def make_boxstyles(ax): + styles = mpatch.BoxStyle.get_styles() -.. _psd-amplitude: + for i, (stylename, styleclass) in enumerate(sorted(styles.items())): + ax.text(0.5, (float(len(styles)) - 0.5 - i)/len(styles), stylename, + ha="center", + size=fontsize, + transform=ax.transAxes, + bbox=dict(boxstyle=stylename, fc="w", ec="k")) + + def make_arrowstyles(ax): + styles = mpatch.ArrowStyle.get_styles() + + ax.set_xlim(0, 4) + ax.set_ylim(0, figheight) + + for i, (stylename, styleclass) in enumerate(sorted(styles.items())): + y = (float(len(styles)) - 0.25 - i) # /figheight + p = mpatch.Circle((3.2, y), 0.2, fc="w") + ax.add_patch(p) + + ax.annotate(stylename, (3.2, y), + (2., y), + # xycoords="figure fraction", textcoords="figure fraction", + ha="right", va="center", + size=fontsize, + arrowprops=dict(arrowstyle=stylename, + patchB=p, + shrinkA=5, + shrinkB=5, + fc="w", ec="k", + connectionstyle="arc3,rad=-0.05", + ), + bbox=dict(boxstyle="square", fc="w")) + + ax.xaxis.set_visible(False) + ax.yaxis.set_visible(False) + + + ax1 = fig.add_subplot(121, frameon=False, xticks=[], yticks=[]) + make_boxstyles(ax1) + + ax2 = fig.add_subplot(122, frameon=False, xticks=[], yticks=[]) + make_arrowstyles(ax2) + + + plt.show() Native OS X backend --------------------- +------------------- Michiel de Hoon has provided a native Mac OSX backend that is almost completely implemented in C. The backend can therefore use Quartz @@ -81,8 +122,11 @@ matplotlibrc file, or run your script with:: > python myfile.py -dmacosx + +.. _psd-amplitude: + psd amplitude scaling -------------------------- +--------------------- Ryan May did a lot of work to rationalize the amplitude scaling of :func:`~matplotlib.pyplot.psd` and friends. See @@ -93,7 +137,7 @@ compatibility and increase scaling options. .. _fill-between: Fill between ------------------- +------------ Added a :func:`~matplotlib.pyplot.fill_between` function to make it easier to do shaded region plots in the presence of masked data. You @@ -109,7 +153,7 @@ where you want to do the filling. Whats New 98 4 Fill Between Lots more ------------ +--------- Here are the 0.98.4 notes from the CHANGELOG:: From d01904f7fc870a2a3a78519ed14e46c4d4b3a261 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Wed, 19 Jun 2019 00:13:56 +0200 Subject: [PATCH 3/3] Adapt plot parameters to mimic original behavior --- doc/users/prev_whats_new/whats_new_0.98.4.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/users/prev_whats_new/whats_new_0.98.4.rst b/doc/users/prev_whats_new/whats_new_0.98.4.rst index d364db9ed7af..01f9fe117c0c 100644 --- a/doc/users/prev_whats_new/whats_new_0.98.4.rst +++ b/doc/users/prev_whats_new/whats_new_0.98.4.rst @@ -54,9 +54,9 @@ boxes and connectors in annotations. See import matplotlib.patches as mpatch import matplotlib.pyplot as plt - figheight = 8 - fig = plt.figure(figsize=(9, figheight), dpi=80) - fontsize = 0.4 * fig.dpi + figheight = 4 + fig = plt.figure(figsize=(4.5, figheight), dpi=80) + fontsize = 0.2 * fig.dpi def make_boxstyles(ax): styles = mpatch.BoxStyle.get_styles() @@ -72,7 +72,7 @@ boxes and connectors in annotations. See styles = mpatch.ArrowStyle.get_styles() ax.set_xlim(0, 4) - ax.set_ylim(0, figheight) + ax.set_ylim(0, figheight*2) for i, (stylename, styleclass) in enumerate(sorted(styles.items())): y = (float(len(styles)) - 0.25 - i) # /figheight