Skip to content

Commit 204e0cb

Browse files
committed
Other doc tweaks
1 parent 0c610a3 commit 204e0cb

File tree

8 files changed

+145
-101
lines changed

8 files changed

+145
-101
lines changed

doc/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*_files/
22
_build/
33
generated/
4+
_static/examples/*.png
45
aesthetics.rst
56
linear_models.rst
67
plotting_distributions.rst

doc/api.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _api_ref:
2+
13
.. currentmodule:: seaborn
24

35
API reference

doc/installing.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
.. _installing:
12

2-
Installing seaborn
3-
------------------
3+
Installing and getting started
4+
------------------------------
45

56
To install the released version of seaborn, you can use ``pip`` or
67
``easy_install``, (i.e. ``pip install seaborn``). Alternatively, you can use

doc/tutorials.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.. _tutorials:
12

23
Tutorial notebooks
34
==================

doc/v0.2.0.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,15 @@ Bug fixes
137137

138138
- Fixed a bug in the ``desaturate()`` function.
139139

140-
- Fixed a bug in the ``coefplot`` figure size calculation.
140+
- Fixed a bug in the ``coefplot()`` figure size calculation.
141141

142142
- Fixed a bug where ``regplot()`` choked on list input.
143143

144144
- Fixed buggy behavior when drawing horizontal boxplots.
145145

146-
- Specifying bins for the ``distplot`` histogram now works.
146+
- Specifying bins for the ``distplot()`` histogram now works.
147147

148-
- Fixed a bug where ``kdeplot`` would reset the axis height and cut off
148+
- Fixed a bug where ``kdeplot()`` would reset the axis height and cut off
149149
existing data.
150150

151151
- All axis styling has been moved out of the top-level ``seaborn.set()``

doc/whatsnew.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
.. _whatsnew:
12

2-
What's new in seaborn
3-
=====================
3+
What's new in the package
4+
=========================
45

56
A catalog of new features, improvements, and bug-fixes in each release.
67

examples/example_plot.png

143 Bytes
Loading

examples/example_plot.py

Lines changed: 132 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -5,135 +5,173 @@
55
from scipy import stats
66
import moss
77

8-
f = plt.figure(figsize=(10, 12))
9-
gs = plt.GridSpec(6, 2)
10-
np.random.seed(0)
8+
def lmplot(ax):
119

12-
# Linear regression
13-
# -----------------
10+
n = 80
11+
c = "#222222"
12+
rs = np.random.RandomState(5)
13+
x = rs.normal(4, 1, n)
14+
y = 2 + 1.5 * x + rs.normal(0, 3, n)
15+
ax.plot(x, y, "o", c=c, alpha=.8)
1416

15-
ax = plt.subplot(gs[:2, 0])
16-
plt.title("lmplot()")
17+
xx = np.linspace(1 + 1e-9, 7 - 1e-9, 100)
18+
lmpred = lambda x, y: np.polyval(np.polyfit(x, y, 1), xx)
19+
yy = lmpred(x, y)
20+
ax.plot(xx, yy, c=c)
21+
boots = moss.bootstrap(x, y, func=lmpred, n_boot=100)
22+
ci = moss.percentiles(boots, [2.5, 97.5], 0)
23+
ax.fill_between(xx, *ci, alpha=.15, color=c)
24+
ax.set_title("lmplot()")
1725

18-
n = 80
19-
c = "#222222"
20-
rs = np.random.RandomState(5)
21-
x = rs.normal(4, 1, n)
22-
y = 2 + 1.5 * x + rs.normal(0, 3, n)
23-
ax.plot(x, y, "o", c=c, alpha=.8)
2426

25-
xx = np.linspace(1, 7, 100)
26-
lmpred = lambda x, y: np.polyval(np.polyfit(x, y, 1), xx)
27-
yy = lmpred(x, y)
28-
ax.plot(xx, yy, c=c)
29-
boots = moss.bootstrap(x, y, func=lmpred, n_boot=100)
30-
ci = moss.percentiles(boots, [2.5, 97.5], 0)
31-
ax.fill_between(xx, *ci, alpha=.15, color=c)
27+
def tsplot(ax):
3228

33-
# Timeseries plot
34-
# ---------------
29+
n = 20
30+
t = 10
31+
ax.set_xlim(0, t)
32+
x = np.linspace(0, t, 100)
33+
s = np.array([stats.gamma.pdf(x, a) for a in [3, 5, 7]])
34+
d = s[:, np.newaxis, :]
35+
rs = np.random.RandomState(24)
3536

36-
ax = plt.subplot(gs[:2, 1])
37-
plt.title("tsplot()")
37+
d = d * np.array([1, -1])[rs.binomial(1, .3, 3)][:, np.newaxis, np.newaxis]
38+
d = d + rs.normal(0, .15, (3, n))[:, :, np.newaxis]
39+
d = d + rs.uniform(0, .25, 3)[:, np.newaxis, np.newaxis]
40+
d *= 10
41+
d = d.transpose((1, 2, 0))
3842

39-
n = 20
40-
t = 10
41-
ax.set_xlim(0, t)
42-
x = np.linspace(0, t, 100)
43-
s = np.array([stats.gamma.pdf(x, a) for a in [3, 5, 7]])
44-
d = s[:, np.newaxis, :]
45-
rs = np.random.RandomState(24)
43+
sns.tsplot(d, time=x, ax=ax)
44+
ax.set_title("tsplot()")
4645

47-
d = d * np.array([1, -1])[rs.binomial(1, .3, 3)][:, np.newaxis, np.newaxis]
48-
d = d + rs.normal(0, .15, (3, n))[:, :, np.newaxis]
49-
d = d + rs.uniform(0, .25, 3)[:, np.newaxis, np.newaxis]
50-
d *= 10
51-
d = d.transpose((1, 2, 0))
5246

53-
sns.tsplot(d, time=x, ax=ax)
47+
def violinplot(ax):
5448

55-
# Violin plots
56-
# ------------
49+
n = 40
50+
p = 8
51+
rs = np.random.RandomState(8)
52+
d = rs.normal(0, 1, (n, p))
53+
d += np.log(np.arange(1, p + 1)) * -5 + 10
5754

58-
sns.set(style="whitegrid")
55+
sns.violinplot(d, inner="points", ax=ax)
56+
ax.set_title("violinplot()")
5957

60-
ax = plt.subplot(gs[2:4, 0])
61-
plt.title("violinplot()")
6258

63-
n = 40
64-
p = 8
65-
rs = np.random.RandomState(8)
66-
d = rs.normal(0, 1, (n, p))
67-
d += np.log(np.arange(1, p + 1)) * -5 + 10
59+
def interactplot(ax):
6860

69-
sns.violinplot(d, inner="points")
61+
rs = np.random.RandomState(11)
7062

71-
#sns.despine(ax=ax)
63+
n = 80
64+
x1 = rs.randn(n)
65+
x2 = x1 / 5 + rs.randn(n)
66+
b0, b1, b2, b3 = 1.5, 4, -1, 3
67+
y = b0 + b1 * x1 + b2 * x2 + b3 * x1 * x2 + rs.randn(n)
7268

73-
# Continuous interaction
74-
# ----------------------
69+
sns.interactplot(x1, x2, y, colorbar=False, ax=ax)
70+
ax.set_title("interactplot()")
7571

76-
sns.set(style="darkgrid")
7772

78-
ax = plt.subplot(gs[2:4, 1])
79-
plt.title("interactplot()")
73+
def corrplot(ax):
8074

81-
rs = np.random.RandomState(11)
75+
rs = np.random.RandomState(0)
76+
x0, x1 = rs.randn(2, 60)
77+
x2, x3 = rs.multivariate_normal([0, 0], [(1, -.5), (-.5, 1)], 60).T
78+
x2 += x0 / 8
79+
x4 = x1 + rs.randn(60) * 2
80+
data = np.c_[x0, x1, x2, x3, x4]
8281

83-
n = 80
84-
x1 = rs.randn(n)
85-
x2 = x1 / 5 + rs.randn(n)
86-
b0, b1, b2, b3 = 1.5, 4, -1, 3
87-
y = b0 + b1 * x1 + b2 * x2 + b3 * x1 * x2 + rs.randn(n)
82+
sns.corrplot(data, ax=ax)
83+
ax.set_title("corrplot()", verticalalignment="top")
8884

89-
sns.interactplot(x1, x2, y, colorbar=False, ax=ax)
9085

86+
def distplot_hist(ax):
9187

92-
# Correlation matrix
93-
# ------------------
88+
ax.set_xlim(0, 1)
89+
ax.set_xticklabels([])
9490

95-
ax = plt.subplot(gs[4:, 0])
91+
g = sns.color_palette("Set2", desat=.75)[0]
92+
n = 1000
93+
rs = np.random.RandomState(0)
94+
d = rs.beta(8, 13, n)
9695

97-
rs = np.random.RandomState(0)
98-
x0, x1 = rs.randn(2, 60)
99-
x2, x3 = rs.multivariate_normal([0, 0], [(1, -.5), (-.5, 1)], 60).T
100-
x2 += x0 / 8
101-
x4 = x1 + rs.randn(60) * 2
102-
data = np.c_[x0, x1, x2, x3, x4]
96+
sns.distplot(d, color=g, ax=ax)
97+
sns.despine(ax=ax)
98+
ax.set_title("distplot()")
10399

104-
sns.corrplot(data, ax=ax)
105-
ax.set_title("corrplot()", verticalalignment="top")
106100

101+
def distplot_kde(ax):
107102

108-
# Beta distributions
109-
# ------------------
103+
ax.set_xlim(0, 1)
110104

111-
sns.set(style="nogrid")
105+
p = sns.color_palette("Set2", desat=.75)[2]
106+
n = 80
107+
rs = np.random.RandomState(0)
108+
d = rs.beta(50, 25, n)
112109

113-
ax = plt.subplot(gs[4, 1])
114-
plt.title("distplot()")
115-
plt.xlim(0, 1)
116-
ax.set_xticklabels([])
110+
sns.distplot(d, hist=False, rug=True, color=p,
111+
kde_kws=dict(shade=True), ax=ax)
112+
sns.despine(ax=ax)
117113

118-
g, _, p = sns.color_palette("Set2", 3, desat=.75)
119-
n = 1000
120-
rs = np.random.RandomState(0)
121-
d = rs.beta(8, 13, n)
122114

123-
sns.distplot(d, color=g)
124-
sns.despine(ax=ax)
115+
if __name__ == "__main__":
125116

126-
ax = plt.subplot(gs[5, 1], sharey=ax)
127-
plt.xlim(0, 1)
117+
f = plt.figure(figsize=(10, 12))
118+
gs = plt.GridSpec(6, 2)
119+
np.random.seed(0)
128120

129-
d = rs.beta(50, 25, n / 15)
121+
# Linear regression
122+
ax = plt.subplot(gs[:2, 0])
123+
lmplot(ax)
130124

131-
sns.distplot(d, hist=False, rug=True, color=p, kde_kws=dict(shade=True))
132-
sns.despine(ax=ax)
125+
# Timeseries plot
126+
ax = plt.subplot(gs[:2, 1])
127+
tsplot(ax)
133128

129+
# Violin plots
130+
sns.set(style="whitegrid")
131+
ax = plt.subplot(gs[2:4, 0])
132+
violinplot(ax)
134133

135-
# Save the plot
136-
# -------------
134+
# Continuous interaction
135+
sns.set(style="darkgrid")
136+
ax = plt.subplot(gs[2:4, 1])
137+
interactplot(ax)
137138

138-
f.tight_layout()
139-
f.savefig("%s/example_plot.png" % os.path.dirname(__file__))
139+
# Correlation matrix
140+
ax = plt.subplot(gs[4:, 0])
141+
corrplot(ax)
142+
143+
# Beta distributions
144+
sns.set(style="nogrid")
145+
ax = plt.subplot(gs[4, 1])
146+
distplot_hist(ax)
147+
148+
ax = plt.subplot(gs[5, 1], sharey=ax)
149+
distplot_kde(ax)
150+
151+
# Save the plot
152+
f.tight_layout()
153+
png_template = os.path.dirname(__file__) + "/%s.png"
154+
f.savefig(png_template % "example_plot")
155+
156+
# Carousel images
157+
plots = ["lmplot", "tsplot", "violinplot", "interactplot",
158+
"corrplot", "distplot"]
159+
styles = {p: "darkgrid" for p in plots}
160+
styles["violinplot"] = "whitegrid"
161+
styles["distplot"] = "nogrid"
162+
163+
figsize = (6, 4.2)
164+
for plot in plots:
165+
sns.set_axes_style(styles[plot], "notebook")
166+
167+
if plot == "distplot":
168+
f, (ax1, ax2) = plt.subplots(2, 1, sharey=True, figsize=figsize)
169+
distplot_hist(ax1)
170+
distplot_kde(ax2)
171+
else:
172+
plot_func = locals()[plot]
173+
f, ax = plt.subplots(figsize=figsize)
174+
plot_func(ax)
175+
176+
f.tight_layout()
177+
f.savefig(png_template % plot)

0 commit comments

Comments
 (0)