# Moving grid lines to foreground with contour

**URL:** <https://discourse.julialang.org/t/moving-grid-lines-to-foreground-with-contour/49275>\
**Category:** Visualization\
**Tags:** gmt\
**Created:** [October 30, 2020, 12:38am UTC](https://discourse.julialang.org/t/moving-grid-lines-to-foreground-with-contour/49275 "2020-10-30T00:38:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gideonsimpson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gideonsimpson/32/1928_2.png) [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Post date:** [October 30, 2020, 12:38am UTC](https://discourse.julialang.org/t/moving-grid-lines-to-foreground-with-contour/49275/1 "2020-10-30T00:38:27Z")

</div>

When using `contourf`, I’d like to move the grid lines to the foreground, but I can’t quite see how to do that. Thanks.

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [October 30, 2020, 7:28am UTC](https://discourse.julialang.org/t/moving-grid-lines-to-foreground-with-contour/49275/2 "2020-10-30T07:28:06Z")

</div>

You could just use transparency with eg alpha=0.5

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [October 30, 2020, 10:21pm UTC](https://discourse.julialang.org/t/moving-grid-lines-to-foreground-with-contour/49275/3 "2020-10-30T22:21:31Z")

</div>

Example below using GMT:

```julia
using GMT
G = GMT.peaks(N=100)
zmin, zmax = floor(Int,minimum(G)), ceil(Int,maximum(G))
colorstep = 0.1; contstep = 1; annotstep = 2;
C = makecpt(T=(zmin,zmax,colorstep), cmap=:rainbow);
contourf(G, C, cont=contstep, annot=annotstep;
        frame=(axes=(:left_full, :bot_full),),
        xaxis=(grid=1, annot=1, ticks=:auto, label="X [km]"),
        yaxis=(grid=1, annot=1, ticks=:auto, label="Y [km]") )
colorbar!(pos=(paper=true,anchor=(13,1),size=(10,0.5), vertical=true),
        frame=(annot=1, ticks=1, xlabel="Elevation [m]"), fmt=:png, show=true)

```

 ![GMTjl_contourf_with_grid_on_top](https://global.discourse-cdn.com/julialang/original/3X/b/0/b050513e7321d3eb1b5314c743cb68fc0fb285aa.png)

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [October 30, 2020, 11:30pm UTC](https://discourse.julialang.org/t/moving-grid-lines-to-foreground-with-contour/49275/4 "2020-10-30T23:30:18Z")

</div>

I don’t know if that can be done with Plots (GR), but I have been using `hline` and `vline` to add lines to form a grid in top of the other plots.

Example: [https://github.com/m3g/CKP/blob/master/disciplina/codes/lcells2.jl](https://github.com/m3g/CKP/blob/master/disciplina/codes/lcells2.jl)

 ![image](https://global.discourse-cdn.com/julialang/original/3X/7/8/78c0a48cc12fdf5a7e1022ed1b632b01f0629991.png)
