1

I'm trying to animate a scatter-plot and a line graph in parallel using matplotlib.

First, I plot the two pieces separately:

deaths_scatter = ax.scatter(all_episode_labels_list, all_episode_deaths_list, picker=5, label="Deaths")
death_line = ax.plot(all_episode_labels_list, all_episode_deaths_list)

Next, I set the visible window to the first range desired.

ax.axis([-.2, 9.5, -0.1, 12])

Finally, I define the update and animation functions, which should slowly pan the x-axis. This part works with just the scatter-plot...

def update(frames):

    ax.axis([frames, frames + 10, -0.1, 12])
    return deaths_scatter, 


ani = animation.FuncAnimation(fig, update, frames=list(range(0,80)), interval=1000, blit=True)

...but If I add the line graph it breaks

def update(frames):

    ax.axis([frames, frames + 10, -0.1, 12])
    return deaths_scatter, death_line,

 AttributeError: 'list' object has no attribute 'get_zorder'

I've attempted to search overflow and the web for a solution, but I haven't had any luck yet. Any help is greatly appreciated!

JKolb
  • 23
  • 6

0 Answers0