Matplotlib.artist.artist.format_cursor_data()
Python matplotlib库的artist模块中的format_cursor_data()方法用于获取数据的字符串表示形式。
语法:Artist.remove_callback(self, data)
参数:该方法接受以下参数。
- data:该参数是用于使用的数据。
Returns:该方法返回数据的字符串表示形式。
下面的例子演示了matplotlib中的matplotlib.artist.artist.format_cursor_data()函数:
示例1
# Implementation of matplotlib function
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.artist import Artist
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,
Artist.format_cursor_data(ax, data = geeksx))
fig.suptitle('matplotlib.artist.Artist.format_cursor_data()\
function Example', fontweight ="bold")
plt.show()
输出:
示例2
# Implementation of matplotlib function
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.artist import Artist
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,
Artist.format_cursor_data(ax,
data = geeksx))
fig.suptitle('matplotlib.artist.Artist.format_cursor_data()\
function Example', fontweight ="bold")
plt.show()
输出: