Matplotlib 方形箱线图
我在同一个图中有两个箱线图。出于样式原因,轴应具有相同的长度,以便图形框是方形的。我尝试使用 set_aspect
方法,但轴由于范围而差异太大 结果很糟糕。
即使点数不同,是否也可以拥有 1:1 轴?
I have a plot of two boxplots in the same figure. For style reasons, the axis should have the same length, so that the graphic box is square. I tried to use the set_aspect
method, but the axes are too different because of their range
and the result is terrible.
Is it possible to have 1:1 axes even if they do not have the same number of points?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 Axes.set_aspect如果将纵横比设置为轴限制的比率,则可以执行此操作。这是一个例子:
可能有更简单的方法,但我不知道。
You can use Axes.set_aspect to do this if you set the aspect to the ratio of axes limits. Here's an example:
There may be an easier way, but I don't know it.
尝试
axis('equal')
。自从我使用 matplotlib 以来已经有一段时间了,但我似乎记得经常输入该命令。Try
axis('equal')
. It's been a while since I worked with matplotlib, but I seem to remember typing that command a lot.对于对数对数图(
loglog()
),不要忘记使用For loglog plots (
loglog()
) don't forget to use