- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我刚刚开始为我的 matplotlib 补丁制作动画。在我当前的工作中,我想显示一个可视化,其中存在一个随时间改变其大小的楔子。然而,我得到了一个静态楔子,其原因超出了我的想象。
#!/usr/bin/env python
import numpy as np
from matplotlib import pyplot as plt
from matplotlib import animation
import matplotlib.patches
# First set up the figure, the axis, and the plot element we want to animate
fig = plt.figure()
ax = plt.axes(xlim=(-2, 2), ylim=(-2, 2))
plt.grid(True)
# patch_one = matplotlib.patches.Circle((0, 0), 1)
patch_one = matplotlib.patches.Wedge((0,0), 1, -10, 10)
# initialization function: plot the background of each frame
def init():
patch_one.radius = 1
ax.add_patch(patch_one)
return patch_one,
# animation function. This is called sequentially
def animate(i):
patch_one.radius +=i*0.0001
return patch_one,
# call the animator. blit=True means only re-draw the parts that have changed.
anim = animation.FuncAnimation(fig, animate, init_func=init,
frames=200, interval=20, blit=True)
plt.show()
我通过用圆形补丁替换 patch_one 来尝试代码,它确实有效(在代码中将该部分注释掉)。
最佳答案
代码似乎需要两个小改动:
# animation function. This is called sequentially
def animate(i):
patch_one.r +=i*0.0001
patch_one._recompute_path()
return patch_one,
为什么:
属性r
定义半径,没有属性radius
。另一方面,您可以(并且可能应该)使用方法 set_radius()
。
由于某种原因,需要手动调用内部方法_recompute_path
来重新计算实际路径。
后一个似乎是源代码中的遗漏,方法set_radius
可以调用_recompute_path
。然而,有更聪明的人(至少@tcaswell)可能能够判断这是否是一个错误或者是否有其他问题发生。
(顺便问一下,您确定要说 patch_one.r += i*0.0001
吗?动画看起来有点奇怪。也许您的意思是 patch_one.r = 1 + i*.0001
?)
关于python - Matplotlib.patches.Wedge 动画不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25207432/
我正在编写一个 C# POS(销售点)系统,它从键盘磁卡读卡器获取输入。这意味着它从磁条上读取的任何数据都可以像在键盘上快速输入一样输入。目前,我通过附加到 KeyPress 事件并寻找一系列包含刷卡
事实证明annularWedge graphs 包的函数不能将半径 0 用作内半径。您必须改用wedge。 对我来说,内半径 0 只是 annularWedge 的退化情况,并且应该表现得像 wedg
我刚刚开始为我的 matplotlib 补丁制作动画。在我当前的工作中,我想显示一个可视化,其中存在一个随时间改变其大小的楔子。然而,我得到了一个静态楔子,其原因超出了我的想象。 #!/usr/bin
我有以下代码: var text = new Kinetic.Text({ text: carNames, fontFamily: 'Calibri', fontSize: 1
我正在尝试创建一个“馅饼楔”。我不擅长。自从我开始尝试以来已经很长时间了。我看过很多示例,并在 JS 中完成了这个代码生成器: var startPointX = 200; var startPoin
我的 Android 应用因以下错误而崩溃: ERROR/dalvikvm(7051): HeapWorker is wedged: 10037ms spent inside Lcom/android
我正在从服务器获取大量数据。我正在使用 Get 方法获取响应并且我能够获得响应,但问题是由于某些"HeapWorker is wedged" 错误,在解析应用程序之间崩溃。 逻辑猫 12-20 10:
我即将购买 Metrologic Quantim T 条码扫描器,它配备了 RS232、Keyboard Wedge 或 USB。我将需要创建一个程序来从这个扫描仪读取数据,并试图做出选择的决定。所以
我是一名优秀的程序员,十分优秀!