Hi all,
I’m trying to create composite figures which involve a heatmap
as well as an overlying contour
. I’d like to control the aspect ratio, the contour thickness and the colorbars. I chose plotlyjs
backend of Plots
because it’s light and it allows to hover the mouse and pick the data values directly, which I find extremely useful.
However, I have some trouble controlling the appearance of the figure, in particular:
- the aspect ratio does not appear correct. Even with aspect_ratio=1.0, there is still a vertical exagerration (the circular contour appears as an ellipse).
- modifying the contour
linewidth
has no effect - once two data sets are used (one for
heatmap
, one forcontour
), the colorbar somehow merges the values of the two datasets. I have tried settingcolorbar=false
for the contour plot but this had no effect. - sometimes the contour does not appear on top of the heatmap
I have pasted a MWE below. Does anyone see obvious misuses? Is this an expected behaviour? Is there another (light) way to make such type of figures with Julia?
Cheers!
using Plots
plotlyjs()
function main()
# Mesh
x = LinRange(-2.0, 2.0, 100)
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()
p = heatmap!(x, y, f')
p = contour!(x, y, g', c=:black, linewidth=0.1) # contour does not appear on top of heatmap, colorbar is messed up, linewidth fails
p = plot!(aspect_ratio=1) # aspect ratio fails: does not seem 1.0 on my screen
display(p)
end
main()