Update image in for loop #417
Answered
by
kushalkolar
anderssonf
asked this question in
Q&A
-
Is it possible to update an image in a for loop? Something similar to drawnow in matlab? |
Beta Was this translation helpful? Give feedback.
Answered by
kushalkolar
Mar 5, 2024
Replies: 1 comment 12 replies
-
Yes, an animation function, this applies for any graphic. See "Image updates" in the # create a `Plot` instance
plot_v = Plot()
# make some random data
data = np.random.rand(512, 512)
# plot the data
plot_v.add_image(data=data, name="random-image")
# a function to update the image_graphic
# a plot will pass its plot instance to the animation function as an argument
def update_data(plot_instance):
new_data = np.random.rand(512, 512)
plot_instance["random-image"].data = new_data
#add this as an animation function
plot_v.add_animations(update_data)
# show the plot
plot_v.show() |
Beta Was this translation helpful? Give feedback.
12 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think the easiest way for you to do this right now is using two separate processes and sending the data to be plotted over zmq: https://github.com/fastplotlib/fastplotlib/tree/main/examples/notebooks/multiprocessing_zmq