I have two different plots, one heatmap and a contour plot, and I would like to put the contour on top of the heatmap. The z-value for each of the plots correspond to different quantities.
import plotly.graph_objects as go
fig1=go.Figure(go.Heatmap(
x=data.X,
y=data.Y,
z=data0.Z1, zsmooth='best',
colorscale='Viridis'
), layout=layout)
fig2=go.Figure(go.Contour(
x=data.X,
y=data.Y,
z=round(data.Z2,3),
zmin=0,
zmax=0.3,
contours_coloring='lines',
line_width=2,
colorscale=[[0,'blue'],[0.5,'black'],[1,'red']],
contours=dict(
start=0, end=0.01, size=1)
), layout=layout)
In Altair I could just use fig1 + fig2 but that does not work with Plotly. Unfortunately Altair does not have any contour capabilities. If this is not possible with Plotly, could this be achieved with matplotlib?
Edit: here is a data example
ls = [[-0.1,-3.0,-0.5,0.0],[-0.1,-2.0,-0.25,0.2],[-0.1,-1.0,-0.15,0.25],[-0.1,0.0,0,0.3],[-0.1,1.0,0.1,0.25],[-0.1,2.0,0.25,0.2],[-0.1,3.0,0.5,0.0],[0.0,-3.0,-0.5,0.0],[0.0,-2.0,-0.25,0.1],[0.0,-1.0,-0.15,0.11],[0.0,0.0,0.0,0.1],[0.0,1.0,0.1,0.0],[0.0,2.0,0.25,0.0],[0.0,3.0,0.5,0.0],[0.1,-3.0,-0.5,0.0],[0.1,-2.0,-0.5,0.12],[0.1,-1.0,-0.15,0.12],[0.1,0.0,0.0,0.13],[0.1,1.0,0.1,0.12],[0.1,2.0,0.5,0.12],[0.1,3.0,0.5,0.0]]
data = pd.DataFrame(ls, columns=['X', 'Y', 'Z1', 'Z2'])
contours_coloring='lines', also could you provide a sample of the dataset in order to check if my proposition would work? If you could provide details of the environment you're working on I may also be able provide some plotly advicecontours_coloring='lines'allows to show colored lines on an empty background, i.e. without the underlying heatmap. You make look at the documentation to see an example: contour lines . I will edit my post later today to provide you with some of the data. I didn't put any because I didn't think it was relevant in this case.