面积图代码
import matplotlib.pyplot as plt
import pandas as pd
import matplotlib
matplotlib.use('TkAgg')
df = pd.DataFrame({
"年份": [2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022],
"京东销售额": [120450, 521232, 654512, 456212, 365425, 954212, 1125452, 152151, 585123, 451232],
"天猫销售额": [220450, 321232, 454512, 476212, 345425, 1254212, 225452, 11211251, 441232, 285123],
"抖音销售额": [520450, 241232, 454512, 256412, 162425, 554212, 125452, 1121251, 385123, 641232],
})
plt.rcParams["font.sans-serif"] = ["SimHei"] # 解决英文冲突问题
x = df["年份"]
y1 = df["京东销售额"]
y2 = df["天猫销售额"]
y3 = df["抖音销售额"]
plt.stackplot(x, y1, y2, y3, colors=["red", "blue", "green"])
# stack 堆/大量 stackplot 面积图
plt.legend(["京东", "天猫", "抖音"])
plt.show()
标签:plt,df,面积,matplotlib,天猫,抖音,销售额
From: https://www.cnblogs.com/pythonxuexi123/p/17707150.html