Skip to content

Commit 2fba987

Browse files
add plotting examples
adding np and plt into script
1 parent c2a5f5e commit 2fba987

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

examples/style_sheets/plot_bmh.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
This example demonstrates the "bmh" style, which is the design used in the
3+
Bayesian Methods for Hackers online book.
4+
5+
"""
6+
from numpy.random import beta
7+
import matplotlib.pyplot as plt
8+
9+
plt.style.use('bmh')
10+
plt.hist(beta(10,10,size=10000),histtype="stepfilled", bins=25, alpha=0.8, normed=True)
11+
plt.hist(beta(4,12,size=10000),histtype="stepfilled", bins=25, alpha=0.7, normed=True)
12+
plt.hist(beta(50,12,size=10000),histtype="stepfilled", bins=25, alpha=0.8, normed=True)
13+
plt.hist(beta(6,55,size=10000),histtype="stepfilled", bins=25, alpha=0.8, normed=True)
14+
15+
plt.show()
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
This shows an example of the "fivethirtyeight" styling, which tries to replicate the styles from FiveThirtyEight.com.
3+
"""
4+
5+
6+
from matplotlib import pyplot as plt
7+
import numpy as np
8+
9+
x = np.linspace(0,10)
10+
11+
with plt.style.context('fivethirtyeight'):
12+
plt.plot(x, np.sin(x) + x + np.random.randn(50))
13+
plt.plot(x, np.sin(x) + 0.5*x + np.random.randn(50))
14+
plt.plot(x, np.sin(x) + 2*x + np.random.randn(50))
15+

lib/matplotlib/style/stylelib/fivethirtyeight.mplstyle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#Author: Cameron Davidson-Pilon, replicated styles from FiveThirtyEight.com
22
# See https://www.dataorigami.net/blogs/fivethirtyeight-mpl
33

4-
lines.linewidth: 2.0
54
lines.linewidth: 4
65
lines.solid_capstyle: butt
76

@@ -19,7 +18,7 @@ axes.titlesize: x-large
1918
patch.edgecolor: f0f0f0
2019
patch.linewidth: 0.5
2120

22-
svg.embed_char_paths: path
21+
svg.fonttype: path
2322

2423
grid.linestyle: -
2524
grid.linewidth: 1.0

0 commit comments

Comments
 (0)