日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

Matplotlib之Bar Chart

發(fā)布時間:2024/1/4 综合教程 32 生活家
生活随笔 收集整理的這篇文章主要介紹了 Matplotlib之Bar Chart 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

Matplotlib之Bar Chart:

import numpy as np
import matplotlib.pyplot as plt

data = [[300, 200, 250, 150, 280],
        [300, 166, 203, 250, 225],
        [100, 110, 115, 150, 112],
        [300, 200, 250, 150, 280],
        [20, 30, 15, 10, 12],
        [20, 10, 10, 10, 20]]

columns = ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday')
rows = [x for x in ("EQP.NY", "EQB.NY", "EQP.LN", "EQB.LN", "FIP.NY", "FIB.NY")]

values = np.arange(0, 2000, 500)

# Get some pastel shades for the colors
colors = plt.cm.YlOrRd(np.linspace(0, 0.7, len(rows)))

n_rows = len(data)

index = np.arange(len(columns)) + 0.3
bar_width = 0.4

# Initialize the vertical-offset for the stacked bar chart.
y_offset = np.zeros(len(columns))

# Plot bars and create text labels for the table
cell_text = []
for row in range(n_rows):
    plt.bar(index, data[row], bar_width, bottom=y_offset, color=colors[row])
    y_offset = y_offset + data[row]
    cell_text.append(['%u' % x for x in data[row]])
# Reverse colors and text labels to display the last value at the top.
colors = colors[::-1]
cell_text.reverse()
# print(cell_text)

# Add a table at the bottom of the axes
the_table = plt.table(cellText=cell_text,
                      rowLabels=rows[::-1],
                      rowColours=colors,
                      colLabels=columns,
                      loc='bottom')

# Adjust layout to make room for the table:
plt.subplots_adjust(left=0.2, bottom=0.25)

# plt.ylabel("Loss in ${0}'s".format(value_increment))
plt.ylabel('Break counts')
# print(values)
plt.yticks(values, ['%d' % val for val in values])
plt.xticks([])
plt.title('Break Recon Summary')

plt.show()

效果:

總結(jié)

以上是生活随笔為你收集整理的Matplotlib之Bar Chart的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。