How can I plot 2D xyz data?

  python

I’m trying to plot Magnetic field(x)-current(y)-resistance(z) in 2d resistance map data. I have Magnetic field – Resistance data with current value variable.
example example1 is the data that I want to get.
Following is the code that I tried.

import numpy as np
import matplotlib.pyplot as plt
import csv
import scipy.interpolate

def M_Rxy_curve_variable_method(location, name_format, temperature, variable_startpoint, variable_endpoint, step, variable_unit, measurement_method) :
for i in np.arange(variable_startpoint, variable_endpoint, step) :
    x=[]
    y2=[]
    z=[]
    with open("{0}{1}_{2}_{3}{4}_{5}.txt".format(location, name_format, temperature, round(i,2), variable_unit, measurement_method),"r",encoding="utf-8") as txtfile : 
        txtfile = txtfile.readlines()[2:]
        plots = csv.reader(txtfile, delimiter = ',')
        for row in plots : 
            x.append(float(row[1]))
            z.append(float(row[3])/i)
            z = ([i/(min(y2)) for i in z])
            y2.append(float(i))
            xi, yi = np.linspace(min(x), max(x)), np.linspace(min(y2), max(y2))
            xi, yi = np.meshgrid(x, y2)
        rbf = scipy.interpolate.Rbf(x, y2, z)
        zi = rbf(xi, yi)
        plt.imshow(zi, vmin=min(z), vmax=max(z), origin='lower',extent=[min(x), max(x), min(y2), max(y2)])
        plt.scatter(x,y2,c=z)
plt.colorbar()
plt.show()

Upper part is for importing data.
Following pics are the data.
data
data

Source: Python Questions

LEAVE A COMMENT