I have three lists that I want to use to make a contour plot. They are all length 8000. The x axis represents principal component 1 and the y axis represents principal component 2, the z axis is what I am trying to figure out how to generate.
For each x and y I have a % value in the third list ie 100% would equate to a denser contour whilst 0% would have no contour, but its currently just a list and im not sure how to convert it into a 2D array.
What i've done so far is:
import numpy as np
import matplotlib.pyplot as plt
def f(x):
return (x[:,0]**2 + x[:,1]**2)
x = list(finalDf['pc1'])
y = list(finalDf['pc2'])
xx, yy = np.meshgrid(x, y)
X_grid = np.c_[ np.ravel(xx), np.ravel(yy) ]
z = f(X_grid)
z = z.reshape(xx.shape)
plt.contour(xx, yy, z)
but the z values from my third list are not even included so not sure where to include them such that for each x,y there is an elevation/dense contour. I've read about interpolation but not sure how to implement it. From this, I want to then set a threshold where only points above a certain threshold show.