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

Appearance settings

Commit 3ce3835

Browse filesBrowse files
committed
Merge branch 'v2.0.0-doc' into v2.0.x
2 parents 6061a43 + 68d2327 commit 3ce3835
Copy full SHA for 3ce3835
Expand file treeCollapse file tree

18 files changed

+230
-192
lines changed

‎doc/contents.rst

Copy file name to clipboardExpand all lines: doc/contents.rst
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Overview
88
:Release: |version|
99
:Date: |today|
1010

11+
Download `PDF <Matplotlib.pdf>`_
12+
1113

1214
.. toctree::
1315
:maxdepth: 2

‎doc/devel/testing.rst

Copy file name to clipboardExpand all lines: doc/devel/testing.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ a colon, e.g., (this is assuming the test is installed)::
8686
If you want to run the full test suite, but want to save wall time try
8787
running the tests in parallel::
8888

89-
python tests.py --nocapture --nose-verbose --processes=5 --process-timeout=300
89+
python tests.py --nocapture --verbose --processes=5 --process-timeout=300
9090

9191

9292
An alternative implementation that does not look at command line

‎examples/color/color_cycle_default.py

Copy file name to clipboardExpand all lines: examples/color/color_cycle_default.py
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
"""
2+
====================================
3+
Colors in the default property cycle
4+
====================================
5+
26
Display the colors from the default prop_cycle.
37
"""
4-
58
import numpy as np
69
import matplotlib.pyplot as plt
710

11+
812
prop_cycle = plt.rcParams['axes.prop_cycle']
913
colors = prop_cycle.by_key()['color']
1014

‎examples/color/color_cycle_demo.py

Copy file name to clipboardExpand all lines: examples/color/color_cycle_demo.py
+11-5Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,36 @@
11
"""
2-
Demo of custom property-cycle settings to control colors and such
3-
for multi-line plots.
2+
===================
3+
Styling with cycler
4+
===================
5+
6+
Demo of custom property-cycle settings to control colors and other style
7+
properties for multi-line plots.
48
59
This example demonstrates two different APIs:
610
7-
1. Setting the default rc-parameter specifying the property cycle.
11+
1. Setting the default rc parameter specifying the property cycle.
812
This affects all subsequent axes (but not axes already created).
9-
2. Setting the property cycle for a specific axes. This only
10-
affects a single axes.
13+
2. Setting the property cycle for a single pair of axes.
1114
"""
1215
from cycler import cycler
1316
import numpy as np
1417
import matplotlib.pyplot as plt
1518

19+
1620
x = np.linspace(0, 2 * np.pi)
1721
offsets = np.linspace(0, 2*np.pi, 4, endpoint=False)
1822
# Create array with shifted-sine curve along each column
1923
yy = np.transpose([np.sin(x + phi) for phi in offsets])
2024

25+
# 1. Setting prop cycle on default rc parameter
2126
plt.rc('lines', linewidth=4)
2227
plt.rc('axes', prop_cycle=(cycler('color', ['r', 'g', 'b', 'y']) +
2328
cycler('linestyle', ['-', '--', ':', '-.'])))
2429
fig, (ax0, ax1) = plt.subplots(nrows=2)
2530
ax0.plot(yy)
2631
ax0.set_title('Set default color cycle to rgby')
2732

33+
# 2. Define prop cycle for single set of axes
2834
ax1.set_prop_cycle(cycler('color', ['c', 'm', 'y', 'k']) +
2935
cycler('lw', [1, 2, 3, 4]))
3036
ax1.plot(yy)

‎examples/color/colormaps_reference.py

Copy file name to clipboardExpand all lines: examples/color/colormaps_reference.py
+8-3Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
"""
2+
==================
3+
Colormap reference
4+
==================
5+
26
Reference for colormaps included with Matplotlib.
37
48
This reference example shows all colormaps included with Matplotlib. Note that
@@ -35,9 +39,9 @@
3539
import numpy as np
3640
import matplotlib.pyplot as plt
3741

42+
3843
# Have colormaps separated into categories:
3944
# http://matplotlib.org/examples/color/colormaps_reference.html
40-
4145
cmaps = [('Perceptually Uniform Sequential',
4246
['viridis', 'inferno', 'plasma', 'magma']),
4347
('Sequential', ['Blues', 'BuGn', 'BuPu',
@@ -65,7 +69,7 @@
6569
gradient = np.vstack((gradient, gradient))
6670

6771

68-
def plot_color_gradients(cmap_category, cmap_list):
72+
def plot_color_gradients(cmap_category, cmap_list, nrows):
6973
fig, axes = plt.subplots(nrows=nrows)
7074
fig.subplots_adjust(top=0.95, bottom=0.01, left=0.2, right=0.99)
7175
axes[0].set_title(cmap_category + ' colormaps', fontsize=14)
@@ -81,7 +85,8 @@ def plot_color_gradients(cmap_category, cmap_list):
8185
for ax in axes:
8286
ax.set_axis_off()
8387

88+
8489
for cmap_category, cmap_list in cmaps:
85-
plot_color_gradients(cmap_category, cmap_list)
90+
plot_color_gradients(cmap_category, cmap_list, nrows)
8691

8792
plt.show()

‎examples/color/named_colors.py

Copy file name to clipboardExpand all lines: examples/color/named_colors.py
+10-17Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,37 @@
11
"""
2-
Visualization of named colors.
2+
========================
3+
Visualizing named colors
4+
========================
35
46
Simple plot example with the named colors and its visual representation.
57
"""
8+
from __future__ import division
69

7-
from __future__ import (absolute_import, division, print_function,
8-
unicode_literals)
9-
10-
import six
11-
12-
import numpy as np
1310
import matplotlib.pyplot as plt
1411
from matplotlib import colors as mcolors
1512

1613

1714
colors = dict(mcolors.BASE_COLORS, **mcolors.CSS4_COLORS)
1815

19-
# Sort by hue, saturation, value and name.
16+
# Sort colors by hue, saturation, value and name.
2017
by_hsv = sorted((tuple(mcolors.rgb_to_hsv(mcolors.to_rgba(color)[:3])), name)
2118
for name, color in colors.items())
22-
23-
# Get the sorted color names.
2419
sorted_names = [name for hsv, name in by_hsv]
2520

2621
n = len(sorted_names)
2722
ncols = 4
28-
nrows = int(np.ceil(1. * n / ncols))
23+
nrows = n // ncols + 1
2924

3025
fig, ax = plt.subplots(figsize=(8, 5))
3126

27+
# Get height and width
3228
X, Y = fig.get_dpi() * fig.get_size_inches()
33-
34-
# row height
3529
h = Y / (nrows + 1)
36-
# col width
3730
w = X / ncols
3831

3932
for i, name in enumerate(sorted_names):
4033
col = i % ncols
41-
row = int(i / ncols)
34+
row = i // ncols
4235
y = Y - (row * h) - h
4336

4437
xi_line = w * (col + 0.05)
@@ -49,8 +42,8 @@
4942
horizontalalignment='left',
5043
verticalalignment='center')
5144

52-
ax.hlines(
53-
y + h * 0.1, xi_line, xf_line, color=colors[name], linewidth=(h * 0.6))
45+
ax.hlines(y + h * 0.1, xi_line, xf_line,
46+
color=colors[name], linewidth=(h * 0.6))
5447

5548
ax.set_xlim(0, X)
5649
ax.set_ylim(0, Y)

‎examples/misc/multiprocess.py

Copy file name to clipboardExpand all lines: examples/misc/multiprocess.py
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ def main():
7979
for ii in range(10):
8080
pl.plot()
8181
time.sleep(0.5)
82-
raw_input('press Enter...')
82+
try:
83+
input = raw_input
84+
except NameError:
85+
pass
86+
input('press Enter...')
8387
pl.plot(finished=True)
8488

8589
if __name__ == '__main__':

‎examples/pie_and_polar_charts/pie_demo_features.py

Copy file name to clipboardExpand all lines: examples/pie_and_polar_charts/pie_demo_features.py
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
"""
2+
===============
3+
Basic pie chart
4+
===============
5+
26
Demo of a basic pie chart plus a few additional features.
37
48
In addition to the basic pie chart, this demo shows a few optional features:

‎examples/pie_and_polar_charts/polar_bar_demo.py

Copy file name to clipboardExpand all lines: examples/pie_and_polar_charts/polar_bar_demo.py
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
"""
2+
=======================
3+
Pie chart on polar axis
4+
=======================
5+
26
Demo of bar plot on a polar axis.
37
"""
48
import numpy as np
59
import matplotlib.pyplot as plt
610

711

12+
# Compute pie slices
813
N = 20
914
theta = np.linspace(0.0, 2 * np.pi, N, endpoint=False)
1015
radii = 10 * np.random.rand(N)
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
"""
2+
==========================
3+
Scatter plot on polar axis
4+
==========================
5+
26
Demo of scatter plot on a polar axis.
37
48
Size increases radially in this example and color increases with angle
@@ -8,14 +12,14 @@
812
import matplotlib.pyplot as plt
913

1014

15+
# Compute areas and colors
1116
N = 150
1217
r = 2 * np.random.rand(N)
1318
theta = 2 * np.pi * np.random.rand(N)
1419
area = 200 * r**2
1520
colors = theta
1621

1722
ax = plt.subplot(111, projection='polar')
18-
c = ax.scatter(theta, r, c=colors, s=area, cmap=plt.cm.hsv)
19-
c.set_alpha(0.75)
23+
c = ax.scatter(theta, r, c=colors, s=area, cmap='hsv', alpha=0.75)
2024

2125
plt.show()
+16-70Lines changed: 16 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
'''
2-
Demonstration of quiver and quiverkey functions. This is using the
3-
new version coming from the code in quiver.py.
2+
========================================================
3+
Demonstration of advanced quiver and quiverkey functions
4+
========================================================
45
56
Known problem: the plot autoscaling does not take into account
67
the arrows, so those on the boundaries are often out of the picture.
78
This is *not* an easy problem to solve in a perfectly general way.
89
The workaround is to manually expand the axes.
9-
1010
'''
1111
import matplotlib.pyplot as plt
1212
import numpy as np
@@ -16,81 +16,27 @@
1616
U = np.cos(X)
1717
V = np.sin(Y)
1818

19-
# 1
20-
plt.figure()
21-
Q = plt.quiver(U, V)
22-
qk = plt.quiverkey(Q, 0.5, 0.98, 2, r'$2 \frac{m}{s}$', labelpos='W',
23-
fontproperties={'weight': 'bold'})
24-
l, r, b, t = plt.axis()
25-
dx, dy = r - l, t - b
26-
plt.axis([l - 0.05*dx, r + 0.05*dx, b - 0.05*dy, t + 0.05*dy])
27-
28-
plt.title('Minimal arguments, no kwargs')
29-
30-
# 2
3119
plt.figure()
20+
plt.title('Arrows scale with plot width, not view')
3221
Q = plt.quiver(X, Y, U, V, units='width')
33-
qk = plt.quiverkey(Q, 0.9, 0.95, 2, r'$2 \frac{m}{s}$',
34-
labelpos='E',
35-
coordinates='figure',
36-
fontproperties={'weight': 'bold'})
37-
plt.axis([-1, 7, -1, 7])
38-
plt.title('scales with plot width, not view')
22+
qk = plt.quiverkey(Q, 0.9, 0.9, 2, r'$2 \frac{m}{s}$', labelpos='E',
23+
coordinates='figure')
3924

40-
# 3
4125
plt.figure()
42-
Q = plt.quiver(X[::3, ::3], Y[::3, ::3], U[::3, ::3], V[::3, ::3],
43-
pivot='mid', color='r', units='inches')
44-
qk = plt.quiverkey(Q, 0.5, 0.03, 1, r'$1 \frac{m}{s}$',
45-
fontproperties={'weight': 'bold'})
46-
plt.plot(X[::3, ::3], Y[::3, ::3], 'k.')
47-
plt.axis([-1, 7, -1, 7])
4826
plt.title("pivot='mid'; every third arrow; units='inches'")
27+
Q = plt.quiver(X[::3, ::3], Y[::3, ::3], U[::3, ::3], V[::3, ::3],
28+
pivot='mid', units='inches')
29+
qk = plt.quiverkey(Q, 0.9, 0.9, 1, r'$1 \frac{m}{s}$', labelpos='E',
30+
coordinates='figure')
31+
plt.scatter(X[::3, ::3], Y[::3, ::3], color='r', s=5)
4932

50-
# 4
5133
plt.figure()
34+
plt.title("pivot='tip'; scales with x view")
5235
M = np.hypot(U, V)
53-
Q = plt.quiver(X, Y, U, V, M,
54-
units='x',
55-
pivot='tip',
56-
width=0.022,
36+
Q = plt.quiver(X, Y, U, V, M, units='x', pivot='tip', width=0.022,
5737
scale=1 / 0.15)
58-
qk = plt.quiverkey(Q, 0.9, 1.05, 1, r'$1 \frac{m}{s}$',
59-
labelpos='E',
60-
fontproperties={'weight': 'bold'})
61-
plt.plot(X, Y, 'k.', markersize=2)
62-
plt.axis([-1, 7, -1, 7])
63-
plt.title("scales with x view; pivot='tip'")
64-
65-
# 5
66-
plt.figure()
67-
Q = plt.quiver(X[::3, ::3], Y[::3, ::3], U[::3, ::3], V[::3, ::3],
68-
color='r', units='x',
69-
linewidths=(0.5,), edgecolors=('k'), headaxislength=5)
70-
qk = plt.quiverkey(Q, 0.5, 0.03, 1, r'$1 \frac{m}{s}$',
71-
fontproperties={'weight': 'bold'})
72-
plt.axis([-1, 7, -1, 7])
73-
plt.title("triangular head; scale with x view; black edges")
74-
75-
# 6
76-
plt.figure()
77-
M = np.zeros(U.shape, dtype='bool')
78-
XMaskStart = U.shape[0]//3
79-
YMaskStart = U.shape[1]//3
80-
XMaskStop = 2*U.shape[0]//3
81-
YMaskStop = 2*U.shape[1]//3
82-
83-
M[XMaskStart:XMaskStop,
84-
YMaskStart:YMaskStop] = True
85-
U = ma.masked_array(U, mask=M)
86-
V = ma.masked_array(V, mask=M)
87-
Q = plt.quiver(U, V)
88-
qk = plt.quiverkey(Q, 0.5, 0.98, 2, r'$2 \frac{m}{s}$', labelpos='W',
89-
fontproperties={'weight': 'bold'})
90-
l, r, b, t = plt.axis()
91-
dx, dy = r - l, t - b
92-
plt.axis([l - 0.05 * dx, r + 0.05 * dx, b - 0.05 * dy, t + 0.05 * dy])
93-
plt.title('Minimal arguments, no kwargs - masked values')
94-
38+
qk = plt.quiverkey(Q, 0.9, 0.9, 1, r'$1 \frac{m}{s}$', labelpos='E',
39+
coordinates='figure')
40+
plt.scatter(X, Y, color='k', s=5)
9541

9642
plt.show()
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'''
2+
==================================================
3+
A simple example of a quiver plot with a quiverkey
4+
==================================================
5+
'''
6+
import matplotlib.pyplot as plt
7+
import numpy as np
8+
9+
X = np.arange(-10, 10, 1)
10+
Y = np.arange(-10, 10, 1)
11+
U, V = np.meshgrid(X, Y)
12+
13+
fig, ax = plt.subplots()
14+
q = ax.quiver(X, Y, U, V)
15+
ax.quiverkey(q, X=0.3, Y=1.1, U=10,
16+
label='Quiver key, length = 10', labelpos='E')
17+
18+
plt.show()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.