如何在python中创建用户界面

如何在python中创建用户界面,python,3d,matplotlib,Python,3d,Matplotlib,我需要做一个用户界面,在那里我可以改变点的位置,箭头从它出来,也可以改变箭头的值。例如:该点位于xyz(0,0,0)上,现在我希望它位于xyz(0,1,1)上,箭头也是如此 我已经做到了 from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np from itertools import product, combinations fig = plt.figure() ax

我需要做一个用户界面,在那里我可以改变点的位置,箭头从它出来,也可以改变箭头的值。例如:该点位于xyz(0,0,0)上,现在我希望它位于xyz(0,1,1)上,箭头也是如此

我已经做到了

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
from itertools import product, combinations
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.set_aspect("equal")

#draw cube
r = [-1, 1]
for s, e in combinations(np.array(list(product(r,r,r))), 2):
    if np.sum(np.abs(s-e)) == r[1]-r[0]:
        ax.plot3D(*zip(s,e), color="b")

#draw a point
ax.scatter([0],[0],[0],color="g",s=100)

#draw a vector
from matplotlib.patches import FancyArrowPatch
from mpl_toolkits.mplot3d import proj3d

class Arrow3D(FancyArrowPatch):
    def __init__(self, xs, ys, zs, *args, **kwargs):
        FancyArrowPatch.__init__(self, (0,0), (0,0), *args, **kwargs)
        self._verts3d = xs, ys, zs

    def draw(self, renderer):
        xs3d, ys3d, zs3d = self._verts3d
        xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
        self.set_positions((xs[0],ys[0]),(xs[1],ys[1]))
        FancyArrowPatch.draw(self, renderer)

a = Arrow3D([0,1],[0,1],[0,1], mutation_scale=20, lw=1, arrowstyle="-|>", color="k")
b = Arrow3D([0,1],[0,0],[0,0], mutation_scale=20, lw=1, arrowstyle="-|>", color="r")
c = Arrow3D([0,0],[0,0],[0,1], mutation_scale=20, lw=1, arrowstyle="-|>", color="b")
d = Arrow3D([0,1],[0,1],[0,0], mutation_scale=20, lw=1, arrowstyle="-|>", color="g")
e = Arrow3D([0,1],[0,0],[0,1], mutation_scale=20, lw=1, arrowstyle="-|>", color="c")
f = Arrow3D([0,0],[0,-0.5],[0,0], mutation_scale=20, lw=1, arrowstyle="-|>", color="m")

ax.add_artist(a)
ax.add_artist(b)
ax.add_artist(c)
ax.add_artist(d)
ax.add_artist(e)
ax.add_artist(f)
plt.show()

但是现在我需要为我做一个用户界面,以便能够更改点的位置和每个箭头的值。

到目前为止,您尝试了什么?你到底坚持什么?我们通常会帮助解决特定问题,而不是“为我写这个”类型的问题。尝试向我们展示绘制多维数据集的特定代码片段,然后展示您希望绘制6个向量的操作-查看更新!!非常感谢。那么问题是什么?如何绘制立方体和箭头,或者如何使用用户界面(手动)更改对象的位置?是 啊现在我需要使用用户界面来更改对象的位置!:我不知道怎么做!也许考虑编辑标题和第一段。毕竟,你似乎已经解决了你在那里要求的所有问题。