Python Matplotlib.axes.Axes.invert

您所在的位置:网站首页 反转x轴什么意思 Python Matplotlib.axes.Axes.invert

Python Matplotlib.axes.Axes.invert

2024-07-09 10:39| 来源: 网络整理| 查看: 265

Matplotlib是Python中的一个库,它是数字的-NumPy库的数学扩展。轴类包含大多数图形元素:Axis,Tick,Line2D,Text,Polygon等,并设置坐标系。 Axes实例通过callbacks属性支持回调。

matplotlib.axes.Axes.invert_xaxis()函数

matplotlib库的axiss模块中的Axes.invert_xaxis()函数用于反转x轴。

用法: Axes.invert_xaxis(self)

参数:此方法不接受任何参数。

返回:此方法不返回任何值。

以下示例说明了matplotlib.axes中的matplotlib.axes.Axes.invert_xaxis()函数:

范例1:

# Implementation of matplotlib function import matplotlib.pyplot as plt import numpy as np         X = np.arange(-20, 20, 0.5) Y = np.arange(-20, 20, 0.5) U, V = np.meshgrid(X, Y)     fig, ax = plt.subplots() ax.quiver(X, Y, U, V) w = ax.invert_xaxis() ax.set_title('matplotlib.axes.Axes.invert_xaxis() \ Example', fontsize = 14, fontweight ='bold') plt.show()

输出:

范例2:

# Implementation of matplotlib function import matplotlib.pyplot as plt import numpy as np         x = np.linspace(0, 200, 10) yy = np.transpose([2 * np.sin(x + phi) for phi in x])     fig, ax = plt.subplots() ax.plot(yy) w = ax.invert_xaxis() ax.set_title('matplotlib.axes.Axes.invert_xaxis() \ Example', fontsize = 14, fontweight ='bold') plt.show()

输出:



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3