Mar*_*ame 5 python matplotlib pandas seaborn
我想创建一个与此类似的图形。是否可以使用matplotlib / seaborn。如果是这样,我可以使用哪些资源来学习如何设置matplotlib / seaborn图的样式以及如何使两个图像这样排列。
使用公共x轴并将其中一个数据集转换为包含负值。
y = ['{} to {} years'.format(i, i+4) for i in range(0, 90, 4)]
d_1 = np.random.randint(0, 150, 23)
d_2 = -1 * d_1
Run Code Online (Sandbox Code Playgroud)
然后绘制:
fig, ax = plt.subplots()
ax.bar(y, d_1)
ax.bar(y, d_2)
# Formatting x labels
plt.xticks(rotation=90)
plt.tight_layout()
# Use absolute value for y-ticks
ticks = ax.get_yticks()
ax.set_yticklabels([int(abs(tick)) for tick in ticks])
plt.show()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
568 次 |
| 最近记录: |