如何将Matplotlib图旋转90度? [英] How can I rotate a matplotlib plot through 90 degrees?

查看:2835
本文介绍了如何将Matplotlib图旋转90度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在matplotlib中创建了一个图形,其中包含三个子图,一个在左上象限,一个在右上象限,一个在右下象限.右上方的图包含一个二维图像,其他两个图分别是在Y轴和X轴上的投影.我想将左上象限子图逆时针旋转90度,以使该图的x轴沿着二维图的y轴.

I have created a figure in matplotlib which contains three subplots, one in the top left quadrant, one in the top right quadrant, and one in the bottom right quadrant. The top right figure contains a two-d image, and the other two plots are the projection onto the Y and X axis respectively. I'd like to rotate the top left quadrant subplot through 90deg counterclockwise, so that the x-axis of that plot lies along the y-axis of the 2-d plot.

对于子图,我意识到我可以翻转x和y数据,旋转轴标签,在左侧创建图标题,等等.但是我希望找到一个可以旋转整个图的调用,通过90deg完成地块.但是我找不到一个.

For the subplot, I realize I could flip the x and y data, rotate the axis labels, create a plot title on the left hand side, etc. But I was hoping to find a single call which would just rotate the whole, finished plot through 90deg. But I can't find one.

有没有简单的方法可以做到这一点?

Is there a simple way to do this?

推荐答案

许多pyplot 1D图似乎在其自变量中都具有方向"或枢轴"选项.例如,从matplotlib.org的直方图示例:

Many of the pyplot 1D plots seem to have "orientation" or "pivot" options within their own arguments. For example, from matplotlib.org example of histogram:

matplotlib.pyplot.hist(x, 
                       bins=10, 
                       range=None, 
                       normed=False, 
                       weights=None, 
                       cumulative=False, 
                       bottom=None, 
                       histtype=u'bar', 
                       align=u'mid', 
                       orientation=u'vertical', 
                       rwidth=None, 
                       log=False, 
                       color=None, 
                       label=None, 
                       stacked=False, 
                       hold=None, 
                       **kwargs)

只需更改为水平(orientation=u'vertical')

这篇关于如何将Matplotlib图旋转90度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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