From 7ba2d9a12a78d37f4cf59f202e9f943a30c94bda Mon Sep 17 00:00:00 2001 From: David Stansby Date: Fri, 27 Apr 2018 16:56:38 +0100 Subject: [PATCH 1/3] Move remaining examples from api/ --- doc/api/pyplot_summary.rst | 2 -- doc/faq/howto_faq.rst | 7 ++++--- doc/users/prev_whats_new/whats_new_1.1.rst | 9 +++++---- doc/users/prev_whats_new/whats_new_1.4.rst | 4 ++-- doc/users/prev_whats_new/whats_new_1.5.rst | 4 ++-- examples/api/README.txt | 18 ------------------ .../image_zcoord.py | 0 .../watermark_image.py | 2 +- .../filled_step.py | 0 .../joinstyle.py | 0 .../scatter_piecharts.py | 0 .../span_regions.py | 2 +- examples/{api => misc}/agg_oo_sgskip.py | 0 examples/{api => misc}/histogram_path.py | 0 examples/{api => misc}/logos2.py | 0 examples/{api => scales}/power_norm.py | 0 .../patch_collection.py | 0 .../quad_bezier.py | 0 .../{api => specialty_plots}/radar_chart.py | 0 .../{api => specialty_plots}/sankey_basics.py | 0 .../{api => specialty_plots}/sankey_links.py | 0 .../sankey_rankine.py | 0 examples/{api => specialty_plots}/skewt.py | 0 .../two_scales.py | 3 +-- examples/test2.png | Bin 0 -> 1199 bytes .../font_family_rc_sgskip.py | 0 .../font_file.py | 0 .../legend.py | 2 +- .../line_with_text.py | 0 .../mathtext_asarray.py | 0 .../unicode_minus.py | 0 .../watermark_text.py | 6 +----- lib/matplotlib/axes/_axes.py | 2 +- lib/matplotlib/path.py | 2 +- lib/matplotlib/sankey.py | 2 +- tutorials/introductory/lifecycle.py | 4 +--- tutorials/introductory/sample_plots.py | 4 ++-- 37 files changed, 24 insertions(+), 49 deletions(-) delete mode 100644 examples/api/README.txt rename examples/{api => images_contours_and_fields}/image_zcoord.py (100%) rename examples/{api => images_contours_and_fields}/watermark_image.py (96%) rename examples/{api => lines_bars_and_markers}/filled_step.py (100%) rename examples/{api => lines_bars_and_markers}/joinstyle.py (100%) rename examples/{api => lines_bars_and_markers}/scatter_piecharts.py (100%) rename examples/{api => lines_bars_and_markers}/span_regions.py (98%) rename examples/{api => misc}/agg_oo_sgskip.py (100%) rename examples/{api => misc}/histogram_path.py (100%) rename examples/{api => misc}/logos2.py (100%) rename examples/{api => scales}/power_norm.py (100%) rename examples/{api => shapes_and_collections}/patch_collection.py (100%) rename examples/{api => shapes_and_collections}/quad_bezier.py (100%) rename examples/{api => specialty_plots}/radar_chart.py (100%) rename examples/{api => specialty_plots}/sankey_basics.py (100%) rename examples/{api => specialty_plots}/sankey_links.py (100%) rename examples/{api => specialty_plots}/sankey_rankine.py (100%) rename examples/{api => specialty_plots}/skewt.py (100%) rename examples/{api => subplots_axes_and_figures}/two_scales.py (94%) create mode 100644 examples/test2.png rename examples/{api => text_labels_and_annotations}/font_family_rc_sgskip.py (100%) rename examples/{api => text_labels_and_annotations}/font_file.py (100%) rename examples/{api => text_labels_and_annotations}/legend.py (95%) rename examples/{api => text_labels_and_annotations}/line_with_text.py (100%) rename examples/{api => text_labels_and_annotations}/mathtext_asarray.py (100%) rename examples/{api => text_labels_and_annotations}/unicode_minus.py (100%) rename examples/{api => text_labels_and_annotations}/watermark_text.py (88%) diff --git a/doc/api/pyplot_summary.rst b/doc/api/pyplot_summary.rst index 4b290d5452af..99660f45864d 100644 --- a/doc/api/pyplot_summary.rst +++ b/doc/api/pyplot_summary.rst @@ -28,8 +28,6 @@ While it is easy to quickly generate plots with the we recommend using the object-oriented approach for more control and customization of your plots. See the methods in the :meth:`matplotlib.axes.Axes` class for many of the same plotting functions. -For examples of the OO approach to Matplotlib, see the -:ref:`API Examples`. Colors in Matplotlib -------------------- diff --git a/doc/faq/howto_faq.rst b/doc/faq/howto_faq.rst index f1ddfe8bd8e5..12633e8b2d91 100644 --- a/doc/faq/howto_faq.rst +++ b/doc/faq/howto_faq.rst @@ -137,7 +137,7 @@ Finally, the multipage pdf object has to be closed:: pp.close() The same can be done using the pgf backend:: - + from matplotlib.backends.backend_pgf import PdfPages @@ -415,7 +415,8 @@ locators as desired because the two axes are independent. .. only:: html - See :doc:`/gallery/api/two_scales` for a complete example + See :doc:`/gallery/subplots_axes_and_figures/two_scales` for a + complete example. .. _howto-batch: @@ -661,7 +662,7 @@ For more on configuring your backend, see Alternatively, you can avoid pylab/pyplot altogether, which will give you a little more control, by calling the API directly as shown in -:doc:`/gallery/api/agg_oo_sgskip`. +:doc:`/gallery/misc/agg_oo_sgskip`. You can either generate hardcopy on the filesystem by calling savefig:: diff --git a/doc/users/prev_whats_new/whats_new_1.1.rst b/doc/users/prev_whats_new/whats_new_1.1.rst index cf9d38dd234a..502f63e4e0cc 100644 --- a/doc/users/prev_whats_new/whats_new_1.1.rst +++ b/doc/users/prev_whats_new/whats_new_1.1.rst @@ -17,11 +17,12 @@ Sankey Diagrams Kevin Davies has extended Yannick Copin's original Sankey example into a module (:mod:`~matplotlib.sankey`) and provided new examples -(:doc:`/gallery/api/sankey_basics`, :doc:`/gallery/api/sankey_links`, -:doc:`/gallery/api/sankey_rankine`). +(:doc:`/gallery/specialty_plots/sankey_basics`, +:doc:`/gallery/specialty_plots/sankey_links`, +:doc:`/gallery/specialty_plots/sankey_rankine`). -.. figure:: ../../gallery/api/images/sphx_glr_sankey_rankine_001.png - :target: ../../gallery/api/sankey_rankine.html +.. figure:: ../../gallery/specialty_plots/images/sphx_glr_sankey_rankine_001.png + :target: ../../gallery/specialty_plots/sankey_rankine.html :align: center :scale: 50 diff --git a/doc/users/prev_whats_new/whats_new_1.4.rst b/doc/users/prev_whats_new/whats_new_1.4.rst index 48dbd8266e22..70146e1e8c57 100644 --- a/doc/users/prev_whats_new/whats_new_1.4.rst +++ b/doc/users/prev_whats_new/whats_new_1.4.rst @@ -160,8 +160,8 @@ matplotlib internals were cleaned up to support using such transforms in :class:`~matplotlib.Axes`. This transform is important for some plot types, specifically the Skew-T used in meteorology. -.. figure:: ../../gallery/api/images/sphx_glr_skewt_001.png - :target: ../../gallery/api/skewt.html +.. figure:: ../../gallery/specialty_plots/images/sphx_glr_skewt_001.png + :target: ../../gallery/specialty_plots/skewt.html :align: center :scale: 50 diff --git a/doc/users/prev_whats_new/whats_new_1.5.rst b/doc/users/prev_whats_new/whats_new_1.5.rst index 854cb889f746..9e7ca186252b 100644 --- a/doc/users/prev_whats_new/whats_new_1.5.rst +++ b/doc/users/prev_whats_new/whats_new_1.5.rst @@ -377,8 +377,8 @@ kwargs names is not ideal, but `Axes.fill_between` already has a This is particularly useful for plotting pre-binned histograms. -.. figure:: ../../gallery/api/images/sphx_glr_filled_step_001.png - :target: ../../gallery/api/filled_step.html +.. figure:: ../../gallery/lines_bars_and_markers/images/sphx_glr_filled_step_001.png + :target: ../../gallery/lines_bars_and_markers/filled_step.html :align: center :scale: 50 diff --git a/examples/api/README.txt b/examples/api/README.txt deleted file mode 100644 index c0359dc24319..000000000000 --- a/examples/api/README.txt +++ /dev/null @@ -1,18 +0,0 @@ -.. _api_examples: - -Matplotlib API -============== - -These examples use the Matplotlib api rather than the pylab/pyplot -procedural state machine. For robust, production level scripts, or -for applications or web application servers, we recommend you use the -Matplotlib API directly as it gives you the maximum control over your -figures, axes and plottng commands. - -The example agg_oo.py is the simplest example of using the Agg backend -which is readily ported to other output formats. This example is a -good starting point if your are a web application developer. Many of -the other examples in this directory use ``matplotlib.pyplot`` just to -create the figure and show calls, and use the API for everything else. -This is a good solution for production quality scripts. For full -fledged GUI applications, see the user_interfaces examples. diff --git a/examples/api/image_zcoord.py b/examples/images_contours_and_fields/image_zcoord.py similarity index 100% rename from examples/api/image_zcoord.py rename to examples/images_contours_and_fields/image_zcoord.py diff --git a/examples/api/watermark_image.py b/examples/images_contours_and_fields/watermark_image.py similarity index 96% rename from examples/api/watermark_image.py rename to examples/images_contours_and_fields/watermark_image.py index a3246e7ae0d9..91cf43302668 100644 --- a/examples/api/watermark_image.py +++ b/examples/images_contours_and_fields/watermark_image.py @@ -3,7 +3,7 @@ Watermark image =============== -Use a PNG file as a watermark +Using a PNG file as a watermark. """ import numpy as np import matplotlib.cbook as cbook diff --git a/examples/api/filled_step.py b/examples/lines_bars_and_markers/filled_step.py similarity index 100% rename from examples/api/filled_step.py rename to examples/lines_bars_and_markers/filled_step.py diff --git a/examples/api/joinstyle.py b/examples/lines_bars_and_markers/joinstyle.py similarity index 100% rename from examples/api/joinstyle.py rename to examples/lines_bars_and_markers/joinstyle.py diff --git a/examples/api/scatter_piecharts.py b/examples/lines_bars_and_markers/scatter_piecharts.py similarity index 100% rename from examples/api/scatter_piecharts.py rename to examples/lines_bars_and_markers/scatter_piecharts.py diff --git a/examples/api/span_regions.py b/examples/lines_bars_and_markers/span_regions.py similarity index 98% rename from examples/api/span_regions.py rename to examples/lines_bars_and_markers/span_regions.py index 04ff7561800c..e1a9b85c1407 100644 --- a/examples/api/span_regions.py +++ b/examples/lines_bars_and_markers/span_regions.py @@ -4,7 +4,7 @@ ================ Illustrate some helper functions for shading regions where a logical -mask is True +mask is True. See :meth:`matplotlib.collections.BrokenBarHCollection.span_where` """ diff --git a/examples/api/agg_oo_sgskip.py b/examples/misc/agg_oo_sgskip.py similarity index 100% rename from examples/api/agg_oo_sgskip.py rename to examples/misc/agg_oo_sgskip.py diff --git a/examples/api/histogram_path.py b/examples/misc/histogram_path.py similarity index 100% rename from examples/api/histogram_path.py rename to examples/misc/histogram_path.py diff --git a/examples/api/logos2.py b/examples/misc/logos2.py similarity index 100% rename from examples/api/logos2.py rename to examples/misc/logos2.py diff --git a/examples/api/power_norm.py b/examples/scales/power_norm.py similarity index 100% rename from examples/api/power_norm.py rename to examples/scales/power_norm.py diff --git a/examples/api/patch_collection.py b/examples/shapes_and_collections/patch_collection.py similarity index 100% rename from examples/api/patch_collection.py rename to examples/shapes_and_collections/patch_collection.py diff --git a/examples/api/quad_bezier.py b/examples/shapes_and_collections/quad_bezier.py similarity index 100% rename from examples/api/quad_bezier.py rename to examples/shapes_and_collections/quad_bezier.py diff --git a/examples/api/radar_chart.py b/examples/specialty_plots/radar_chart.py similarity index 100% rename from examples/api/radar_chart.py rename to examples/specialty_plots/radar_chart.py diff --git a/examples/api/sankey_basics.py b/examples/specialty_plots/sankey_basics.py similarity index 100% rename from examples/api/sankey_basics.py rename to examples/specialty_plots/sankey_basics.py diff --git a/examples/api/sankey_links.py b/examples/specialty_plots/sankey_links.py similarity index 100% rename from examples/api/sankey_links.py rename to examples/specialty_plots/sankey_links.py diff --git a/examples/api/sankey_rankine.py b/examples/specialty_plots/sankey_rankine.py similarity index 100% rename from examples/api/sankey_rankine.py rename to examples/specialty_plots/sankey_rankine.py diff --git a/examples/api/skewt.py b/examples/specialty_plots/skewt.py similarity index 100% rename from examples/api/skewt.py rename to examples/specialty_plots/skewt.py diff --git a/examples/api/two_scales.py b/examples/subplots_axes_and_figures/two_scales.py similarity index 94% rename from examples/api/two_scales.py rename to examples/subplots_axes_and_figures/two_scales.py index 6a0017e5b891..6238732e47f9 100644 --- a/examples/api/two_scales.py +++ b/examples/subplots_axes_and_figures/two_scales.py @@ -3,8 +3,7 @@ Plots with different scales =========================== -Demonstrate how to do two plots on the same axes with different left and -right scales. +Two plots on the same axes with different left and right scales. The trick is to use *two different axes* that share the same *x* axis. You can use separate `matplotlib.ticker` formatters and locators as diff --git a/examples/test2.png b/examples/test2.png new file mode 100644 index 0000000000000000000000000000000000000000..68c75e2ad2adfab5346dd7ed6be62ac49bc0a617 GIT binary patch literal 1199 zcmV;g1W@~lP)n0hNR$he2c+} z@_*sGit=NFcI#mXCU>WUMhVG_Lj-}JV>b3J$j<#3gHerkPzE7O#PS=5%W)`P6ic%R zOcBKF(};2{AJS|*UGe!nyos-I8Xhaa-fGOjZMZP6a#>5J5^Y$4{R*^kHzwl5yo%d` zkp9B?ttimOFJhKV%d1!hA-4)AHxwt}39Q0Xb@Zl+nB}}qo?nzbzpj(#4+#f5GS6Vk zAY?G+;Zw{N{$niusH3+yt4Gv$))zDI1!i@kzf{B*lkyC<45xZ_gLtiCyV%>{`)&Fs{I}m|v%lmqbLJ>|D2JLST`IR}QOa zyAv(AGC_Y?R-cq=@V`I^9m{5d$cgU4M+y3$h`j0eRD(tMkS$HWd`fOMEY8$Q104OYn1!K33}>w60??gM>g6Q z3ljQTEdJrC;*92joMTxderHl{QxqYSMeNazv0}FvAp)s>SSMnVdh2_Un039y?(%oe zv24id-BN^$BIGPvN22Spx;3-eZg+wDamw53p^Pmx?zVzY=PhKR^%*eU#FCmW z$ZQ0?vikQF;UadK4dTqT7S`Zhk?cL1$*r%F8HDq35H1kQM*t5XiLJHr66Q1q!c>JKle;-}p0C5>1==TqL3lY;VSCSZyNl7nX@8iiPy`{>_qcgVGtoor zSP$n>DuR%fPD*clg_&K*G!tXQHa|O$QkhHUT5<4O7AA?4_goQf8Hdb7$Uar9FFFx4o7kQrGaUW*u}7&72`T#auU?VuJR8^zu0Ec}_Z-6R}h zHRe~yz@;L8*;cqkTyWLHQ6g<1;+0jh^OBYwZy|1t|9j}38#@T8!aty7-3{!nb?pEE N002ovPDHLkV1hk%JTU+O literal 0 HcmV?d00001 diff --git a/examples/api/font_family_rc_sgskip.py b/examples/text_labels_and_annotations/font_family_rc_sgskip.py similarity index 100% rename from examples/api/font_family_rc_sgskip.py rename to examples/text_labels_and_annotations/font_family_rc_sgskip.py diff --git a/examples/api/font_file.py b/examples/text_labels_and_annotations/font_file.py similarity index 100% rename from examples/api/font_file.py rename to examples/text_labels_and_annotations/font_file.py diff --git a/examples/api/legend.py b/examples/text_labels_and_annotations/legend.py similarity index 95% rename from examples/api/legend.py rename to examples/text_labels_and_annotations/legend.py index 8a5c25a3a699..7e6162a51c25 100644 --- a/examples/api/legend.py +++ b/examples/text_labels_and_annotations/legend.py @@ -24,7 +24,7 @@ legend = ax.legend(loc='upper center', shadow=True, fontsize='x-large') # Put a nicer background color on the legend. -legend.get_frame().set_facecolor('#00FFCC') +legend.get_frame().set_facecolor('C0') plt.show() diff --git a/examples/api/line_with_text.py b/examples/text_labels_and_annotations/line_with_text.py similarity index 100% rename from examples/api/line_with_text.py rename to examples/text_labels_and_annotations/line_with_text.py diff --git a/examples/api/mathtext_asarray.py b/examples/text_labels_and_annotations/mathtext_asarray.py similarity index 100% rename from examples/api/mathtext_asarray.py rename to examples/text_labels_and_annotations/mathtext_asarray.py diff --git a/examples/api/unicode_minus.py b/examples/text_labels_and_annotations/unicode_minus.py similarity index 100% rename from examples/api/unicode_minus.py rename to examples/text_labels_and_annotations/unicode_minus.py diff --git a/examples/api/watermark_text.py b/examples/text_labels_and_annotations/watermark_text.py similarity index 88% rename from examples/api/watermark_text.py rename to examples/text_labels_and_annotations/watermark_text.py index a5dbdb2ddef9..a4909b9696e9 100644 --- a/examples/api/watermark_text.py +++ b/examples/text_labels_and_annotations/watermark_text.py @@ -3,12 +3,9 @@ Text watermark ============== -Use a Text as a watermark +Adding a text watermark. """ import numpy as np -#import matplotlib -#matplotlib.use('Agg') - import matplotlib.pyplot as plt # Fixing random state for reproducibility @@ -19,7 +16,6 @@ ax.plot(np.random.rand(20), '-o', ms=20, lw=2, alpha=0.7, mfc='orange') ax.grid() -# position bottom right fig.text(0.95, 0.05, 'Property of MPL', fontsize=50, color='gray', ha='right', va='bottom', alpha=0.5) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index d0e5fd415a32..b719cc84d4e0 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -368,7 +368,7 @@ def legend(self, *args, **kwargs): Examples -------- - .. plot:: gallery/api/legend.py + .. plot:: gallery/text_labels_and_annotations/legend.py """ handles, labels, extra_args, kwargs = mlegend._parse_legend_args( diff --git a/lib/matplotlib/path.py b/lib/matplotlib/path.py index ab9c271460bc..e2cee67974bf 100644 --- a/lib/matplotlib/path.py +++ b/lib/matplotlib/path.py @@ -303,7 +303,7 @@ def make_compound_path_from_polys(cls, XY): numsides x 2) numpy array of vertices. Return object is a :class:`Path` - .. plot:: gallery/api/histogram_path.py + .. plot:: gallery/misc/histogram_path.py """ diff --git a/lib/matplotlib/sankey.py b/lib/matplotlib/sankey.py index 8e3d3c28c7ef..72460f4a0ed2 100644 --- a/lib/matplotlib/sankey.py +++ b/lib/matplotlib/sankey.py @@ -118,7 +118,7 @@ def __init__(self, ax=None, scale=1.0, unit='', format='%G', gap=0.25, **Examples:** - .. plot:: gallery/api/sankey_basics.py + .. plot:: gallery/specialty_plots/sankey_basics.py """ # Check the arguments. if gap < 0: diff --git a/tutorials/introductory/lifecycle.py b/tutorials/introductory/lifecycle.py index c8af6d5c6183..515c3b1c75f6 100644 --- a/tutorials/introductory/lifecycle.py +++ b/tutorials/introductory/lifecycle.py @@ -36,9 +36,7 @@ "axis", which refers to the x/y axis of a plot). We call methods that do the plotting directly from the Axes, which gives -us much more flexibility and power in customizing our plot. See the -:ref:`object-oriented examples ` for many examples of how -this approach is used. +us much more flexibility and power in customizing our plot. .. note:: diff --git a/tutorials/introductory/sample_plots.py b/tutorials/introductory/sample_plots.py index 97ad1a96948f..f185d17f80ce 100644 --- a/tutorials/introductory/sample_plots.py +++ b/tutorials/introductory/sample_plots.py @@ -333,8 +333,8 @@ generates figure legends, with MATLAB-compatible legend-placement functions. -.. figure:: ../../gallery/api/images/sphx_glr_legend_001.png - :target: ../../gallery/api/legend.html +.. figure:: ../../gallery/text_labels_and_annotations/images/sphx_glr_legend_001.png + :target: ../../gallery/text_labels_and_annotations/legend.html :align: center :scale: 50 From 31f53812521248dd53110373ae9cb257fc0fba78 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Thu, 24 May 2018 10:45:36 +0100 Subject: [PATCH 2/3] Remove api folder mention in examples README --- examples/README | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/README b/examples/README index 1e89277d289b..746f2e334664 100644 --- a/examples/README +++ b/examples/README @@ -16,8 +16,6 @@ Below is a brief description of the different directories found here: * animation - Dynamic plots, see the documentation at http://matplotlib.org/api/animation_api.html - * api - working with the Matplotlib API directly. - * axes_grid1 - Examples related to the axes_grid1 toolkit. * axisartist - Examples related to the axisartist toolkit. From a351d21feeec8d635e4844bf079c057d3be2314f Mon Sep 17 00:00:00 2001 From: David Stansby Date: Tue, 26 Jun 2018 10:23:43 +0100 Subject: [PATCH 3/3] Fix link --- examples/text_labels_and_annotations/font_file.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/text_labels_and_annotations/font_file.py b/examples/text_labels_and_annotations/font_file.py index 8dc8cddc5315..ed1341c14356 100644 --- a/examples/text_labels_and_annotations/font_file.py +++ b/examples/text_labels_and_annotations/font_file.py @@ -10,7 +10,8 @@ Here, we use the Computer Modern roman font (``cmr10``) shipped with Matplotlib. -For a more flexible solution, see :doc:`/gallery/api/font_family_rc_sgskip` and +For a more flexible solution, see +:doc:`/gallery/text_labels_and_annotations/font_family_rc_sgskip` and :doc:`/gallery/text_labels_and_annotations/fonts_demo`. """