-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
DOC Convert style sheet examples to MEP12 #7890
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
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,31 @@ | ||
""" | ||
This example demonstrates the "bmh" style, which is the design used in the | ||
Bayesian Methods for Hackers online book. | ||
======================================== | ||
Bayesian Methods for Hackers style sheet | ||
======================================== | ||
|
||
This example demonstrates the style used in the Bayesian Methods for Hackers | ||
[1]_ online book. | ||
|
||
.. [1] http://camdavidsonpilon.github.io/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/ | ||
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. Question to a PEP8 expert (@QuLogic ?) : are URLs longer than 80 characters OK with our pycodestyle setup? 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 was wondering about that too and pushed this to see if the build would fail. Obviously there isn't much of a way around this short of using a URL shortener or something. 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 think it might ignore URLs in docstrings. You could get it to fit with backslashes, but it'd be ugly. |
||
|
||
""" | ||
from numpy.random import beta | ||
import matplotlib.pyplot as plt | ||
|
||
plt.style.use('bmh') | ||
|
||
|
||
def plot_beta_hist(a, b): | ||
plt.hist(beta(a, b, size=10000), histtype="stepfilled", | ||
bins=25, alpha=0.8, normed=True) | ||
return | ||
def plot_beta_hist(ax, a, b): | ||
ax.hist(beta(a, b, size=10000), histtype="stepfilled", | ||
bins=25, alpha=0.8, normed=True) | ||
return ax | ||
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. Remove this line; the return value is not used for anything. |
||
|
||
|
||
plot_beta_hist(10, 10) | ||
plot_beta_hist(4, 12) | ||
plot_beta_hist(50, 12) | ||
plot_beta_hist(6, 55) | ||
fig, ax = plt.subplots() | ||
plot_beta_hist(ax, 10, 10) | ||
plot_beta_hist(ax, 4, 12) | ||
plot_beta_hist(ax, 50, 12) | ||
plot_beta_hist(ax, 6, 55) | ||
ax.set_title("'bmh' style sheet") | ||
|
||
plt.show() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
""" | ||
=========================== | ||
FiveThirtyEight style sheet | ||
=========================== | ||
|
||
This shows an example of the "fivethirtyeight" styling, which | ||
tries to replicate the styles from FiveThirtyEight.com. | ||
""" | ||
|
@@ -12,13 +16,16 @@ | |
# Fixing random state for reproducibility | ||
np.random.seed(19680801) | ||
|
||
fig, ax = plt.subplots() | ||
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. You might need to do this within the context to ensure that general figure styling matches the style. 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. Or maybe change the example to use |
||
|
||
with plt.style.context('fivethirtyeight'): | ||
plt.plot(x, np.sin(x) + x + np.random.randn(50)) | ||
plt.plot(x, np.sin(x) + 0.5 * x + np.random.randn(50)) | ||
plt.plot(x, np.sin(x) + 2 * x + np.random.randn(50)) | ||
plt.plot(x, np.sin(x) - 0.5 * x + np.random.randn(50)) | ||
plt.plot(x, np.sin(x) - 2 * x + np.random.randn(50)) | ||
plt.plot(x, np.sin(x) + np.random.randn(50)) | ||
ax.plot(x, np.sin(x) + x + np.random.randn(50)) | ||
ax.plot(x, np.sin(x) + 0.5 * x + np.random.randn(50)) | ||
ax.plot(x, np.sin(x) + 2 * x + np.random.randn(50)) | ||
ax.plot(x, np.sin(x) - 0.5 * x + np.random.randn(50)) | ||
ax.plot(x, np.sin(x) - 2 * x + np.random.randn(50)) | ||
ax.plot(x, np.sin(x) + np.random.randn(50)) | ||
ax.set_title("'fivethirtyeight' style sheet") | ||
|
||
|
||
plt.show() |
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.
@NelleV does the length of the
=
's need to match the title?E.g.,
vs
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.
Yes, it does: our documentation build is else going to fail.
(To be precise, lines can be longer, but not shorter than the title)
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.
👍