Matplotlib.artist.artist.properties()
Python matplotlib库的artist模块中的properties()方法用于获取artist的所有属性的字典。
语法:Artist.properties(self)
参数:该方法不接受任何参数。
这个方法返回artist的所有属性的字典。
下面的例子说明了matplotlib中的matplotlib.artist.artist.properties()函数:
示例1
# Implementation of matplotlib function
from matplotlib.artist import Artist
import numpy as np
import matplotlib.pyplot as plt
xx = np.random.rand(16, 30)
fig, ax = plt.subplots()
m = ax.pcolor(xx)
m.set_zorder(-20)
w = Artist.properties(ax)
print("Display all Properties\n")
for i in w:
print(i, ":", w[i])
fig.suptitle('matplotlib.artist.Artist.properties() \
function Example', fontweight ="bold")
plt.show()
输出:
示例2
# Implementation of matplotlib function
from matplotlib.artist import Artist
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(10**7)
geeks = np.random.randn(100)
fig, ax = plt.subplots()
ax.acorr(geeks, usevlines = True,
normed = True,
maxlags = 80, lw = 3)
ax.grid(True)
w = Artist.properties(ax)
print("Display all Properties\n")
for i in w:
print(i, ":", w[i])
fig.suptitle('matplotlib.artist.Artist.properties() \
function Example', fontweight ="bold")
plt.show()
输出: