【数据分析&数据挖掘】2000-2017年各个产业生产总值箱线图
import matplotlib.pyplot as plt import numpy as np # 构建数据 def build_data(): res = np.load("./国民经济核算季度数据.npz", allow_pickle=True) columns = res["columns"] values = res["values"] return columns, values def show_data(columns, values): fig = plt.figure() plt.rcParams[‘font.sans-serif‘] = ‘SimHei‘ plt.rcParams[‘axes.unicode_minus‘] = False fig.add_subplot(2, 1, 1) x = (list(values[:, 3]), list(values[:, 4]), list(values[:, 5])) labels = [tmp[:4] for tmp in columns[3:6]] plt.boxplot(x, notch=True, labels=labels, meanline=True, showmeans=True) plt.title("2000-2017年各个产业生产总值箱线图") plt.xlabel("产业") plt.ylabel("生产总值(亿元)") fig.add_subplot(2, 1, 2) x = (list(values[:, 6]), list(values[:, 7]), list(values[:, 8]), list(values[:, 9]), list(values[:, 10]), list(values[:, 11]), list(values[:, 12]), list(values[:, 13]), list(values[:, 14])) labels = [tmp[:2] for tmp in columns[6:]] plt.boxplot(x, notch=True, labels=labels, meanline=True, showmeans=True) plt.title("2000-2017年各个行业生产总值箱线图") plt.xlabel("行业") plt.ylabel("生产总值(亿元)") plt.savefig("./2000-2017年各个产业生产总值箱线图.png") plt.show() def main(): columns, values = build_data() show_data(columns, values) if __name__ == ‘__main__‘: main()
绘制更多的图,参考网址:https://matplotlib.org/gallery/index.html
echarts
pyecharts
相关推荐
小小梦想家 2020-09-26
茄肥猫的窝 2020-10-29
kkbb 2020-10-27
gallon00 2020-10-16
yangkang 2020-11-09
lbyd0 2020-11-17
sushuanglei 2020-11-12
85477104 2020-11-17
KANSYOUKYOU 2020-11-16
wushengyong 2020-10-28
lizhengjava 2020-11-13
星月情缘 2020-11-13
huangxiaoyun00 2020-11-13
luyong0 2020-11-08
腾讯soso团队 2020-11-06
Apsaravod 2020-11-05
PeterChangyb 2020-11-05
gaobudong 2020-11-04