I'm using matplotlib to draw a 3d heatmap by drawing a 3d scatter plot where the color of each data point corresponds to how often it occurs. I want to increment the values in "freq" as the program reads my data and dynamically update the graph. There are functions like ".set_xdata()" to update the scatter plot's "x" but I couldn't find a similar function to update the scatter plot's "c". This is what I'm currently doing and it's slow and crashes after a while:
location = 0
for row in df.itertuples(index=False):
location = row[4]+4*row[5]+16*row[6]
color_freq[location] += 1
ax.scatter(xs, ys, zs, c=color_freq, s=300)
ax.draw_artist(ax.patch)
fig.canvas.update()
fig.canvas.flush_events()
Instead of doing "ax.scatter(xs, ys, zs, c=color_freq, s=300)" I would like to just update the "c" variable. Any ideas? Thanks.