【发布时间】:2019-11-18 15:23:20
【问题描述】:
我需要 4 个不同生物体的 4 个直方图,数据非常多样化,但轴的限制和(更重要的是)所有箱的宽度在每个图中都应该相等。 我有这个代码
fig, axes = plt.subplots(nrows=2, ncols=2, figsize=(16, 10))
colors = ['tab:red', 'tab:blue', 'tab:green', 'tab:pink']
for i, (ax, Organism) in enumerate(zip(axes.flatten(), data.Organism.unique())):
x = data.loc[data.Organism == Organism, 'Protein Length']
ax.hist(x, density=True, label=str(Organism), color=colors[i], alpha=0.5, rwidth=0.5, bins = 30)
ax.set_xscale("log")
ax.set_xlim([min(data["Protein Length"]), max(data["Protein Length"])])
我还应该指定什么来获得 EQUAL bin 宽度?
提前致谢!
【问题讨论】:
标签: python matplotlib plot histogram