Python中的 Matplotlib.axis.Axis.format_cursor_data()函数
Matplotlib是Python中的一个库,它是 NumPy 库的数值数学扩展。它是Python中用于二维数组图的惊人可视化库,用于处理更广泛的 SciPy 堆栈。
matplotlib.axis.Axis.format_cursor_data()函数
matplotlib库的axis模块中的axis.format_cursor_data()函数用于获取数据的字符串表示。
Syntax: Axis.format_cursor_data(self, data)
Parameters: This method accepts the following parameters.
- data: This parameter is the data which is used to be used.
Return value: This method return the string representation of data.
下面的示例说明了 matplotlib.axis 中的 matplotlib.axis.Axis.format_cursor_data()函数:
示例 1:
Python3
# Implementation of matplotlib function
from matplotlib.axis import Axis
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(10**7)
geeksx = np.random.randn(10)
fig, ax = plt.subplots()
ax.plot(geeksx)
ax.text(1.5, 0.85,
"Value return by format_cursor_data():",
fontweight ="bold")
ax.text(0, 0.7,
Axis.format_cursor_data(ax, data = geeksx))
fig.suptitle("""matplotlib.axis.Axis.format_cursor_data()
function Example\n""", fontweight ="bold")
plt.show()
Python3
# Implementation of matplotlib function
from matplotlib.axis import Axis
import numpy as np
import matplotlib.pyplot as plt
geeksx = np.array([24.40, 110.25, 20.05,
22.00, 61.90, 7.80,
15.00])
fig, ax = plt.subplots()
ax.plot(geeksx, 'go-')
ax.text(1, 95,
"Value return by format_cursor_data():",
fontweight ="bold")
ax.text(1.3, 85,
Axis.format_cursor_data(ax,
data = geeksx))
fig.suptitle("""matplotlib.axis.Axis.format_cursor_data()
function Example\n""", fontweight ="bold")
plt.show()
输出:
示例 2:
Python3
# Implementation of matplotlib function
from matplotlib.axis import Axis
import numpy as np
import matplotlib.pyplot as plt
geeksx = np.array([24.40, 110.25, 20.05,
22.00, 61.90, 7.80,
15.00])
fig, ax = plt.subplots()
ax.plot(geeksx, 'go-')
ax.text(1, 95,
"Value return by format_cursor_data():",
fontweight ="bold")
ax.text(1.3, 85,
Axis.format_cursor_data(ax,
data = geeksx))
fig.suptitle("""matplotlib.axis.Axis.format_cursor_data()
function Example\n""", fontweight ="bold")
plt.show()
输出: