Skip to content

Move some examples out of pylab_examples #8633

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 2 commits into from
May 29, 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
5 changes: 1 addition & 4 deletions doc/users/prev_whats_new/whats_new_1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ indexing (starts with 0). e.g.::
fig, axarr = plt.subplots(2, 2)
axarr[0,0].plot([1,2,3]) # upper, left

See :ref:`sphx_glr_gallery_pylab_examples_subplot_demo.py` for several code examples.
See :ref:`sphx_glr_gallery_subplots_axes_and_figures_subplot_demo.py` for several code examples.

Contour fixes and and triplot
---------------------------------
Expand Down Expand Up @@ -147,6 +147,3 @@ Eric Firing went on a bug fixing and closing marathon, closing over
<http://sourceforge.net/tracker/?group_id=80706&atid=560720>`__ with
help from Jae-Joon Lee, Michael Droettboom, Christoph Gohlke and
Michiel de Hoon.



7 changes: 2 additions & 5 deletions doc/users/prev_whats_new/whats_new_1.5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ quads touching the point; any triangular corners comprising three unmasked
points are contoured as usual. If the ``corner_mask`` keyword argument is not
specified, the default value is taken from rcParams.

.. figure:: ../../gallery/pylab_examples/images/sphx_glr_contour_corner_mask_001.png
:target: ../../gallery/pylab_examples/contour_corner_mask.html
.. figure:: ../../gallery/images_contours_and_fields/images/sphx_glr_contour_corner_mask_001.png
:target: ../../gallery/images_contours_and_fields/contour_corner_mask.html
:align: center
:scale: 50

Expand Down Expand Up @@ -744,6 +744,3 @@ is important if your toolchain is prefixed. This is done in a simpilar
way as setting `CC` or `CXX` before building. An example follows.

export PKG_CONFIG=x86_64-pc-linux-gnu-pkg-config



Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"""
===============
Color By Yvalue
===============
================
Color By y-value
================

Use masked arrays to plot a line with different colors by y-value.
"""
import numpy as np
import matplotlib.pyplot as plt

t = np.arange(0.0, 2.0, 0.01)
s = np.sin(2*np.pi*t)
s = np.sin(2 * np.pi * t)

upper = 0.77
lower = -0.77
Expand All @@ -19,5 +19,6 @@
slower = np.ma.masked_where(s > lower, s)
smiddle = np.ma.masked_where(np.logical_or(s < lower, s > upper), s)

plt.plot(t, smiddle, t, slower, t, supper)
fig, ax = plt.subplots()
ax.plot(t, smiddle, t, slower, t, supper)
plt.show()
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
import matplotlib.pyplot as plt
import numpy as np

plt.subplot(111, facecolor='darkslategray')
#subplot(111, facecolor='#ababab')
t = np.arange(0.0, 2.0, 0.01)
s = np.sin(2*np.pi*t)
plt.plot(t, s, 'C1')
plt.xlabel('time (s)', color='C1')
plt.ylabel('voltage (mV)', color='0.5') # grayscale color
plt.title('About as silly as it gets, folks', color='#afeeee')
s = np.sin(2 * np.pi * t)

fig, ax = plt.subplots(facecolor='darkslategray')
ax.plot(t, s, 'C1')
ax.set_xlabel('time (s)', color='C1')
ax.set_ylabel('voltage (mV)', color='0.5') # grayscale color
ax.set_title('About as silly as it gets, folks', color='#afeeee')

plt.show()
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# Data to plot.
x, y = np.meshgrid(np.arange(7), np.arange(10))
z = np.sin(0.5*x)*np.cos(0.52*y)
z = np.sin(0.5 * x) * np.cos(0.52 * y)

# Mask various z values.
mask = np.zeros_like(z, dtype=np.bool)
Expand All @@ -24,7 +24,7 @@

corner_masks = [False, True]
for i, corner_mask in enumerate(corner_masks):
plt.subplot(1, 2, i+1)
plt.subplot(1, 2, i + 1)
cs = plt.contourf(x, y, z, corner_mask=corner_mask)
plt.contour(cs, colors='k')
plt.title('corner_mask = {0}'.format(corner_mask))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@

