# Plotlyjs and composite figures

**URL:** <https://discourse.julialang.org/t/plotlyjs-and-composite-figures/97320>\
**Category:** General Usage\
**Tags:** plots, plotlyjs\
**Created:** [April 10, 2023, 9:35pm UTC](https://discourse.julialang.org/t/plotlyjs-and-composite-figures/97320 "2023-04-10T21:35:50Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![Gravlax](https://avatars.discourse-cdn.com/v4/letter/g/dbc845/32.png) [@Gravlax](https://discourse.julialang.org/u/Gravlax)\
**Post date:** [April 12, 2023, 9:33pm UTC](https://discourse.julialang.org/t/plotlyjs-and-composite-figures/97320/7 "2023-04-12T21:33:41Z")

</div>

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?

 ![image](https://global.discourse-cdn.com/julialang/original/3X/a/3/a319ddd32d8edff2dc5c11a5c34fe8c102ec0620.png)

```julia
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](https://discourse.julialang.org/t/overlay-a-contour-over-a-heatmap/53586/2). 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.

---

_[View the full topic](https://discourse.julialang.org/t/plotlyjs-and-composite-figures/97320)._
