📅  最后修改于: 2022-03-11 14:45:36.365000             🧑  作者: Mango
import pandas
import matplotlib.pyplot as plt
import numpy as np
df = pandas.DataFrame(dict(graph=['Item one', 'Item two', 'Item three'],
n=[3, 5, 2], m=[6, 1, 3]))
ind = np.arange(len(df))
width = 0.4
fig, ax = plt.subplots()
ax.barh(ind, df.n, width, color='red', label='N')
ax.barh(ind + width, df.m, width, color='green', label='M')
ax.set(yticks=ind + width, yticklabels=df.graph, ylim=[2*width - 1, len(df)])
ax.legend()
plt.show()