【问题标题】:Plotting convergence of points on top of a contour plot in Python在 Python 中绘制等高线图顶部的点收敛
【发布时间】:2020-04-27 18:56:25
【问题描述】:

我在 Python 中为优化算法制作了等高线图。现在,我无法在 Python 中绘制迭代点。我的 (x,y) 点存储为数组中的向量。这是一个例子:

[array([-1, -2]), array([ 0.93396226, -0.45283019]), array([2.86792453, 1.09433962]),...]

如何使用 matplotlib 在现有的等高线图上绘制这些点?

进一步解释:我有这个数组。它们代表 x 和 y 坐标。我想将这些 (x,y) 坐标放在等高线图的顶部。

【问题讨论】:

标签: python python-3.x matplotlib plot graphing


【解决方案1】:

我认为,您正在寻找类似的东西:

import pylab as plt

# ....

a = [array([-1, -2]),
 array([ 0.93396226, -0.45283019]),
 array([2.86792453, 1.09433962]),...]
x = array(a)[:, 0]
y = array(a)[:, 1]

# some contourf stuff

plt.scatter(x, y)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-27
    • 2023-03-22
    • 1970-01-01
    • 1970-01-01
    • 2012-03-25
    • 2020-05-18
    • 1970-01-01
    相关资源
    最近更新 更多