[英]Contour plot with 2 arrays and a third containing chi-squared in python
I have the chi-squared for all values of: 我具有以下所有值的卡方值:
kT=linspace(0.01,0.11,10)
v=linspace(0.05,0.5,10)
where:
KT=[]
V=[]
for i in range(len(kT)):
for u in range(len(v)):
KT.append(kT[i])
V.append(v[u])
Therefore I have: 因此,我有:
KT=asarray(KT)
V=asarray(V)
x=asarray(x)
Where x[0]
is the chi-squared for (kT[0],v[0])
, and x[1]
is the chi-squared for (kT[0],v[1])
其中
x[0]
是(kT[0],v[0])
的卡方, x[1]
是(kT[0],v[1])
的卡方
etc... 等等...
So as an overview, I have 1D arrays of len=100
, where kT[0]
and v[0]
gives x[0]
(this is done in another program). 因此,作为概述,我有
len=100
一维数组,其中kT[0]
和v[0]
给出x[0]
(这在另一个程序中完成)。
I want to plot the chi-squared as a contour plot, how do I go about this? 我想将卡方图绘制为轮廓图,该如何处理? I tried using the contour from plt.contour, but it was x as a 2D vector.
我尝试使用plt.contour中的轮廓,但它是x作为2D向量。
Any advice? 有什么建议吗?
You can reshape
your array 您可以
reshape
阵列
x2d = x.reshape(10, 10)
contour
accepts vectors for grid coordinates. contour
接受矢量作为网格坐标。 you can therefore omit the double loop and use kT
and v
directly 因此,您可以省略双循环并直接使用
kT
和v
pyplot.contour(v, kT, x2d)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.