-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
DOC: clearing out some instances of using pylab in the docs #6957
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
#!/usr/bin/env python | ||
import matplotlib.mlab as mlab | ||
from pylab import figure, show | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
x = np.arange(0.0, 2, 0.01) | ||
y1 = np.sin(2*np.pi*x) | ||
y2 = 1.2*np.sin(4*np.pi*x) | ||
|
||
fig = figure() | ||
ax = fig.add_subplot(111) | ||
fig, ax = plt.subplots() | ||
ax.plot(x, y1, x, y2, color='black') | ||
ax.fill_between(x, y1, y2, where=y2>y1, facecolor='green') | ||
ax.fill_between(x, y1, y2, where=y2<=y1, facecolor='red') | ||
ax.set_title('fill between where') | ||
|
||
show() | ||
plt.show() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
from mpl_toolkits.mplot3d import Axes3D | ||
from matplotlib import cm | ||
import pylab | ||
import random | ||
|
||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
from matplotlib import cm | ||
from mpl_toolkits.mplot3d import Axes3D | ||
|
||
fig = pylab.figure() | ||
ax = Axes3D(fig) | ||
X = np.arange(-5, 5, 0.25) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe move data pieces above plotting code? |
||
Y = np.arange(-5, 5, 0.25) | ||
X, Y = np.meshgrid(X, Y) | ||
R = np.sqrt(X**2 + Y**2) | ||
Z = np.sin(R) | ||
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet) | ||
|
||
pylab.show() | ||
fig = plt.figure() | ||
ax = Axes3D(fig) | ||
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.viridis) | ||
|
||
plt.show() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,28 +9,25 @@ | |
arrays. | ||
""" | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
from basic_units import secs, hertz, minutes | ||
from matplotlib.pylab import figure, show | ||
|
||
# create masked array | ||
data = (1, 2, 3, 4, 5, 6, 7, 8) | ||
mask = (1, 0, 1, 0, 0, 0, 1, 0) | ||
xsecs = secs * np.ma.MaskedArray(data, mask, float) | ||
|
||
|
||
xsecs = secs*np.ma.MaskedArray((1, 2, 3, 4, 5, 6, 7, 8), (1, 0, 1, 0, 0, 0, 1, 0), float) | ||
#xsecs = secs*np.arange(1,10.) | ||
|
||
fig = figure() | ||
ax1 = fig.add_subplot(3, 1, 1) | ||
fig, (ax1, ax2, ax3) = plt.subplots(nrows=3, sharex=True) | ||
ax1.scatter(xsecs, xsecs) | ||
#ax1.set_ylabel('seconds') | ||
ax1.yaxis.set_units(secs) | ||
ax1.axis([0, 10, 0, 10]) | ||
|
||
ax2 = fig.add_subplot(3, 1, 2, sharex=ax1) | ||
ax2.scatter(xsecs, xsecs, yunits=hertz) | ||
ax2.axis([0, 10, 0, 1]) | ||
|
||
ax3 = fig.add_subplot(3, 1, 3, sharex=ax1) | ||
ax3.scatter(xsecs, xsecs, yunits=hertz) | ||
ax3.yaxis.set_units(minutes) | ||
ax3.axis([0, 10, 0, 1]) | ||
|
||
show() | ||
fig.tight_layout() | ||
plt.show() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. consistency of fig.show() or plt.show()? (my preference is for fig.show()...) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mine too, but some examples have more than 1 figure, so Happy to change this one though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also, an advantage of IOW, if I run There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, the new I guess use plt.show() for all? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would lean towards |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these comments wrong? Why remove them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added them to the figures as titles -- figure that just as informative when reading the code.