python怎么交换xy轴 您所在的位置:网站首页 怎么对调xy轴 python怎么交换xy轴

python怎么交换xy轴

2024-01-19 02:09| 来源: 网络整理| 查看: 265

代码中的内容是如何在matplotlib中启动直方图的示例。注意,您使用的是pyplot默认接口(不一定要构建自己的图形)。

因此这一行:orientation=u'vertical',

应该是:orientation=u'horizontal',

,如果你想让酒吧从左到右。但这对y轴没有帮助。要反转y轴,应使用以下命令:plt.gca().invert_yaxis()

下面的例子向您展示了如何从随机数据中构建直方图(非对称以便更容易感知修改)。第一个图是标准直方图,第二个图改变了直方图的方向;最后一个图反转了y轴。import numpy as np

import matplotlib.pyplot as plt

data = np.random.exponential(1, 100)

# Showing the first plot.

plt.hist(data, bins=10)

plt.show()

# Cleaning the plot (useful if you want to draw new shapes without closing the figure

# but quite useless for this particular example. I put it here as an example).

plt.gcf().clear()

# Showing the plot with horizontal orientation

plt.hist(data, bins=10, orientation='horizontal')

plt.show()

# Cleaning the p



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有