I have a 3-D surface plot that shows x and y coordinates and depths. I also have a 2-D contourf plot with x and y coordinates and the filled contours at the different locations. If I know the depths at the coordinates in the contourf plot, is there a way I can show the contours on the 3-D surface plot?
I have created a 3-D surface plot using plotly
with the code below:
import plotly.graph_objects as go
import oceansdb
import numpy as np
import matplotlib.pyplot as plt
Xa = np.linspace(29.005,29.405,200)
Ya = np.linspace(-93.6683,-93.2683,200)
db = oceansdb.ETOPO()
dcont = db['topography'].extract(lat=Xa, lon=Ya)
depth = dcont['height']
fig = go.Figure(data=[go.Surface(z=depth, x=Xa, y=Ya)])
fig.show()
Say my contourf plot can be created with the code below:
X = np.array([29.1,29.15,29.2,29.25])
Y = np.array([-93.5,-93.45,-93.4,-93.35])
r = np.array([0,0,0,2,3,0,0,6,7,8,9,1,9,0,0,0])
plt.figure()
plt.contourf(X,Y,r.reshape(len(X),len(Y)))
plt.show()
Assuming that the depth at each location can be determined using the oceansdb
module, can I overlay the contour plot on the surface plot at the correct depth?