# Overlay a contour over a heatmap

**URL:** <https://discourse.julialang.org/t/overlay-a-contour-over-a-heatmap/53586>\
**Category:** Visualization\
**Created:** [January 19, 2021, 6:58am UTC](https://discourse.julialang.org/t/overlay-a-contour-over-a-heatmap/53586 "2021-01-19T06:58:33Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)\
**Post date:** [January 19, 2021, 9:09am UTC](https://discourse.julialang.org/t/overlay-a-contour-over-a-heatmap/53586/2 "2021-01-19T09:09:02Z")

</div>

A solution with Makie [sorry is not with Plots]

```julia
using CairoMakie
f(x,y) = (x + 2y^2) * abs(sin(y) + cos(x))
x = y = 1:0.5:20
z = [f(x,y) for x in x, y in y]
fig = Figure(resolution=(750,300), fontsize = 14)
ax1 = Axis(fig, aspect = 1, xlabel = "x", ylabel = "y")
ax2 = Axis(fig, aspect = 1, xlabel = "x")
ax3 = Axis(fig, aspect = 1, xlabel = "x")
p1 = heatmap!(ax1, x, y, z, colormap = :Spectral)
contour!(ax2, x, y, z, color = :black, levels = 100:1:101) # contourf! also works... but with colormap
heatmap!(ax3, x, y, z, colormap = (:Spectral, 0.3))
contour!(ax3, x, y, z, color = :black, levels = 100:1:101)
cbar = Colorbar(fig, p1, width = 10, hight = Relative(0.8), ticklabelsize = 10)
limits!(ax2, 0,20,0,20)
hideydecorations!(ax2, grid = false)
hideydecorations!(ax3, grid = false)
fig[1,1] = ax1
fig[1,2] = cbar
fig[1,3] = ax2
fig[1,4] = ax3
save("./results/FigMixHeatContour.png", fig, px_per_unit = 2)
fig

```

 ![FigMixHeatContour](https://global.discourse-cdn.com/julialang/original/3X/1/c/1c58d7f5fbdc65fd6e39f6e8dbd436c7487a9860.png)

---

_[View the full topic](https://discourse.julialang.org/t/overlay-a-contour-over-a-heatmap/53586)._
