我在matplotlib中有散点图
import matplotib.pyplot as plt
fig, ax = plt.subplots()
scatter = ax.scatter([0], [0])
scatter.remove() # remove the scatter from figure是否有一种scatter方法可以将它(返回)添加到图形中?
发布于 2017-11-20 15:02:14
散射是一个matplotlib.collections.PathCollection。若要将此类集合添加到轴中,请使用ax.add_collection
ax.add_collection(scatter)完整的例子:
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
scatter = ax.scatter([0], [0])
scatter.remove()
ax.add_collection(scatter)
plt.show()发布于 2017-11-20 15:08:48
如果您不想实际将其从绘图中删除,则可以使用以下方法将散射设置为不可见:
scatter.set_visible(False)
然后稍后使用:
scatter.set_visible(True)
把它带回来。
例如:
import matplotib.pyplot as plt
fig, ax = plt.subplots()
scatter = ax.scatter([0], [0])
scatter.set_visible(False)
# Do something
scatter.set_visible(True)https://stackoverflow.com/questions/47394923
复制相似问题