- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在研究博客上的一个示例 post关于使用 matplotlib 绘制动画。
一个涉及等高线图的示例 - 代码如下。但是,当我运行此代码时,我收到一个 UserWarning
UserWarning: No contour levels were found within the data range.
warnings.warn("No contour levels were found")
该图的代码如下。
x = np.linspace(-3,3,91)
t = np.linspace(0,25,30)
y = np.linspace(-3,3,91)
X3, Y3, T3 = np.meshgrid(x,y, t)
sinT3 = np.sin(2*np.pi*T3/T3.max(axis=2)[...,np.newaxis])
G = (X3**2 + Y3**2)*sinT3
contour_opts = {'levels': np.linspace(-9, 9, 10),
'cmap':'RdBu', 'linewidths': 2}
cax = ax.contour(x, y, G[..., 0], **contour_opts)
def animate(i):
ax.collections = []
ax.contour(x, y, G[..., i], **contour_opts)
anim = FuncAnimation(fig, animate, interval=100, frames = len(t)-1)
HTML(anim.to_html5_video())
该情节仍然有效,但我不断收到该用户警告。
我检查了matplotlib文档,发现levels参数仍然是正确的名称。所以不确定是什么导致了这个错误。
最佳答案
0 的正弦值为 0。因此,您得到一个完整的 G
切片,即第一个 G[:,:,0]
,它全为零在里面。零不是级别之一,但即使是,也没有定义绘制常量数组的轮廓(完整的表面应该是轮廓线吗?)
因此 matplotlib 会正确警告您此帧中没有要绘制的轮廓。
关于python - matplotlib 等高线图 : warning about `no contour levels were found` ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48408123/
我试图理解 findContours 的输出基于 this one 等教程和文档。我想知道为什么我得到我得到的输出。我有一个中间有一个正方形的 jpeg img,我的目标是找到正方形并为其着色(只是为
我有一组数据,其中包含 x 和 y 坐标以及每个坐标的计算值。网格是不规则的,所以现在我一直在创建一个散点图并将值分成多个箱子,以显示为下面链接中 img 上的等高线。 http://i.stack.
这个问题在这里已经有了答案: Test if a numpy array is a member of a list of numpy arrays, and remove it from the
我有一个存储为栅格的高程图。我想将平滑的“vector ”曲线拟合到恒定高度的轮廓。在我的应用程序中,数据实际上是地理海拔,但问题可以推广到两个变量的任何函数。 如果有帮助,我可以生成另一个具有抗锯齿
我想生成一个带有颜色条的等高线图/热图,然后添加一个注释框。这个数字很丑,但得到了我想要的: add_subplot() 是不够的。如果我尝试将所有内容都放在同一个子图中,则该框会被遮盖。我可以通过使
我正在尝试使用属于 ROOT 的 Minuit2 最小化器为具有物理限制的参数生成等高线图数据分析框架。不幸的是,当我尝试生成等高线图时,Minuit2 似乎有意将参数漂移到超出其限制的区域: >>>
我的目标是这种效果:(仅水平轮廓线): 我确实找到了 this example ,但是它会创建水平 和 垂直轮廓线。我无法完全理解如何调用 fwidth()正在生成线条。 uniform float
大家好,我是编程新手,我正在尝试做一些可能非常明显的事情,但对于我来说,我无法弄明白。我有一系列 x、y、z 数据(在我的例子中,对应于距离、深度和 pH 值)。我想使用 matplotlib 在 x
我是一名优秀的程序员,十分优秀!