Matplotlib.axes.axes.invert_yaxis() - 反转y轴

Matplotlib.axes.axes.invert_yaxis()

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

函数:Matplotlib.axes.axes.invert_yaxis()

matplotlib库的Axes模块中的Axes.invert_yaxis()函数用于反转y轴。

语法:Axes.invert_yaxis(self)

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

Returns:该方法不返回任何值。

下面的例子演示了matplotlib.axes.axes.invert_yaxis()函数在matplotlib.axes中的作用:

示例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_yaxis()
ax.set_title('matplotlib.axes.Axes.invert_yaxis() \
Example', fontsize = 14, fontweight ='bold')
plt.show()

输出:

Matplotlib.axes.axes.invert_yaxis()

示例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_yaxis()
ax.set_title('matplotlib.axes.Axes.invert_yaxis()\
 Example', fontsize = 14, fontweight ='bold')
plt.show()

输出:

Matplotlib.axes.axes.invert_yaxis()

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程