Thanks for the help! I’ve tried adapting the MWE. I would like to use contour
instead of scatter
(for the purpose of contouring another field than the one represented with a heatmap
).
It seems that adding a contour (the 0/1 boundary) erases the underlying heatmap and overprints the colorbar.
Would there be a way to draw the contour line on top of the heatmap and not to link the contour to the colorbar?
Also, while forcing the aspect ratio to avoid vertical exagerration, is there a way to crop out the additional grey space out of the xaxis_range/yaxis-range?
using PlotlyJS
# Mesh
x = LinRange(-2.0, 2.0, 200)
y = LinRange(-1.0, 1.0, 100)
Lx, Ly = x[end]-x[1], y[end]-y[1] # Added after edit
# One continuous field
f = 1e3.*exp.(-x.^2 .- (y').^2)
# One discontinuous field
g = zero(f)
g[(x.^2 .+ (y.^2)') .< 0.5^2] .= 1.0
# Compose figure
p = Plot([heatmap(x=x, y=y, z=f', colorscale=colors.plasma, colorbar_thickness=24),
contour(x=x, y=y, z=g', mode="lines",
line_width=2, colorscale=[[1, "rgb(255,255,255)"]])],
Layout(width=600, height=600*Ly/Lx,
xaxis_range=[-2,2], yaxis_range=[-1,1], yaxis_scaleanchor="x", yaxis_scaleratio=1))
display(p)
EDIT: the contour overlying a heatmap issue is also discussed there. I have just tested the proposed Plots solution. It involves using clim to rescale the colobar while drawing the contour. This work with gr() but does not seem to work with plotlyJS().
EDIT: add transpose of in the heatmap and defined Lx and Ly for aspect ratio.