I have a dataframe in which I have 3 columns each representing latitude, longitude and elevation of the point.
I would like to create a bathymetric map of the seabed. With the code below I obtain the following map:
Df2D = pd.read_csv(r'C:\Users\Thomas\Desktop\Df.csv', header = 0, delimiter=';')
Y = Df2D['lat'].values
X = Df2D['lon'].values
Z = Df2D['elevation'].values
plt.scatter(X,Y, c=Z)
plt.colorbar()
plt.show()
Now, however, I would like to add contours to precise values (e.g., 0m, -10m,-50m,...) to have a more detailed map of the seabed. I tried with plt.tricontour but the result is not so good, also because it shows only one contour :
plt.tricontour(X, Y, Z, 0, linewidths=0.5, colors='k')
plt.tricontourf(X, Y, Z, 0)
Any ideas to increase the final result?
First, I'm not sure if tricontour
is what you're after or just contour
. You didn't talk about triangulation in your post.
But either way, after specifying X, Y, Z
, in both these functions the next arg is called levels
. If you pass an integer n
here (in your case, 0
), the contour plot will have at most n+1
levels. If instead you pass an array, it will use the values of the array as levels.
Long story short, replace 0
with [0, -10, -50, -100]
to get contour lines at exactly those levels.