Python matplotlib,ipywidgets-如何更改箭袋对象的位置?
我想根据ipywidgets滚动的交互输入更改箭袋(或箭头)对象的位置 以下是我尝试过的:Python matplotlib,ipywidgets-如何更改箭袋对象的位置?,python,matplotlib,plot,jupyter-notebook,ipywidgets,Python,Matplotlib,Plot,Jupyter Notebook,Ipywidgets,我想根据ipywidgets滚动的交互输入更改箭袋(或箭头)对象的位置 以下是我尝试过的: %matplotlib notebook from ipywidgets import * import numpy as np import matplotlib.pyplot as plt from matplotlib.patches import Ellipse, Arrow fig = plt.figure(figsize=[6,6]) ax = fig.add_subplot(1, 1, 1
%matplotlib notebook
from ipywidgets import *
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse, Arrow
fig = plt.figure(figsize=[6,6])
ax = fig.add_subplot(1, 1, 1)
x_ar1 = -5 #object distance
dy_ar1 = 2 #boject heightX
object1 = plt.quiver(x_ar1, 0, 0, dy_ar1, angles='xy', scale_units='xy', scale=1)
ax.add_artist(object1)
#mark axis
x_axis, = ax.plot([-10, 10], [0, 0], lw=1, c='k')
plt.xlim([-10,10])
plt.ylim([-5,5])
def update(x = -5, y = 2):
x_ar1 = x
dy_ar1 = y
object1.X = x_ar1
object1.V = dy_ar1
fig.canvas.draw_idle()
interact(update, x=(-6,6,0.1), y = (-2,2,0.1))
即使代码适用于箭袋的高度(
object1.V
),它也不适用于对象的放置(object1.X
)。我也看不到任何可用的set\uxy
功能。有人知道我在这里遗漏了什么吗?我认为matplotlib目前不允许这样做。看
唯一的API方法是set_UVC(),可用于更改箭头的大小、方向和颜色;实例化类时,它们的位置是固定的。这种方法可能在动画中很有用
Matplotlib上有此的开放功能请求: