From 741b10953d57d324f5120f7c9fd0af563254fe7a Mon Sep 17 00:00:00 2001 From: yinleon Date: Mon, 6 Mar 2017 18:02:31 -0800 Subject: [PATCH 1/4] changes for MEP12/sphinx-gallery compliance --- examples/axisartist/demo_axisline_style.py | 11 +++++++++++ examples/event_handling/keypress_demo.py | 4 ++++ examples/event_handling/pipong.py | 9 ++++++--- examples/event_handling/poly_editor.py | 4 ++++ examples/event_handling/resample.py | 11 +++++++++-- examples/mplot3d/lines3d_demo.py | 6 +++++- examples/mplot3d/lorenz_attractor.py | 9 +++++++-- examples/mplot3d/mixed_subplots_demo.py | 5 ++++- examples/mplot3d/offset_demo.py | 4 ++++ examples/pylab_examples/bar_stacked.py | 9 +++++++++ examples/pylab_examples/dolphin.py | 8 ++++++++ examples/pylab_examples/fill_between_demo.py | 8 ++++++++ examples/pylab_examples/geo_demo.py | 9 +++++++++ examples/pylab_examples/log_test.py | 8 ++++++++ examples/pylab_examples/mri_demo.py | 9 ++++++++- examples/text_labels_and_annotations/rainbow_text.py | 4 ++++ 16 files changed, 108 insertions(+), 10 deletions(-) diff --git a/examples/axisartist/demo_axisline_style.py b/examples/axisartist/demo_axisline_style.py index a8e2c7ada5d7..6c21987a8052 100644 --- a/examples/axisartist/demo_axisline_style.py +++ b/examples/axisartist/demo_axisline_style.py @@ -1,3 +1,10 @@ +""" +================ +Axis Line Styles +================ + +This example shows some configurations for axis style. +""" from mpl_toolkits.axisartist.axislines import SubplotZero import matplotlib.pyplot as plt @@ -9,10 +16,14 @@ fig.add_subplot(ax) for direction in ["xzero", "yzero"]: + # adds arrows at the ends of each axis ax.axis[direction].set_axisline_style("-|>") + + # adds X and Y-axis from the origin ax.axis[direction].set_visible(True) for direction in ["left", "right", "bottom", "top"]: + # hides boarders ax.axis[direction].set_visible(False) x = np.linspace(-0.5, 1., 100) diff --git a/examples/event_handling/keypress_demo.py b/examples/event_handling/keypress_demo.py index e36eda6bfb72..aa0a4d249c47 100755 --- a/examples/event_handling/keypress_demo.py +++ b/examples/event_handling/keypress_demo.py @@ -1,4 +1,8 @@ """ +========= +Key Press +========= + Show how to connect to keypress events """ from __future__ import print_function diff --git a/examples/event_handling/pipong.py b/examples/event_handling/pipong.py index 89ab36ef9b36..06307d57561c 100755 --- a/examples/event_handling/pipong.py +++ b/examples/event_handling/pipong.py @@ -1,7 +1,10 @@ -# A matplotlib based game of Pong illustrating one way to write interactive -# animation which are easily ported to multiple backends -# pipong.py was written by Paul Ivanov +""" +==== +PONG +==== +A matplotlib based game of Pong illustrating one way to write interactive animation which are easily ported to multiple backends pipong.py was written by Paul Ivanov +""" from __future__ import print_function import numpy as np diff --git a/examples/event_handling/poly_editor.py b/examples/event_handling/poly_editor.py index df95a95d11fe..09e9ee2fc451 100644 --- a/examples/event_handling/poly_editor.py +++ b/examples/event_handling/poly_editor.py @@ -1,4 +1,8 @@ """ +=========== +Poly Editor +========== + This is an example to show how to build cross-GUI applications using matplotlib event handling to interact with objects on the canvas diff --git a/examples/event_handling/resample.py b/examples/event_handling/resample.py index 1b380a06cb96..d1b1654f1b30 100644 --- a/examples/event_handling/resample.py +++ b/examples/event_handling/resample.py @@ -1,13 +1,20 @@ +""" +=============== +Resampling Data +=============== + +Downsampling lowers the sample rate or sample size of a signal. In this tutorial, the signal is downsampled when the plot is adjusted through dragging and zooming. +""" + import numpy as np import matplotlib.pyplot as plt - # A class that will downsample the data and recompute when zoomed. class DataDisplayDownsampler(object): def __init__(self, xdata, ydata): self.origYData = ydata self.origXData = xdata - self.ratio = 5 + self.ratio = 50 self.delta = xdata[-1] - xdata[0] def downsample(self, xstart, xend): diff --git a/examples/mplot3d/lines3d_demo.py b/examples/mplot3d/lines3d_demo.py index 8e73a301b39c..34ef9328c663 100644 --- a/examples/mplot3d/lines3d_demo.py +++ b/examples/mplot3d/lines3d_demo.py @@ -1,5 +1,9 @@ ''' -Demonstrating plotting a parametric curve in 3D. +================ +Parametric Curve +================ + +This example demonstrates plotting a parametric curve in 3D. ''' import matplotlib as mpl diff --git a/examples/mplot3d/lorenz_attractor.py b/examples/mplot3d/lorenz_attractor.py index 9fceb0af149d..c90b8b9f8fd3 100644 --- a/examples/mplot3d/lorenz_attractor.py +++ b/examples/mplot3d/lorenz_attractor.py @@ -1,6 +1,11 @@ ''' -Plot of the Lorenz Attractor based on Edward Lorenz's 1963 "Deterministic -Nonperiodic Flow" publication. +================ +Lorenz Attractor +================ + +This is an example of plotting Edward Lorenz's 1963 "Deterministic +Nonperiodic Flow" in a 3-dimensional space using mplot3d. + http://journals.ametsoc.org/doi/abs/10.1175/1520-0469%281963%29020%3C0130%3ADNF%3E2.0.CO%3B2 Note: Because this is a simple non-linear ODE, it would be more easily diff --git a/examples/mplot3d/mixed_subplots_demo.py b/examples/mplot3d/mixed_subplots_demo.py index f7788e0add78..f6121a021602 100644 --- a/examples/mplot3d/mixed_subplots_demo.py +++ b/examples/mplot3d/mixed_subplots_demo.py @@ -1,5 +1,8 @@ """ -Demonstrate the mixing of 2d and 3d subplots. +============================================ +Demonstrate the mixing of 2d and 3d subplots +============================================ +This example shows a how to plot a 2D and 3D plot on the same figure. """ from mpl_toolkits.mplot3d import Axes3D diff --git a/examples/mplot3d/offset_demo.py b/examples/mplot3d/offset_demo.py index c4f6d35e021a..da846c8cc26a 100644 --- a/examples/mplot3d/offset_demo.py +++ b/examples/mplot3d/offset_demo.py @@ -1,4 +1,8 @@ ''' +========================= +Automatic Text Offsetting +========================= + This example demonstrates mplot3d's offset text display. As one rotates the 3D figure, the offsets should remain oriented the same way as the axis label, and should also be located "away" diff --git a/examples/pylab_examples/bar_stacked.py b/examples/pylab_examples/bar_stacked.py index 67ef657a8eea..ee2473b90ac0 100755 --- a/examples/pylab_examples/bar_stacked.py +++ b/examples/pylab_examples/bar_stacked.py @@ -1,3 +1,12 @@ +""" +================= +Stacked Bar Graph +================= + +This is an example of creating a stacked bar plot with error bars using `plt.bar`. +Note the parameters `yerr` used for error bars, and `bottom` to stack the women's bars on top of the men's bars. +""" + # a stacked bar plot with errorbars import numpy as np import matplotlib.pyplot as plt diff --git a/examples/pylab_examples/dolphin.py b/examples/pylab_examples/dolphin.py index 3e876180589f..25f1de509b7a 100644 --- a/examples/pylab_examples/dolphin.py +++ b/examples/pylab_examples/dolphin.py @@ -1,3 +1,11 @@ +""" +======= +Dophins +======= + +This example shows how to draw, and manipulate shapes given verticies and nodes using the patches, path and transforms classes. +""" + import matplotlib.cm as cm import matplotlib.pyplot as plt from matplotlib.patches import Circle, PathPatch diff --git a/examples/pylab_examples/fill_between_demo.py b/examples/pylab_examples/fill_between_demo.py index b3653e456ce5..a338b197216f 100644 --- a/examples/pylab_examples/fill_between_demo.py +++ b/examples/pylab_examples/fill_between_demo.py @@ -1,3 +1,11 @@ +""" +============================== +Filling the area between lines +============================== + +This example shows how to use fill_between() to color between lines based on user-defined logic. +""" + import matplotlib.pyplot as plt import numpy as np diff --git a/examples/pylab_examples/geo_demo.py b/examples/pylab_examples/geo_demo.py index 9ef96b2b564c..b9df747af7cb 100644 --- a/examples/pylab_examples/geo_demo.py +++ b/examples/pylab_examples/geo_demo.py @@ -1,3 +1,12 @@ +""" +====================== +Geographic Projections +====================== + +This shows 4 possible projections using subplot. +Matplotlib also supports the Basemaps Toolkit for geographic projections. +""" + import matplotlib.pyplot as plt plt.figure() diff --git a/examples/pylab_examples/log_test.py b/examples/pylab_examples/log_test.py index 0aa2a410ee8b..7b6b4253ddcd 100644 --- a/examples/pylab_examples/log_test.py +++ b/examples/pylab_examples/log_test.py @@ -1,3 +1,11 @@ +""" +======== +Log Axis +======== + +This is an example of assigning a log-scale for the x-axis using `semilogx`. +""" + import matplotlib.pyplot as plt import numpy as np diff --git a/examples/pylab_examples/mri_demo.py b/examples/pylab_examples/mri_demo.py index 0840e5222f46..372246068381 100755 --- a/examples/pylab_examples/mri_demo.py +++ b/examples/pylab_examples/mri_demo.py @@ -1,4 +1,11 @@ -"""Displays an MRI image.""" +""" +=== +MRI +=== + +This example illustrates how to read an image (of an MRI) into a numpy array, and display it in greyscale using `ax.imshow`. + +""" import matplotlib.pyplot as plt import matplotlib.cbook as cbook diff --git a/examples/text_labels_and_annotations/rainbow_text.py b/examples/text_labels_and_annotations/rainbow_text.py index 95142175ce3d..186362b4bc52 100644 --- a/examples/text_labels_and_annotations/rainbow_text.py +++ b/examples/text_labels_and_annotations/rainbow_text.py @@ -1,5 +1,9 @@ # -*- coding: utf-8 -*- """ +========================= +Selective Text Coloration +========================= + The example shows how to string together several text objects. HISTORY From b8e69d499b366e6cc4123a20dda609464140431c Mon Sep 17 00:00:00 2001 From: Leon Yin Date: Mon, 6 Mar 2017 18:49:56 -0800 Subject: [PATCH 2/4] DOC FIX reviewer's comments --- examples/axisartist/demo_axisline_style.py | 6 +++--- examples/event_handling/pipong.py | 6 ++++-- examples/event_handling/poly_editor.py | 3 +-- examples/event_handling/resample.py | 6 ++++-- examples/mplot3d/mixed_subplots_demo.py | 1 + examples/pylab_examples/bar_stacked.py | 5 +++-- examples/pylab_examples/dolphin.py | 9 +++++---- examples/pylab_examples/fill_between_demo.py | 3 ++- examples/pylab_examples/geo_demo.py | 5 ++++- examples/pylab_examples/mri_demo.py | 3 ++- 10 files changed, 29 insertions(+), 18 deletions(-) diff --git a/examples/axisartist/demo_axisline_style.py b/examples/axisartist/demo_axisline_style.py index 6c21987a8052..7823e9c52b12 100644 --- a/examples/axisartist/demo_axisline_style.py +++ b/examples/axisartist/demo_axisline_style.py @@ -1,6 +1,6 @@ """ ================ -Axis Line Styles +Axis line styles ================ This example shows some configurations for axis style. @@ -18,12 +18,12 @@ for direction in ["xzero", "yzero"]: # adds arrows at the ends of each axis ax.axis[direction].set_axisline_style("-|>") - + # adds X and Y-axis from the origin ax.axis[direction].set_visible(True) for direction in ["left", "right", "bottom", "top"]: - # hides boarders + # hides borders ax.axis[direction].set_visible(False) x = np.linspace(-0.5, 1., 100) diff --git a/examples/event_handling/pipong.py b/examples/event_handling/pipong.py index 06307d57561c..8f0318adb3a1 100755 --- a/examples/event_handling/pipong.py +++ b/examples/event_handling/pipong.py @@ -1,9 +1,11 @@ """ ==== -PONG +Pong ==== -A matplotlib based game of Pong illustrating one way to write interactive animation which are easily ported to multiple backends pipong.py was written by Paul Ivanov +A Matplotlib based game of Pong illustrating one way to write interactive +animations which are easily ported to multiple backends pipong.py was written +by Paul Ivanov. """ from __future__ import print_function diff --git a/examples/event_handling/poly_editor.py b/examples/event_handling/poly_editor.py index 09e9ee2fc451..86397626b037 100644 --- a/examples/event_handling/poly_editor.py +++ b/examples/event_handling/poly_editor.py @@ -4,8 +4,7 @@ ========== This is an example to show how to build cross-GUI applications using -matplotlib event handling to interact with objects on the canvas - +matplotlib event handling to interact with objects on the canvas. """ import numpy as np from matplotlib.lines import Line2D diff --git a/examples/event_handling/resample.py b/examples/event_handling/resample.py index d1b1654f1b30..cd6b62505b7f 100644 --- a/examples/event_handling/resample.py +++ b/examples/event_handling/resample.py @@ -3,7 +3,9 @@ Resampling Data =============== -Downsampling lowers the sample rate or sample size of a signal. In this tutorial, the signal is downsampled when the plot is adjusted through dragging and zooming. +Downsampling lowers the sample rate or sample size of a signal. In this +tutorial, the signal is downsampled when the plot is adjusted through dragging +and zooming. """ import numpy as np @@ -14,7 +16,7 @@ class DataDisplayDownsampler(object): def __init__(self, xdata, ydata): self.origYData = ydata self.origXData = xdata - self.ratio = 50 + self.ratio = 5 self.delta = xdata[-1] - xdata[0] def downsample(self, xstart, xend): diff --git a/examples/mplot3d/mixed_subplots_demo.py b/examples/mplot3d/mixed_subplots_demo.py index f6121a021602..6416711903d3 100644 --- a/examples/mplot3d/mixed_subplots_demo.py +++ b/examples/mplot3d/mixed_subplots_demo.py @@ -2,6 +2,7 @@ ============================================ Demonstrate the mixing of 2d and 3d subplots ============================================ + This example shows a how to plot a 2D and 3D plot on the same figure. """ diff --git a/examples/pylab_examples/bar_stacked.py b/examples/pylab_examples/bar_stacked.py index ee2473b90ac0..9bf90cce8c08 100755 --- a/examples/pylab_examples/bar_stacked.py +++ b/examples/pylab_examples/bar_stacked.py @@ -3,8 +3,9 @@ Stacked Bar Graph ================= -This is an example of creating a stacked bar plot with error bars using `plt.bar`. -Note the parameters `yerr` used for error bars, and `bottom` to stack the women's bars on top of the men's bars. +This is an example of creating a stacked bar plot with error bars using +`plt.bar`. Note the parameters `yerr` used for error bars, and `bottom` +to stack the women's bars on top of the men's bars. """ # a stacked bar plot with errorbars diff --git a/examples/pylab_examples/dolphin.py b/examples/pylab_examples/dolphin.py index 25f1de509b7a..cbdc1691536f 100644 --- a/examples/pylab_examples/dolphin.py +++ b/examples/pylab_examples/dolphin.py @@ -1,9 +1,10 @@ """ -======= -Dophins -======= +======== +Dolphins +======== -This example shows how to draw, and manipulate shapes given verticies and nodes using the patches, path and transforms classes. +This example shows how to draw, and manipulate shapes given vertices and nodes +using the `patches`, `path` and `transforms` classes. """ import matplotlib.cm as cm diff --git a/examples/pylab_examples/fill_between_demo.py b/examples/pylab_examples/fill_between_demo.py index a338b197216f..2b065ed42f60 100644 --- a/examples/pylab_examples/fill_between_demo.py +++ b/examples/pylab_examples/fill_between_demo.py @@ -3,7 +3,8 @@ Filling the area between lines ============================== -This example shows how to use fill_between() to color between lines based on user-defined logic. +This example shows how to use `fill_between` to color between lines based on +user-defined logic. """ import matplotlib.pyplot as plt diff --git a/examples/pylab_examples/geo_demo.py b/examples/pylab_examples/geo_demo.py index b9df747af7cb..ebca23272d76 100644 --- a/examples/pylab_examples/geo_demo.py +++ b/examples/pylab_examples/geo_demo.py @@ -4,7 +4,10 @@ ====================== This shows 4 possible projections using subplot. -Matplotlib also supports the Basemaps Toolkit for geographic projections. +Matplotlib also supports +Basemaps Toolkit and +Cartopy +for geographic projections. """ import matplotlib.pyplot as plt diff --git a/examples/pylab_examples/mri_demo.py b/examples/pylab_examples/mri_demo.py index 372246068381..a240ab45c233 100755 --- a/examples/pylab_examples/mri_demo.py +++ b/examples/pylab_examples/mri_demo.py @@ -3,7 +3,8 @@ MRI === -This example illustrates how to read an image (of an MRI) into a numpy array, and display it in greyscale using `ax.imshow`. +This example illustrates how to read an image (of an MRI) into a NumPy array, +and display it in greyscale using `imshow`. """ From bfee1f975a683995b048e3e88023e7add7cd5a92 Mon Sep 17 00:00:00 2001 From: Nelle Varoquaux Date: Fri, 10 Mar 2017 15:01:19 -0800 Subject: [PATCH 3/4] FIX blank space issue for pep8 --- examples/event_handling/resample.py | 1 + examples/pylab_examples/geo_demo.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/event_handling/resample.py b/examples/event_handling/resample.py index cd6b62505b7f..84ba3ee6539b 100644 --- a/examples/event_handling/resample.py +++ b/examples/event_handling/resample.py @@ -11,6 +11,7 @@ import numpy as np import matplotlib.pyplot as plt + # A class that will downsample the data and recompute when zoomed. class DataDisplayDownsampler(object): def __init__(self, xdata, ydata): diff --git a/examples/pylab_examples/geo_demo.py b/examples/pylab_examples/geo_demo.py index ebca23272d76..21859314ddae 100644 --- a/examples/pylab_examples/geo_demo.py +++ b/examples/pylab_examples/geo_demo.py @@ -6,7 +6,7 @@ This shows 4 possible projections using subplot. Matplotlib also supports Basemaps Toolkit and -Cartopy +Cartopy for geographic projections. """ From 0374b18ce8577222d77b48fd3d21b27c77478635 Mon Sep 17 00:00:00 2001 From: Nelle Varoquaux Date: Sat, 11 Mar 2017 17:14:45 -0800 Subject: [PATCH 4/4] DOC fixed title of poly_editor example --- examples/event_handling/poly_editor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/event_handling/poly_editor.py b/examples/event_handling/poly_editor.py index 86397626b037..045d85aa517d 100644 --- a/examples/event_handling/poly_editor.py +++ b/examples/event_handling/poly_editor.py @@ -1,7 +1,7 @@ """ =========== Poly Editor -========== +=========== This is an example to show how to build cross-GUI applications using matplotlib event handling to interact with objects on the canvas.