【记录】python饼状图和条形图

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from openpyxl.workbook import Workbook
from matplotlib import rcParams
from matplotlib.pyplot import MultipleLocator

config = {
            "font.family": 'serif',
            "font.size": 15,
            "mathtext.fontset": 'stix',
            "font.serif": ['SimSun'],
         }
rcParams.update(config)

labels = '四川', '云南', '西藏', '中部', '东北', '东部'
sizes = [22, 20, 19, 14, 10, 5]
fig1 = plt.figure()
ax1 = fig1.add_subplot(111)
ax1.pie(sizes, labels=labels, autopct='%1.1f%%', shadow=False)
ax1.axis('equal')

x = np.arange(6)
y = [7714, 6186, 771, 231, 2119, 1665]
name = ['四川', '云南', '重庆', '西藏', '贵州', '广西']
fig = plt.figure()
ax = fig.add_subplot(111)
bars = ax.bar(x, y)
plt.xticks(range(len(name)), name)
i = 0
for bar in bars:
    height = bar.get_height()
    plt.text(bar.get_x() + bar.get_width() / 2, height, str(height), ha='center', va='baseline')
plt.show()

饼状图
条形图

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值