matplotlib同时使用twinx和twiny(例如twinxy) [英] matplotlib using twinx and twiny together (like twinxy)

查看:205
本文介绍了matplotlib同时使用twinx和twiny(例如twinxy)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以同时拥有twinx和twiny吗(例如twinxy之类的东西)? 我想将CDF放在条形图的X轴为对数刻度的条形图上.我无法将Y放在一起,因为与CDF的[0,1]相比,条形图y的范围非常大.

Can I have both twinx and twiny together (i.e. something like twinxy)? I want to put a CDF on a bar plot where the X axis of the bar plot is in log-scale. I cannot make the Ys together, because the bar plot y range is very large comparing [0,1] for CDF.

有什么想法吗?

谢谢

推荐答案

如果我正确地理解了您的问题,那么您想在同一axes上绘制两件事,而没有共享的axis.可能有更好的方法,但是您可以堆叠twinx (doc)twiny (doc)就这样

If I understand your question right, you want to plot two things on the same axes with no shared axis. There is probably a better way to do this, but you can stack twinx (doc) and twiny (doc) as such

ax # your first axes
ax_new = ax.twinx().twiny()

这将在情节的各个方面给您打勾. ax将在底部和左侧绘制,ax_new将在顶部和右侧绘制.

Which will give you tick marks on all sides of the plot. ax will plot against the bottom and left, ax_new will plot against the top and right.

这篇关于matplotlib同时使用twinx和twiny(例如twinxy)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