Plotlyjs and composite figures

I can’t reproduce your exact code as Lx and Ly are not defined in the pasted code you gave so an error is thrown.
You should be able to to remove the fill of the contour zones and have just the coloring of the contour lines controlled by the line_color attribute by adding to your countour call the following kwarg: contours_coloring="none".
So your contour call above would be:

contour(x=x, y=y, z=g', mode="lines", line_width=2, contours_coloring="none")

Note: I removed the colorscale to contour as if you set contours_coloring to "none" no colorbar is generated and the color of the line of the contour is not controlled by the colorscale but by line_color.

Edit: I just noted you also asked how to crop out the extra space in the axis. You can do this by changing the constrain parameter of the xaxis inside Layout to "domain".

Here is an example in Pluto:

And here is the code modified to use PlotlyJS as you do instead of PlutoPlotly.

using PlotlyJS
# Mesh
x = LinRange(-2.0, 2.0, 200)
y = LinRange(-1.0, 1.0, 100)
# 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=1, contours_coloring="none")],
	Layout(width=600, height=320,
		xaxis = attr(;
			range = [-2,2],
			constrain = "domain",
		),
		yaxis = attr(;
			range = [-1,1],
			scaleanchor = "x",
			scaleratio = 1,
		)
	))
display(p)
1 Like