"""
import matplotlib.pyplot as plt
from numpy import arange, pi, cos, sin
from numpy.random import rand
import numpy as np

# unit area ellipse
rx, ry = 3., 1.
area = rx * ry * pi
theta = arange(0, 2*pi + 0.01, 0.1)
verts = list(zip(rx/area*cos(theta), ry/area*sin(theta)))
area = rx * ry * np.pi
theta = np.arange(0, 2 * np.pi + 0.01, 0.1)
verts = list(zip(rx / area * np.cos(theta), ry / area * np.sin(theta)))

x, y, s, c = rand(4, 30)
x, y, s, c = np.random.rand(4, 30)
s *= 10**2.

fig, ax = plt.subplots()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
price_data = np.load(datafile)['price_data'].view(np.recarray)
price_data = price_data[-250:] # get the most recent 250 trading days

delta1 = np.diff(price_data.adj_close)/price_data.adj_close[:-1]
delta1 = np.diff(price_data.adj_close) / price_data.adj_close[:-1]

# Marker size in units of points^2
volume = (15 * price_data.volume[:-2] / price_data.volume[0])**2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@

N = 100
r0 = 0.6
x = 0.9*np.random.rand(N)
y = 0.9*np.random.rand(N)
area = np.pi*(10 * np.random.rand(N))**2 # 0 to 10 point radii
x = 0.9 * np.random.rand(N)
y = 0.9 * np.random.rand(N)
area = np.pi * (10 * np.random.rand(N))**2 # 0 to 10 point radii
c = np.sqrt(area)
r = np.sqrt(x*x + y*y)
r = np.sqrt(x * x + y * y)
area1 = np.ma.masked_where(r < r0, area)
area2 = np.ma.masked_where(r >= r0, area)
plt.scatter(x, y, s=area1, marker='^', c=c)
plt.scatter(x, y, s=area2, marker='o', c=c)
# Show the boundary between the regions:
theta = np.arange(0, np.pi/2, 0.01)
plt.plot(r0*np.cos(theta), r0*np.sin(theta))
theta = np.arange(0, np.pi / 2, 0.01)
plt.plot(r0 * np.cos(theta), r0 * np.sin(theta))

plt.show()
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

for N in (20, 100, 1000, 10000, 50000):
tstart = time.time()
x = 0.9*np.random.rand(N)
y = 0.9*np.random.rand(N)
s = 20*np.random.rand(N)
x = 0.9 * np.random.rand(N)
y = 0.9 * np.random.rand(N)
s = 20 * np.random.rand(N)
plt.scatter(x, y, s)
print('%d symbols in %1.2f s' % (N, time.time() - tstart))
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
plt.subplot(323)
plt.scatter(x, y, s=80, c=z, marker=(verts, 0))
# equivalent:
#plt.scatter(x,y,s=80, c=z, marker=None, verts=verts)
# plt.scatter(x, y, s=80, c=z, marker=None, verts=verts)

plt.subplot(324)
plt.scatter(x, y, s=80, c=z, marker=(5, 1))
Expand Down
13 changes: 0 additions & 13 deletions examples/pylab_examples/README

This file was deleted.

12 changes: 6 additions & 6 deletions examples/pylab_examples/barb_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

x = np.linspace(-5, 5, 5)
X, Y = np.meshgrid(x, x)
U, V = 12*X, 12*Y
U, V = 12 * X, 12 * Y

data = [(-1.5, .5, -6, -6),
(1, -1, -46, 46),
Expand All @@ -27,29 +27,29 @@
ax.barbs(X, Y, U, V)

# Arbitrary set of vectors, make them longer and change the pivot point
#(point around which they're rotated) to be the middle
# (point around which they're rotated) to be the middle
ax = plt.subplot(2, 2, 2)
ax.barbs(data['x'], data['y'], data['u'], data['v'], length=8, pivot='middle')

# Showing colormapping with uniform grid. Fill the circle for an empty barb,
# don't round the values, and change some of the size parameters
ax = plt.subplot(2, 2, 3)
ax.barbs(X, Y, U, V, np.sqrt(U*U + V*V), fill_empty=True, rounding=False,
ax.barbs(X, Y, U, V, np.sqrt(U * U + V * V), fill_empty=True, rounding=False,
sizes=dict(emptybarb=0.25, spacing=0.2, height=0.3))

# Change colors as well as the increments for parts of the barbs
ax = plt.subplot(2, 2, 4)
ax.barbs(data['x'], data['y'], data['u'], data['v'], flagcolor='r',
barbcolor=['b', 'g'], barb_increments=dict(half=10, full=20, flag=100),
flip_barb=True)
barbcolor=['b', 'g'],
barb_increments=dict(half=10, full=20, flag=100), flip_barb=True)

# Masked arrays are also supported
masked_u = np.ma.masked_array(data['u'])
masked_u[4] = 1000 # Bad value that should not be plotted when masked
masked_u[4] = np.ma.masked

# Identical plot to panel 2 in the first figure, but with the point at
#(0.5, 0.25) missing (masked)
# (0.5, 0.25) missing (masked)
fig2 = plt.figure()
ax = fig2.add_subplot(1, 1, 1)
ax.barbs(data['x'], data['y'], masked_u, data['v'], length=8, pivot='middle')
Expand Down
2 changes: 1 addition & 1 deletion tutorials/01_introductory/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def f(t):
# which allows you to specify the location as ``axes([left, bottom,
# width, height])`` where all values are in fractional (0 to 1)
# coordinates. See :ref:`sphx_glr_gallery_pylab_examples_axes_demo.py` for an example of
# placing axes manually and :ref:`sphx_glr_gallery_pylab_examples_subplot_demo.py` for an
# placing axes manually and :ref:`sphx_glr_gallery_subplots_axes_and_figures_subplot_demo.py` for an
# example with lots of subplots.
#
#
Expand Down
4 changes: 2 additions & 2 deletions tutorials/01_introductory/sample_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@
trading volume and colors varying with time. Here, the
alpha attribute is used to make semitransparent circle markers.

.. figure:: ../../gallery/pylab_examples/images/sphx_glr_scatter_demo2_001.png
:target: ../../gallery/pylab_examples/scatter_demo2.html
.. figure:: ../../gallery/lines_bars_and_markers/images/sphx_glr_scatter_demo2_001.png
:target: ../../gallery/lines_bars_and_markers/scatter_demo2.html
:align: center
:scale: 50

Expand Down