Python中的 Matplotlib.axis.Axis.have_units()函数
Matplotlib是Python中的一个库,它是 NumPy 库的数值数学扩展。它是Python中用于二维数组图的惊人可视化库,用于处理更广泛的 SciPy 堆栈。
Matplotlib.axis.Axis.have_units()函数
matplotlib 库的轴模块中的Axis.have_units()函数用于检查单位是否设置在任何轴上。
Syntax: Axis.have_units(self)
Parameters: This method does not accepts any parameter.
Return value: This method return True if units are set on any axis.
下面的示例说明了 matplotlib.axis 中的 matplotlib.axis.Axis.have_units()函数:
示例 1:
Python3
# Implementation of matplotlib function
from matplotlib.axis import Axis
import matplotlib.pyplot as plt
fig, axs = plt.subplots()
axs.plot([1, 2, 3])
axs.set_title("Units are set on any axis : "
+str(axs.xaxis.have_units()))
fig.suptitle('matplotlib.axis.Axis.have_units() \
function Example\n', fontweight ="bold")
plt.show()
Python3
# Implementation of matplotlib function
from matplotlib.axis import Axis
import matplotlib.pyplot as plt
fig, ax1 = plt.subplots( )
ax1.set_xscale("log")
ax1.set_yscale("log")
ax1.set_adjustable("datalim")
ax1.plot([1, 3, 34, 4, 46, 3, 7, 45, 10],
[1, 9, 27, 8, 29, 84, 78, 19, 48],
"o-", color ="green")
ax1.set_xlim(1e-1, 1e2)
ax1.set_ylim(1, 1e2)
w = Axis.have_units(ax1.yaxis)
print("Value Return by have_units() :", w)
fig.suptitle('matplotlib.axis.Axis.have_units() \
function Example\n', fontweight ="bold")
plt.show()
输出:
示例 2:
Python3
# Implementation of matplotlib function
from matplotlib.axis import Axis
import matplotlib.pyplot as plt
fig, ax1 = plt.subplots( )
ax1.set_xscale("log")
ax1.set_yscale("log")
ax1.set_adjustable("datalim")
ax1.plot([1, 3, 34, 4, 46, 3, 7, 45, 10],
[1, 9, 27, 8, 29, 84, 78, 19, 48],
"o-", color ="green")
ax1.set_xlim(1e-1, 1e2)
ax1.set_ylim(1, 1e2)
w = Axis.have_units(ax1.yaxis)
print("Value Return by have_units() :", w)
fig.suptitle('matplotlib.axis.Axis.have_units() \
function Example\n', fontweight ="bold")
plt.show()
输出: