Matplotlib.artist.artist.remove()
Python matplotlib库的artist模块中的remove()方法 在可能的情况下,用于将artist从图形中移除。
语法: Artist.remove(self)
参数:该方法不接受任何参数。
返回: 该方法返回删除artist后的图像。
下面的例子说明了matplotlib中的matplotlib.artist.artist.remove()函数:
示例1
# Implementation of matplotlib function
from matplotlib.artist import Artist
import matplotlib.pyplot as plt
fig, axs = plt.subplots()
axs.plot([1, 2, 3])
# use of remove() method
Artist.remove(axs)
fig.suptitle("""matplotlib.artist.Artist.remove()
function Example""", fontweight="bold")
plt.show()
输出:
示例2
# Implementation of matplotlib function
from matplotlib.artist import Artist
import matplotlib.pyplot as plt
fig, (axs, axs2) = plt.subplots(2, 1)
gs = axs2.get_gridspec()
# use of remove() method
Artist.remove(axs)
axbig = fig.add_subplot(gs[1:, -1])
axbig.annotate("Removed one Axes",
(0.4, 0.5),
xycoords ='axes fraction',
va ='center')
fig.suptitle("""matplotlib.artist.Artist.remove()
function Example""", fontweight="bold")
plt.show()
输出: