Created
July 10, 2020 08:18
-
-
Save sabopy/8817fc502b72d5d383afcd260217bd5b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Stackplot | |
import numpy as np | |
import matplotlib.pyplot as plt | |
plt.rcParams["font.size"] = 14 | |
x = np.arange(6) | |
y1 = np.random.randint(1,5,6) | |
y2 = np.random.randint(1,5,6) | |
y3 = np.random.randint(1,5,6) | |
labels = ["sa ", "bo", "py"] | |
fig, ax = plt.subplots(figsize=(8,6)) | |
ax.stackplot(x, y1, y2, y3, labels=labels) | |
ax.legend(loc='best') | |
plt.savefig("stackplot1.png",dpi=100) | |
plt.show() | |
y = np.vstack([y1, y2, y3]) | |
fig, ax = plt.subplots(figsize=(8,6)) | |
ax.stackplot(x, y,labels=labels) | |
ax.legend(loc='best') | |
plt.savefig("stackplot2.png",dpi=100) | |
plt.show() | |
fig, ax = plt.subplots(figsize=(8,6)) | |
ax.stackplot(x, y,baseline='sym',labels=labels) | |
ax.legend(loc='best') | |
ax.set_title("baseline='sym'") | |
plt.savefig("stackplot3.png",dpi=100) | |
plt.show() | |
fig, ax = plt.subplots(figsize=(8,6)) | |
ax.stackplot(x, y,baseline='wiggle',labels=labels) | |
ax.legend(loc='best') | |
ax.set_title("baseline='wiggle'") | |
plt.savefig("stackplot4.png",dpi=100) | |
plt.show() | |
#version | |
import matplotlib | |
print(matplotlib.__version__) | |
print(np.__version__) | |
3.2.2 | |
1.18.5 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment