May-17-2022, 03:52 PM
(This post was last modified: May-17-2022, 05:22 PM by deanhystad.)
Quote:I didn't understand what is the usage of set_array(x,y)In the animation demo, and my subsequent reuse of that code, set_array(x, y) changes the data displayed in the plot.
This code change the values stored in the QuadMesh object self.mesh.
self.mesh.set_array(self.data[:-1, :-1, level].flatten())When the plot is redrawn, it displays the new values.
self.figure.canvas.draw()Your code does something different. Your code creates a new QuadMesh object.
ax.pcolormesh(x, y, layer, cmap=newcmp, edgecolor='lightgrey', linewidth=0.003)This not only changes the data in the QuadMesh object (actually creates a new QuadMesh object), but it reconfigures the plot. The new plot might have different range. The labels might change.
The result is not much different. You see a plot of the new data. But your code is doing a lot more work then mine. This isn't really noticeable for your application, but it would be very noticeable if you had the plot changing several times a second. If I wanted to make a plot of real-time values, like an oscilloscope, I would not be pleased with the extra delay introduced by reconfiguring the entire plot each time I just added some now signal points.