Gridding and ploting - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: Gridding and ploting (/thread-1653.html) |
Gridding and ploting - Felipe - Jan-18-2017 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'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: #!/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)Thanks for the help !! RE: Gridding and ploting - Larz60+ - Jan-18-2017 Check the following to see if they may be of help (all but the last use matplotlib) http://matplotlib.org/mpl_toolkits/mplot3d/tutorial.html http://matplotlib.org/examples/pylab_examples/contour_demo.html http://matplotlib.org/examples/mplot3d/contour3d_demo3.html https://plot.ly/python/3d-surface-plots/ RE: Gridding and ploting - Felipe - Jan-19-2017 (Jan-18-2017, 12:39 PM)Larz60+ Wrote: Check the following to see if they may be of help (all but the last use matplotlib) Thanks !! I'll try this. |