python - Plotting contours from data csv -
i have data within csv file temperature, x, y , z points arranged in columns. z points can negated remains 0 through data acquisition.
i'd obtain contour plot of data.
my problem same this got redirected other threads still couldn't figure out going on.
edit: here's unfinished code should open data? don't know go here.
import numpy np import matplotlib.pyplot plt matplotlib.mlab import griddata import csv data = np.genfromtxt('tempcontour0.csv', delimiter=',', dtype=[('t',float),('x',float),('y',float),('z',float)],usecols=(0,1,2)) t=data['t'] x=data['x'] y=data['y'] z = np.zeros((len(x),2)) z[:,0] = x z[:,1] = y plt.contour() plt.show()
the data file so:
t,x,y,z 316.002,0,0,0 309.314,0.00839113,0,0 309.67,0.0172418,0,0 310.34,0.0265772,0,0 310.903,0.0364239,0,0 311.558,0.0468098,0,0 312.704,0.0577645,0,0 313.582,0.0693192,0,0 314.582,0.0815067,0,0 316.2,0.0943616,0,0 317.391,0.107921,0,0 318.93,0.122222,0,0 322.662,0.137307,0,0 325.549,0.153218,0,0 339.193,0.17,0,0 338.943,0,0.0208333,0 341.134,0.00839113,0.0208333,0 341.692,0.0172418,0.0208333,0
first have read file like:
numpy import genfromtxt import numpy np import matplotlib.pyplot plt data = genfromtxt('file.csv', delimiter = ',')
then need plot need know how reshape array, instance looks data goes 15 x values before incrementing in y so:
x = data[:, 1].reshape(15, yincrement) y = data[:, 2] .reshape(15,yincrement) z = data[:,0].reshape(15,yincrement) plt.contour(x,y,z) plt.show()
Comments
Post a Comment