(python) Matplotlib Animation Doesn't Show
Solution 1:
The problem is you are defining a plot initially with a single colour (1.0) so the colour range is set to this. When you update the figure, the range of colours is 1.0 +- some small value so you don't see the change. You need to set the colour range to between one and zero with vmin
/vmax
arguments as follows:
im = plt.imshow(viewport, animated=True, vmin=0., vmax=1.)
The rest of the code stays the same and this should work as expected. Another alternative is to add the call,
im.autoscale()
after im.set_array(viewpoint)
to force the colour range to be updated each time.
Solution 2:
The imshow
plot is initialized with one single value (1 in this case), so any value normalized to the range between 1 and 1 becomes the same color.
In order to change this, you may
- initiate the
imshow
plot with limits for the color (vmin=0, vmax=1
). initiate the
imshow
plot with a normalization instancenorm = matplotlib.colors.Normalize(vmin=0, vmax=1) im = plt.imshow(arr, norm=norm)
- Set the limits afterwards using
im.set_clim(0,1)
.
Solution 3:
Preferences > IPython Console > Graphics > Backend and change it from "Inline" to "Automatic"
Do not forget to restart you IDE (Spyder, PyCharm, etc.) after applying above change.
Cheers
:)
Post a Comment for "(python) Matplotlib Animation Doesn't Show"