'Interact and plot quiverin Python Jupyter Notebook
I would like to use the interact function to create sliders where the user would input vector coordinates and plot these coordinates. The problem is that changing the input values doesn't make a new graph, would it be possible to make it work?
I'm working with jupyter notebook. My code
import panel as pn
import numpy as np
import matplotlib.pyplot as plt
from panel.interact import interact, interactive, fixed, interact_manual
pn.extension()
def f(u1,u2,v1,v2):
plt.clf()
vetores = np.array([[0,0,u1,u2], [u1,u2,v1,v2]])
X, Y, U, V = zip(*vetores)
plt.figure()
ax = plt.gca()
ax.quiver(X, Y, U, V, angles='xy', scale_units='xy', scale=1, color = ['r','g','b'])
ax.set_xlim([min(-1,u1-1, v1-1), max(u1+v1+1, v1+1)])
ax.set_ylim([min(-1,u2-1, v2-1), max(u2+v2+1, v2+1)])
plt.show()
interact(f, u1=2, u2=0, v1=2, v2=3)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
