Matplotlib.artist.artist.set()
Python matplotlib库的artist模块中的set()方法是一个批处理属性setter方法。传递kwargs来设置属性。
语法:Artist.set(self, **kwargs)
参数:此方法不接受**kwargs以外的任何参数。
Returns:该方法不返回任何值。
下面的例子演示了matplotlib中的matplotlib.artist.artist.set()函数:
示例1
# Implementation of matplotlib function
from matplotlib.artist import Artist
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
t = np.arange(0.0, 2, 0.001)
s = 1 + np.sin(8 * np.pi * t)*0.4
fig, ax = plt.subplots()
ax.plot(t, s)
Artist.set(ax, xlabel ='X-Axis', ylabel ='Y-Axis',
xlim =(0, 1.5), ylim =(0.5, 1.5),
title ='matplotlib.artist.Artist.set() function Example')
ax.grid()
plt.show()
输出:
示例2
# Implementation of matplotlib function
from matplotlib.artist import Artist
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(19680801)
fig, ax = plt.subplots()
x, y, s, c = np.random.rand(4, 200)
s *= 200
ax.scatter(x, y, s, c)
Artist.set(ax, xlabel ='X-Axis', ylabel ='Y-Axis',
xlim =(0, 0.5), ylim =(0, 0.5),
title ='matplotlib.artist.Artist.set() function Example')
ax.grid()
plt.show()
输出: