如何使用不同比例轴的2D数据栏创建条形图
我想创建这样的图:
其中只有图表的前半部分。我尝试使用两个刻度y轴,但是我无法将新轴从0开始。这可能是移动新轴吗?还是有其他方法,如何获得此图?
# dummy data
x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
y = [10000, 200000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 100001, 12000]
y2 = [1, 2, 45, 4, 5, 6, 2, 8, 9, 10, 11, 1]
fig, ax1 = plt.subplots(figsize=(5, 5), dpi=80)
ax2 = ax1.twinx()
# plot data
ax1.bar(x, y, color=color, log=True)
ax2.bar(x, y2,color=color)
ax2.invert_yaxis()
I would like to create graph like this:
Where only first half of the graph is in log scale. I tried to use two scale y axis, but I was not able to shift new axis to start from 0. It is possible shift new axis ? Or is there some other way, how to obtain this graph ?
# dummy data
x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
y = [10000, 200000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 100001, 12000]
y2 = [1, 2, 45, 4, 5, 6, 2, 8, 9, 10, 11, 1]
fig, ax1 = plt.subplots(figsize=(5, 5), dpi=80)
ax2 = ax1.twinx()
# plot data
ax1.bar(x, y, color=color, log=True)
ax2.bar(x, y2,color=color)
ax2.invert_yaxis()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过组合两个图来绘制它,这似乎是提供的输出所做的:
You could plot it by combining two plots, which seems to be what the provided output is doing: