8000 Cleanup of merged pylab examples by QuLogic · Pull Request #8677 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Cleanup of merged pylab examples #8677

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 5 commits into from
May 31, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Use standard NumPy import in pylab examples.
  • Loading branch information
QuLogic committed May 29, 2017
commit e53876ae5a66c29160aceab46f468e289d28a8e0
9 changes: 5 additions & 4 deletions examples/animation/image_slices_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

"""
from __future__ import print_function
import numpy

import numpy as np
import matplotlib.pyplot as plt


Expand All @@ -24,9 +25,9 @@ def __init__(self, ax, X):
def onscroll(self, event):
print("%s %s" % (event.button, event.step))
if event.button == 'up':
self.ind = numpy.clip(self.ind + 1, 0, self.slices - 1)
self.ind = np.clip(self.ind + 1, 0, self.slices - 1)
else:
self.ind = numpy.clip(self.ind - 1, 0, self.slices - 1)
self.ind = np.clip(self.ind - 1, 0, self.slices - 1)
self.update()

def update(self):
Expand All @@ -37,7 +38,7 @@ def update(self):

fig, ax = plt.subplots(1, 1)

X = numpy.random.rand(20, 20, 40)
X = np.random.rand(20, 20, 40)

tracker = IndexTracker(ax, X)

Expand Down
8 changes: 4 additions & 4 deletions examples/event_handling/pick_event_demo2.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
mean vs stddev. When you click on one of the mu, sigma points, plot the raw
data from the dataset that generated the mean and stddev.
"""
import numpy
import numpy as np
import matplotlib.pyplot as plt


X = numpy.random.rand(100, 1000)
xs = numpy.mean(X, axis=1)
ys = numpy.std(X, axis=1)
X = np.random.rand(100, 1000)
xs = np.mean(X, axis=1)
ys = np.std(X, axis=1)

fig, ax = plt.subplots()
ax.set_title('click on point to plot time series')
Expand Down
4 changes: 2 additions & 2 deletions examples/event_handling/zoom_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
points**2, so their size is independent of the zoom
"""
from matplotlib.pyplot import figure, show
import numpy
import numpy as np
figsrc = figure()
figzoom = figure()

Expand All @@ -23,7 +23,7 @@
autoscale_on=False)
axsrc.set_title('Click to zoom')
axzoom.set_title('zoom window')
x, y, s, c = numpy.random.rand(4, 200)
x, y, s, c = np.random.rand(4, 200)
s *= 200


Expand Down
10 changes: 6 additions & 4 deletions examples/pylab_examples/ellipse_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@

"""
import matplotlib.pyplot as plt
import numpy.random as rnd
import numpy as np
from matplotlib.patches import Ellipse

NUM = 250

ells = [Ellipse(xy=rnd.rand(2)*10, width=rnd.rand(), height=rnd.rand(), angle=rnd.rand()*360)
ells = [Ellipse(xy=np.random.rand(2)*10,
width=np.random.rand(), height=np.random.rand(),
angle=np.random.rand()*360)
for i in range(NUM)]

fig, ax = plt.subplots(subplot_kw={'aspect': 'equal'})
for e in ells:
ax.add_artist(e)
e.set_clip_box(ax.bbox)
e.set_alpha(rnd.rand())
e.set_facecolor(rnd.rand(3))
e.set_alpha(np.random.rand())
e.set_facecolor(np.random.rand(3))

ax.set_xlim(0, 10)
ax.set_ylim(0, 10)
Expand Down
4 changes: 2 additions & 2 deletions examples/pylab_examples/pcolor_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
"""
import matplotlib.pyplot as plt
import numpy as np
from numpy.random import rand
from matplotlib.colors import LogNorm
from matplotlib.mlab import bivariate_normal


###############################################################################
# A simple pcolor demo
# --------------------

Z = rand(6, 10)
Z = np.random.rand(6, 10)

plt.subplot(2, 1, 1)
c = plt.pcolor(Z)
Expand Down
4 changes: 2 additions & 2 deletions examples/pylab_examples/spy_demos.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
"""

from matplotlib.pyplot import figure, show
import numpy
import numpy as np

fig = figure()
ax1 = fig.add_subplot(221)
ax2 = fig.add_subplot(222)
ax3 = fig.add_subplot(223)
ax4 = fig.add_subplot(224)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I should probably change this one to subplots, too.


x = numpy.random.randn(20, 20)
x = np.random.randn(20, 20)
x[5] = 0.
x[:, 12] = 0.

Expand Down
7 changes: 3 additions & 4 deletions examples/pylab_examples/tricontour_vs_griddata.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@
import matplotlib.pyplot as plt
import matplotlib.tri as tri
import numpy as np
import numpy.random as rnd
import matplotlib.mlab as mlab
import time

rnd.seed(0)
np.random.seed(0)
npts = 200
ngridx = 100
ngridy = 200
x = rnd.uniform(-2, 2, npts)
y = rnd.uniform(-2, 2, npts)
x = np.random.uniform(-2, 2, npts)
y = np.random.uniform(-2, 2, npts)
z = x*np.exp(-x**2 - y**2)

# griddata and contour.
Expand Down
3 changes: 1 addition & 2 deletions examples/pylab_examples/vline_hline_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import matplotlib.pyplot as plt
from matplotlib.transforms import blended_transform_factory as btf
import numpy as np
import numpy.random as rnd


def f(t):
Expand All @@ -19,7 +18,7 @@ def f(t):

t = np.arange(0.0, 5.0, 0.1)
s = f(t)
nse = rnd.normal(0.0, 0.3, t.shape) * s
nse = np.random.normal(0.0, 0.3, t.shape) * s

fig = plt.figure(figsize=(12, 6))
vax = fig.add_subplot(121)
Expand Down
10 changes: 5 additions & 5 deletions examples/subplots_axes_and_figures/subplot_toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@

"""
import matplotlib.pyplot as plt
import numpy.random as rnd
import numpy as np

fig = plt.figure()
plt.subplot(221)
plt.imshow(rnd.random((100, 100)))
plt.imshow(np.random.random((100, 100)))
plt.subplot(222)
plt.imshow(rnd.random((100, 100)))
plt.imshow(np.random.random((100, 100)))
plt.subplot(223)
plt.imshow(rnd.random((100, 100)))
plt.imshow(np.random.random((100, 100)))
plt.subplot(224)
plt.imshow(rnd.random((100, 100)))
plt.imshow(np.random.random((100, 100)))

plt.subplot_tool()
plt.show()
4 changes: 2 additions & 2 deletions examples/units/units_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"""
from basic_units import cm, inch
import matplotlib.pyplot as plt
import numpy
import numpy as np

cms = cm * numpy.arange(0, 10, 2)
cms = cm * np.arange(0, 10, 2)

fig = plt.figure()

Expand Down
7 changes: 3 additions & 4 deletions examples/user_interfaces/histogram_demo_canvasagg_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@
from matplotlib.backends.backend_agg import FigureCanvasAgg
from matplotlib.figure import Figure
from matplotlib.mlab import normpdf
from numpy.random import randn
import numpy
import numpy as np

fig = Figure(figsize=(5, 4), dpi=100)
ax = fig.add_subplot(111)

canvas = FigureCanvasAgg(fig)

mu, sigma = 100, 15
x = mu + sigma*randn(10000)
x = mu + sigma * np.random.randn(10000)

# the histogram of the data
n, bins, patches = ax.hist(x, 50, normed=1)
Expand Down Expand Up @@ -52,7 +51,7 @@

if 0:
# convert to a numpy array
X = numpy.fromstring(s, numpy.uint8).reshape((h, w, 3))
X = np.fromstring(s, np.uint8).reshape((h, w, 3))

if 0:
# pass off to PIL
Expand Down
10 changes: 5 additions & 5 deletions examples/userdemo/annotate_text_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
"""

import numpy.random
import numpy as np
import matplotlib.pyplot as plt

fig, ax = plt.subplots(figsize=(5, 5))
ax.set_aspect(1)

x1 = -1 + numpy.random.randn(100)
y1 = -1 + numpy.random.randn(100)
x2 = 1. + numpy.random.randn(100)
y2 = 1. + numpy.random.randn(100)
x1 = -1 + np.random.randn(100)
y1 = -1 + np.random.randn(100)
x2 = 1. + np.random.randn(100)
y2 = 1. + np.random.randn(100)

ax.scatter(x1, y1, color="r")
ax.scatter(x2, y2, color="g")
Expand Down
0