df = pd.DataFrame({'id':['abc1', 'abc2', 'abc3','abc4'], 'age':[21,23,45,34],
'marks':[20, 24, 34, 18]})
df 所以我想画一个以x轴为年龄组的条形图。
假设我希望我的组是:
10-20, 20-30, 30-40, 40-50我是用Python绘图的新手,你能帮我吗?
发布于 2015-01-13 15:55:49
为此,我将使用matplotlib库。
import matplotlib.pyplot as plt
import numpy as np
def plot_histogram_06():
data = np.random.normal(loc=30, scale=10, size=[1000, 1])
bins = (10, 20, 30, 40, 50, 60, 70)
plt.hist(data, bins=bins)
plt.savefig('my_plot_06.png')
plt.close()

如果要规格化y轴,可以在hist参数列表中添加normed=True。有关更多选项,请参阅matplotlib手册。
https://stackoverflow.com/questions/27915194
复制相似问题