python - Adding water flow arrows to Matplotlib Contour Plot -


i generating groundwater elevation contour matplotlib. see below

here have now; how can add water flow arrows image below? enter image description here

i want add arrows make this: groundwater contour arrows

if has ideas and/or code samples appreciated.

you'll need recent (>= 1.2) version of matplotlib, streamplot this. need take negative gradient of head (a.k.a. "water table" surface aquifers) grid.

as quick example generated random point observations of head:

import numpy np scipy.interpolate import rbf import matplotlib.pyplot plt # make data repeatable np.random.seed(1981)  # generate random wells random head (water table) observations x, y, z = np.random.random((3, 10))  # interpolate these onto regular grid xi, yi = np.mgrid[0:1:100j, 0:1:100j] func = rbf(x, y, z, function='linear') zi = func(xi, yi)  # -- plot -------------------------- fig, ax = plt.subplots()  # plot flowlines dy, dx = np.gradient(-zi.t) # flow goes down gradient (thus -zi) ax.streamplot(xi[:,0], yi[0,:], dx, dy, color='0.8', density=2)  # contour gridded head observations contours = ax.contour(xi, yi, zi, linewidths=2) ax.clabel(contours)  # plot locations ax.plot(x, y, 'ko')  plt.show() 

enter image description here


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -