The 2D array I'm using to plot a horizontal line seems fine - range of x-values, y-values are all ones - but when I plot it through a class and FuncAnimation it is a stationary diagonal line across the plot.
I've tried transposing the array, and getting rid of the variable and just hard coding the data directly into set_data([],[]). I've altered my code slightly numerous times but I don't know what's causing the plot to do this.
lineX = np.linspace(0, 1, n)
lineY = np.ones(n)
lid = np.array((lineX, lineY))
simulation = practiceSim(pos, vel, r, m, lid)
fig = plt.figure(figsize = (10,5), dpi = 100)
fig.subplots_adjust(left=0, right=0.97)
simulation_ax = fig.add_subplot(111, aspect='equal', autoscale_on = False)
particles, = simulation_ax.plot([], [], 'ko')
line, = simulation_ax.plot([], [], 'b')
def init_anim():
particles.set_data([],[])
line.set_data([],[])
return particles, line
def animate(i):
global simulation
simulation.advance(dt)#, lineVel)
particles.set_data(simulation.pos[:,0], simulation.pos[:,1])
particles.set_markersize(0.5)
simulation.rad *= i
simulation.lid[:,0] -= simulation.rad
line.set_data(simulation.lid[:,0], simulation.lid[:,1])
line.set_markersize(2)
return particles, line
N = 1000
anim = FuncAnimation(fig, animate, frames = N, interval=10, blit=False,
init_func = init_anim)
plt.show()