Hi guys,
I have a txt file with 4 columns. The first two (y,x) are coordinates and the last one (z) is density. Here's my input:
I tried something like that but without success:
Thanks for the help !!
I have a txt file with 4 columns. The first two (y,x) are coordinates and the last one (z) is density. Here's my input:
Output: y x h z
54.424013 -6.33163 210.9 2347.553
54.429837 -6.330484 198.9 2156.3
54.418983 -6.326504 193.8 2465.166
54.439936 -6.331769 178.6 2406.85
54.431123 -6.327935 175.6 2045.064
54.421964 -6.324441 169.2 2482.016
I'd like to use x,y,z to construct a gridd and plot using plt.contourf(x,y,z). The desired output is a figure that can be used like a map, showing the distribution of the density on the area delimited by the coordinates.I tried something like that but without success:
1 2 3 4 5 6 7 8 9 10 |
#!/usr/bin/env python3 import numpy as np from scipy.interpolate import griddata import matplotlib.pyplot as plt with open ( "lagan200.txt" , "r" ) as fh: y,x,h,z = np.loadtxt(fh, delimiter = ' ' ,usecols = [ 0 , 1 , 2 , 3 ], unpack = True ) zz = np.meshgrid(z, indexing = 'ij' ) test = plt.contourf(x,y,zz) |