Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9036c31

Browse filesBrowse files
authored
Add stackplot to plot types listing
Area plots (stackplots) are a fairly common plot type, so I figure should be included in the plot type listing. They're structurally similar to fill_between, which is why I put this in the same 'basic' section
1 parent f25c2d0 commit 9036c31
Copy full SHA for 9036c31

File tree

Expand file treeCollapse file tree

1 file changed

+29
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+29
-0
lines changed

‎plot_types/basic/stackplot.py

Copy file name to clipboard
+29Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""
2+
===============================
3+
stackplot(x, y)
4+
===============================
5+
See `~matplotlib.axes.Axes.stackplot`
6+
"""
7+
import matplotlib.pyplot as plt
8+
import numpy as np
9+
10+
plt.style.use('_mpl-gallery')
11+
12+
# make data
13+
np.random.seed(1)
14+
x = np.arange(0, 10, 2)
15+
ay = [1, 1.25, 2 ,2.75, 3]
16+
by = [1, 1, 1, 1, 1]
17+
cy = [2, 1, 2, 1, 2]
18+
y = np.vstack([ay, by, cy])
19+
labels = ['a', 'b', 'c']
20+
# plot
21+
fig, ax = plt.subplots()
22+
23+
ax.stackplot(x, y, labels=labels)
24+
ax.legend(loc=2)
25+
26+
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
27+
ylim=(0, 8), yticks=np.arange(1, 8))
28+
29+
plt.show()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.