8000 Doc yinleon rebase by tacaswell · Pull Request #8860 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Doc yinleon rebase #8860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
< 8000 div class="file-header d-flex flex-md-row flex-column flex-md-items-center file-header--expandable js-file-header js-skip-tagsearch sticky-file-header" data-path="examples/axisartist/demo_axisline_style.py" data-short-path="05874c5" data-anchor="diff-05874c59fdd140417b30882c047fe37db1189258ccc7656f7b55ceb9dcd0aeb5" data-file-type=".py" data-file-deleted="false" >
11 changes: 8 additions & 3 deletions examples/axisartist/demo_axisline_style.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""
===================
Demo Axisline Style
===================
================
Axis line styles
================
This example shows some configurations for axis style.
"""

from mpl_toolkits.axisartist.axislines import SubplotZero
Expand All @@ -15,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 borders
ax.axis[direction].set_visible(False)

x = np.linspace(-0.5, 1., 100)
Expand Down
18 changes: 10 additions & 8 deletions examples/event_handling/poly_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -34,17 +33,19 @@ class PolygonInteractor(object):

def __init__(self, ax, poly):
if poly.figure is None:
raise RuntimeError('You must first add the polygon to a figure or canvas before defining the interactor')
raise RuntimeError('You must first add the polygon to a figure '
'or canvas before defining the interactor')
self.ax = ax
canvas = poly.figure.canvas
self.poly = poly

x, y = zip(*self.poly.xy)
self.line = Line2D(x, y, marker='o', markerfacecolor='r', animated=True)
self.line = Line2D(x, y,
marker='o', markerfacecolor='r',
animated=True)
self.ax.add_line(self.line)
#self._update_line(poly)

cid = self.poly.add_callback(self.poly_changed)
self.cid = self.poly.add_callback(self.poly_changed)
self._ind = None # the active vert

canvas.mpl_connect('draw_event', self.draw_callback)
Expand Down Expand Up @@ -113,7 +114,9 @@ def key_press_callback(self, event):
elif event.key == 'd':
ind = self.get_ind_under_point(event)
if ind is not None:
self.poly.xy = [tup for i, tup in enumerate(self.poly.xy) if i != ind]
self.poly.xy = [tup
for i, tup in enumerate(self.poly.xy)
if i != ind]
self.line.set_data(zip(*self.poly.xy))
elif event.key == 'i':
xys = self.poly.get_transform().transform(self.poly.xy)
Expand Down Expand Up @@ -173,7 +176,6 @@ def motion_notify_callback(self, event):
ax.add_patch(poly)
p = PolygonInteractor(ax, poly)

#ax.add_line(p.line)
ax.set_title('Click and drag a point to move it')
ax.set_xlim((-2, 2))
ax.set_ylim((-2, 2))
Expand Down
37 changes: 26 additions & 11 deletions examples/event_handling/resample.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
"""
========
Resample
========
===============
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

Expand All @@ -13,18 +17,28 @@ class DataDisplayDownsampler(object):
def __init__(self, xdata, ydata):
self.origYData = ydata
self.origXData = xdata
self.ratio = 5
self.max_points = 50
self.delta = xdata[-1] - xdata[0]

def downsample(self, xstart, xend):
# Very simple downsampling that takes the points within the range
# and picks every Nth point
# get the points in the view range
mask = (self.origXData > xstart) & (self.origXData < xend)
xdata = self.origXData[mask]
xdata = xdata[::self.ratio]
# dilate the mask by one to catch the points just outside
# of the view range to not truncate the line
mask = np.convolve([1, 1], mask, mode='same').astype(bool)
# sort out how many points to drop
ratio = max(np.sum(mask) // self.max_points, 1)

# mask data
xdata = self.origXData[mask]
ydata = self.origYData[mask]
ydata = ydata[::self.ratio]

# downsample data
xdata = xdata[::ratio]
ydata = ydata[::ratio]

print("using {} of {} visible points".format(
len(ydata), np.sum(mask)))

return xdata, ydata

Expand All @@ -37,8 +51,9 @@ def update(self, ax):
self.line.set_data(*self.downsample(xstart, xend))
ax.figure.canvas.draw_idle()


# Create a signal
xdata = np.linspace(16, 365, 365-16)
xdata = np.linspace(16, 365, (365-16)*4)
ydata = np.sin(2*np.pi*xdata/153) + np.cos(2*np.pi*xdata/127)

d = DataDisplayDownsampler(xdata, ydata)
Expand All @@ -51,5 +66,5 @@ def update(self, ax):

# Connect for changing the view limits
ax.callbacks.connect('xlim_changed', d.update)

ax.set_xlim(16, 365)
plt.show()
8 changes: 4 additions & 4 deletions examples/mplot3d/lines3d.py
6D47
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'''
===================
3D parametric curve
===================
================
Parametric Curve
================
Demonstrating plotting a parametric curve in 3D.
This example demonstrates plotting a parametric curve in 3D.
'''

import matplotlib as mpl
Expand Down
13 changes: 7 additions & 6 deletions examples/mplot3d/lorenz_attractor.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
'''
====================
The Lorenz Attractor
====================
================
Lorenz Attractor
================

Plot of the Lorenz Attractor based on Edward Lorenz's 1963 "Deterministic
Nonperiodic Flow" publication.
http://journals.ametsoc.org/doi/abs/10.1175/1520-0469%281963%29020%3C0130%3ADNF%3E2.0.CO%3B2
This is an example of plotting Edward Lorenz's 1963 `"Deterministic
Nonperiodic Flow"
<http://journals.ametsoc.org/doi/abs/10.1175/1520-0469%281963%29020%3C0130%3ADNF%3E2.0.CO%3B2>`_
in a 3-dimensional space using mplot3d.

Note: Because this is a simple non-linear ODE, it would be more easily
done using SciPy's ode solver, but this approach depends only
Expand Down
9 changes: 4 additions & 5 deletions examples/mplot3d/mixed_subplots.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
"""
==================
2D and 3D subplots
==================
=================================
2D and 3D *Axes* in same *Figure*
=================================

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
import matplotlib.pyplot as plt
import numpy as np
Expand Down
6 changes: 3 additions & 3 deletions examples/mplot3d/offset.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'''
===================
Offset text display
===================
=========================
Automatic Text Offsetting
=========================

This example demonstrates mplot3d's offset text display.
As one rotates the 3D figure, the offsets should remain oriented the
Expand Down
13 changes: 9 additions & 4 deletions examples/pylab_examples/bar_stacked.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
"""
===========
Bar Stacked
===========
=================
Stacked Bar Graph
=================

This is an example of creating a stacked bar plot with error bars
using `~matplotlib.pyplot.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

Expand Down
10 changes: 7 additions & 3 deletions examples/pylab_examples/dolphin.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
"""
=======
Dolphin
=======
========
Dolphins
========

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
import matplotlib.pyplot as plt
from matplotlib.patches import Circle, PathPatch
Expand Down
9 changes: 6 additions & 3 deletions examples/pylab_examples/fill_between_demo.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
"""
=================
Fill Between Demo
=================
==============================
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

Expand Down
11 changes: 8 additions & 3 deletions examples/pylab_examples/geo_demo.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
"""
========
Geo Demo
========
======================
Geographic Projections
======================

This shows 4 possible projections using subplot. Matplotlib also
supports `Basemaps Toolkit <https://matplotlib.org/basemap>`_ and
`Cartopy <http://scitools.org.uk/cartopy>`_ for geographic projections.

"""

import matplotlib.pyplot as plt

plt.figure()
Expand Down
5 changes: 4 additions & 1 deletion examples/pylab_examples/log_test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
"""
========
Log Test
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

Expand Down
12 changes: 7 additions & 5 deletions examples/pylab_examples/mri_demo.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
"""
========
MRI Demo
========
===
MRI
===

Displays an MRI image.
"""

This example illustrates how to read an image (of an MRI) into a NumPy
array, and display it in greyscale using `imshow`.

"""

import matplotlib.pyplot as plt
import matplotlib.cbook as cbook
Expand Down
0