python做图表的模块有哪些,python生成图表报告

本篇文章给大家谈谈基于python的图表生成系统,以及基于python的图表绘图工具,希望对各位有所帮助,不要忘了收藏本站喔。

40张python图表

1. 条形图

# 库
import numpy as np
import matplotlib.pyplot as plt
 
# 创建数据集
height = [3, 12, 5, 18, 45]
bars = ('A', 'B', 'C', 'D', 'E')
x_pos = np.arange(len(bars))
 
# 创建条形图
plt.bar(x_pos, height)
 
# 在x轴上创建名称
plt.xticks(x_pos, bars)
 
# 显示图形
plt.show()

在这里插入图片描述

#水平条形图
import matplotlib.pyplot as plt
import numpy as np

height = [3, 12, 5, 18, 45]
bars = ('A', 'B', 'C', 'D', 'E')
y_pos = np.arange(len(bars))
#height后面加上代码color=(0.2, 0.4, 0.6, 0.6)可以改变颜色
plt.barh(y_pos, height)

plt.yticks(y_pos, bars)
plt.show()

在这里插入图片描述

# 堆垛条形图
# 库
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rc
import pandas as pd
rc('font', weight='bold')
bars1 = [12, 28, 1, 8, 22]
bars2 = [28, 7, 16, 4, 10]
bars3 = [25, 3, 23, 25, 17]
bars = np.add(bars1, bars2).tolist()
r = [0,1,2,3,4]
names = ['A','B','C','D','E']
barWidth = 1
plt.bar(r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth)
plt.bar(r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth)
plt.bar(r, bars3, bottom=bars, color=
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值