-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Like to make very interactive plotting to fit parameters of real data #4
Comments
I have been checking how to solve that. I think the best approach is to use async calls[1], as the simulation to do the fitting typically it won't be less than hundred of ms. This is the code for the notebook import matplotlib.pyplot as plt
import numpy as np
import asyncio
import time
%matplotlib widget from ipywidgets import interact, interactive def quick_plot(p):
x = np.linspace(0, 2*np.pi, 200)
y = np.sin(x/(p))
time.sleep(0.01) # imagingary thing takes 10 ms
loop = asyncio.get_event_loop()
loop.create_task(update(x, y));
fig = plt.figure(figsize=(5,3))
async def update(x, y):
await asyncio.sleep(0.0)
plt.clf()
plt.plot(x, y)
fig.canvas.draw()
ui = interactive(quick_plot,p=(0.01,2,0.01))
display(ui) The other option to do it even faster is to use blit to avoid re-draw[2]-[3]. But instead of going that route, what I think it will be better is to encapsulate this on a class or similar for future use. [1]https://stackoverflow.com/questions/63384326/how-to-update-interactive-figure-in-loop-with-jupyterlab/63517891#63517891 |
Or maybe check this library, that apparently does that for different types of plots. |
I made the Multi2T plots interactive with controls. |
Tandem3T plots are also now interactive with controls. |
No description provided.
The text was updated successfully, but these errors were encountered: