My variable data
is a 3-column data which describes a regular grid of (x, y) and its respective z-value. I would like to represent this data in a contour plot. My code is below:
import tkinter as tk
from tkinter import filedialog
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
root = tk.Tk()
root.withdraw()
filepath = filedialog.askopenfilename()
data = pd.read_excel(filepath)
data = np.array(data, dtype=np.float)
X, Y = np.meshgrid(data[:, 0], data[:, 1])
_X, Z = np.meshgrid(data[:, 0], data[:,2])
plt.figure()
cp = plt.contour(X, Y, Z)
plt.show()
This is what I get:
I do not wish to use any interpolation function as seen in Make contour of scatter since my data is already interpolated.
What am I doing wrong?