第一个标题没有出现(Matplotlib)

我尝试添加标题,但是没有显示第一个“行”。

fig = plt.figure()
ax1 = fig.add_subplot(121,title="Lines")
ax2 = fig.add_subplot(122,title="Points")

men = Myclass(m,s,t,a)

total_i = 0
i = 0
ani = animation.FuncAnimation(fig,men.calculate,interval=1)
plt.show()

我尝试使用“ ax1.title.set_text(” Lines“),但没有帮助。

men.calculate():

...
ax1.clear()
ax2.clear()
plt.scatter(men.targets[[...,0]],men.targets[[...,1]],s=20)
linearray = men.targets[men.route]
linearray = np.append(linearray,[linearray[0]],axis=0)
ax1.plot(linearray[[...,linearray[[...,1]])
ax2.plot(linearray[[...,1]])
lyloney 回答:第一个标题没有出现(Matplotlib)

那很好。您可以显示代码和输出吗?

import matplotlib.pyplot as plt 
%matplotlib inline

fig = plt.figure()
ax1 = fig.add_subplot(121,title="Lines")
ax2 = fig.add_subplot(122,title="Points")

ax1.plot(list(range(10)),list(range(10)))
ax2.plot(list(range(10)),list(reversed(range(10))))

enter image description here

,

需要添加动画功能:

ax1.title.set_text("Lines")
ax2.title.set_text("Points")

之后:

ax1.clear()
ax2.clear()
本文链接:https://www.f2er.com/3166805.html

大家都在问