Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit30cdd23

Browse files
authored
Merge pull request#8860 from tacaswell/doc_yinleon_rebase
Doc yinleon rebase
2 parents8e517d8 +20b6309 commit30cdd23

13 files changed

+103
-59
lines changed

‎examples/axisartist/demo_axisline_style.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"""
2-
===================
3-
Demo Axisline Style
4-
===================
2+
================
3+
Axis line styles
4+
================
55
6+
This example shows some configurations for axis style.
67
"""
78

89
frommpl_toolkits.axisartist.axislinesimportSubplotZero
@@ -15,10 +16,14 @@
1516
fig.add_subplot(ax)
1617

1718
fordirectionin ["xzero","yzero"]:
19+
# adds arrows at the ends of each axis
1820
ax.axis[direction].set_axisline_style("-|>")
21+
22+
# adds X and Y-axis from the origin
1923
ax.axis[direction].set_visible(True)
2024

2125
fordirectionin ["left","right","bottom","top"]:
26+
# hides borders
2227
ax.axis[direction].set_visible(False)
2328

2429
x=np.linspace(-0.5,1.,100)

‎examples/event_handling/poly_editor.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
===========
55
66
This is an example to show how to build cross-GUI applications using
7-
matplotlib event handling to interact with objects on the canvas
8-
7+
Matplotlib event handling to interact with objects on the canvas.
98
"""
109
importnumpyasnp
1110
frommatplotlib.linesimportLine2D
@@ -34,17 +33,19 @@ class PolygonInteractor(object):
3433

3534
def__init__(self,ax,poly):
3635
ifpoly.figureisNone:
37-
raiseRuntimeError('You must first add the polygon to a figure or canvas before defining the interactor')
36+
raiseRuntimeError('You must first add the polygon to a figure '
37+
'or canvas before defining the interactor')
3838
self.ax=ax
3939
canvas=poly.figure.canvas
4040
self.poly=poly
4141

4242
x,y=zip(*self.poly.xy)
43-
self.line=Line2D(x,y,marker='o',markerfacecolor='r',animated=True)
43+
self.line=Line2D(x,y,
44+
marker='o',markerfacecolor='r',
45+
animated=True)
4446
self.ax.add_line(self.line)
45-
#self._update_line(poly)
4647

47-
cid=self.poly.add_callback(self.poly_changed)
48+
self.cid=self.poly.add_callback(self.poly_changed)
4849
self._ind=None# the active vert
4950

5051
canvas.mpl_connect('draw_event',self.draw_callback)
@@ -113,7 +114,9 @@ def key_press_callback(self, event):
113114
elifevent.key=='d':
114115
ind=self.get_ind_under_point(event)
115116
ifindisnotNone:
116-
self.poly.xy= [tupfori,tupinenumerate(self.poly.xy)ifi!=ind]
117+
self.poly.xy= [tup
118+
fori,tupinenumerate(self.poly.xy)
119+
ifi!=ind]
117120
self.line.set_data(zip(*self.poly.xy))
118121
elifevent.key=='i':
119122
xys=self.poly.get_transform().transform(self.poly.xy)
@@ -173,7 +176,6 @@ def motion_notify_callback(self, event):
173176
ax.add_patch(poly)
174177
p=PolygonInteractor(ax,poly)
175178

176-
#ax.add_line(p.line)
177179
ax.set_title('Click and drag a point to move it')
178180
ax.set_xlim((-2,2))
179181
ax.set_ylim((-2,2))

‎examples/event_handling/resample.py

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
"""
2-
========
3-
Resample
4-
========
2+
===============
3+
Resampling Data
4+
===============
55
6+
Downsampling lowers the sample rate or sample size of a signal. In
7+
this tutorial, the signal is downsampled when the plot is adjusted
8+
through dragging and zooming.
69
"""
10+
711
importnumpyasnp
812
importmatplotlib.pyplotasplt
913

@@ -13,18 +17,28 @@ class DataDisplayDownsampler(object):
1317
def__init__(self,xdata,ydata):
1418
self.origYData=ydata
1519
self.origXData=xdata
16-
self.ratio=5
20+
self.max_points=50
1721
self.delta=xdata[-1]-xdata[0]
1822

1923
defdownsample(self,xstart,xend):
20-
# Very simple downsampling that takes the points within the range
21-
# and picks every Nth point
24+
# get the points in the view range
2225
mask= (self.origXData>xstart)& (self.origXData<xend)
23-
xdata=self.origXData[mask]
24-
xdata=xdata[::self.ratio]
26+
# dilate the mask by one to catch the points just outside
27+
# of the view range to not truncate the line
28+
mask=np.convolve([1,1],mask,mode='same').astype(bool)
29+
# sort out how many points to drop
30+
ratio=max(np.sum(mask)//self.max_points,1)
2531

32+
# mask data
33+
xdata=self.origXData[mask]
2634
ydata=self.origYData[mask]
27-
ydata=ydata[::self.ratio]
35+
36+
# downsample data
37+
xdata=xdata[::ratio]
38+
ydata=ydata[::ratio]
39+
40+
print("using {} of {} visible points".format(
41+
len(ydata),np.sum(mask)))
2842

2943
returnxdata,ydata
3044

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

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

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

5267
# Connect for changing the view limits
5368
ax.callbacks.connect('xlim_changed',d.update)
54-
69+
ax.set_xlim(16,365)
5570
plt.show()

‎examples/mplot3d/lines3d.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'''
2-
===================
3-
3D parametric curve
4-
===================
2+
================
3+
Parametric Curve
4+
================
55
6-
Demonstrating plotting a parametric curve in 3D.
6+
This example demonstrates plotting a parametric curve in 3D.
77
'''
88

99
importmatplotlibasmpl

‎examples/mplot3d/lorenz_attractor.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
'''
2-
====================
3-
TheLorenz Attractor
4-
====================
2+
================
3+
Lorenz Attractor
4+
================
55
6-
Plot of the Lorenz Attractor based on Edward Lorenz's 1963 "Deterministic
7-
Nonperiodic Flow" publication.
8-
http://journals.ametsoc.org/doi/abs/10.1175/1520-0469%281963%29020%3C0130%3ADNF%3E2.0.CO%3B2
6+
This is an example of plotting Edward Lorenz's 1963 `"Deterministic
7+
Nonperiodic Flow"
8+
<http://journals.ametsoc.org/doi/abs/10.1175/1520-0469%281963%29020%3C0130%3ADNF%3E2.0.CO%3B2>`_
9+
in a 3-dimensional space using mplot3d.
910
1011
Note: Because this is a simple non-linear ODE, it would be more easily
1112
done using SciPy's ode solver, but this approach depends only

‎examples/mplot3d/mixed_subplots.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
"""
2-
==================
3-
2D and 3Dsubplots
4-
==================
2+
=================================
3+
2D and 3D*Axes* in same *Figure*
4+
=================================
55
6-
Demonstrate the mixing of 2dand3d subplots.
6+
This example shows a how to plot a 2Dand3D plot on the same figure.
77
"""
8-
98
frommpl_toolkits.mplot3dimportAxes3D
109
importmatplotlib.pyplotasplt
1110
importnumpyasnp

‎examples/mplot3d/offset.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'''
2-
===================
3-
Offset text display
4-
===================
2+
=========================
3+
Automatic Text Offsetting
4+
=========================
55
66
This example demonstrates mplot3d's offset text display.
77
As one rotates the 3D figure, the offsets should remain oriented the

‎examples/pylab_examples/bar_stacked.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
"""
2-
===========
3-
Bar Stacked
4-
===========
2+
=================
3+
Stacked Bar Graph
4+
=================
5+
6+
This is an example of creating a stacked bar plot with error bars
7+
using `~matplotlib.pyplot.bar`. Note the parameters *yerr* used for
8+
error bars, and *bottom* to stack the women's bars on top of the men's
9+
bars.
510
6-
A stacked bar plot with errorbars.
711
"""
12+
813
importnumpyasnp
914
importmatplotlib.pyplotasplt
1015

‎examples/pylab_examples/dolphin.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
"""
2-
=======
3-
Dolphin
4-
=======
2+
========
3+
Dolphins
4+
========
5+
6+
This example shows how to draw, and manipulate shapes given vertices
7+
and nodes using the `Patches`, `Path` and `Transforms` classes.
58
69
"""
10+
711
importmatplotlib.cmascm
812
importmatplotlib.pyplotasplt
913
frommatplotlib.patchesimportCircle,PathPatch

‎examples/pylab_examples/fill_between_demo.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
"""
2-
=================
3-
Fill Between Demo
4-
=================
2+
==============================
3+
Filling the area between lines
4+
==============================
55
6+
This example shows how to use `fill_between` to color between lines based on
7+
user-defined logic.
68
"""
9+
710
importmatplotlib.pyplotasplt
811
importnumpyasnp
912

‎examples/pylab_examples/geo_demo.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
"""
2-
========
3-
Geo Demo
4-
========
2+
======================
3+
Geographic Projections
4+
======================
5+
6+
This shows 4 possible projections using subplot. Matplotlib also
7+
supports `Basemaps Toolkit <https://matplotlib.org/basemap>`_ and
8+
`Cartopy <http://scitools.org.uk/cartopy>`_ for geographic projections.
59
610
"""
11+
712
importmatplotlib.pyplotasplt
813

914
plt.figure()

‎examples/pylab_examples/log_test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
"""
22
========
3-
LogTest
3+
LogAxis
44
========
55
6+
This is an example of assigning a log-scale for the x-axis using
7+
`semilogx`.
68
"""
9+
710
importmatplotlib.pyplotasplt
811
importnumpyasnp
912

‎examples/pylab_examples/mri_demo.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
"""
2-
========
3-
MRI Demo
4-
========
2+
===
3+
MRI
4+
===
55
6-
Displays an MRI image.
7-
"""
86
7+
This example illustrates how to read an image (of an MRI) into a NumPy
8+
array, and display it in greyscale using `imshow`.
9+
10+
"""
911

1012
importmatplotlib.pyplotasplt
1113
importmatplotlib.cbookascbook

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp