Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 44b3634

Browse files
committed
Merge pull request matplotlib#3190 from CamDavidsonPilon/master
Adding two new styles to mplstyles
2 parents aabfd09 + 7b70d19 commit 44b3634

File tree

4 files changed

+101
-0
lines changed

4 files changed

+101
-0
lines changed

examples/style_sheets/plot_bmh.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""
2+
This example demonstrates the "bmh" style, which is the design used in the
3+
Bayesian Methods for Hackers online book.
4+
"""
5+
from numpy.random import beta
6+
import matplotlib.pyplot as plt
7+
8+
plt.style.use('bmh')
9+
10+
11+
def plot_beta_hist(a, b):
12+
plt.hist(beta(a, b, size=10000), histtype="stepfilled",
13+
bins=25, alpha=0.8, normed=True)
14+
return
15+
16+
plot_beta_hist(10, 10)
17+
plot_beta_hist(4, 12)
18+
plot_beta_hist(50, 12)
19+
plot_beta_hist(6, 55)
20+
21+
plt.show()
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""
2+
This shows an example of the "fivethirtyeight" styling, which
3+
tries to replicate the styles from FiveThirtyEight.com.
4+
"""
5+
6+
7+
from matplotlib import pyplot as plt
8+
import numpy as np
9+
10+
x = np.linspace(0, 10)
11+
12+
with plt.style.context('fivethirtyeight'):
13+
plt.plot(x, np.sin(x) + x + np.random.randn(50))
14+
plt.plot(x, np.sin(x) + 0.5 * x + np.random.randn(50))
15+
plt.plot(x, np.sin(x) + 2 * x + np.random.randn(50))
16+
17+
18+
plt.show()
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#Author: Cameron Davidson-Pilon, original styles from Bayesian Methods for Hackers
2+
# https://github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/
3+
4+
lines.linewidth : 2.0
5+
6+
patch.linewidth: 0.5
7+
patch.facecolor: blue
8+
patch.edgecolor: eeeeee
9+
patch.antialiased: True
10+
11+
text.hinting_factor : 8
12+
13+
mathtext.fontset : cm
14+
15+
axes.facecolor: eeeeee
16+
axes.edgecolor: bcbcbc
17+
axes.grid : True
18+
axes.titlesize: x-large
19+
axes.labelsize: large
20+
axes.color_cycle: 348ABD, A60628, 7A68A6, 467821, D55E00, CC79A7, 56B4E9, 009E73, F0E442, 0072B2
21+
22+
legend.fancybox: True
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#Author: Cameron Davidson-Pilon, replicated styles from FiveThirtyEight.com
2+
# See https://www.dataorigami.net/blogs/fivethirtyeight-mpl
3+
4+
lines.linewidth: 4
5+
lines.solid_capstyle: butt
6+
7+
legend.fancybox: true
8+
9+
axes.color_cycle: 30a2da, fc4f30, e5ae38, 6d904f, 8b8b8b
10+
axes.facecolor: f0f0f0
11+
axes.labelsize: large
12+
axes.axisbelow: true
13+
axes.grid: true
14+
axes.edgecolor: f0f0f0
15+
axes.linewidth: 3.0
16+
axes.titlesize: x-large
17+
18+
patch.edgecolor: f0f0f0
19+
patch.linewidth: 0.5
20+
21+
svg.fonttype: path
22+
23+
grid.linestyle: -
24+
grid.linewidth: 1.0
25+
grid.color: cbcbcb
26+
27+
xtick.major.size: 0
28+
xtick.minor.size: 0
29+
ytick.major.size: 0
30+
ytick.minor.size: 0
31+
32+
font.size:14.0
33+
34+
savefig.edgecolor: f0f0f0
35+
savefig.facecolor: f0f0f0
36+
37+
figure.subplot.left: 0.08
38+
figure.subplot.right: 0.95
39+
figure.subplot.bottom: 0.07
40+
figure.facecolor: f0f0f0

0 commit comments

Comments
 (0)