# How to plot heat maps with grid lines in \`Plots.jl\` with \`GR\` as backend?

**URL:** <https://discourse.julialang.org/t/how-to-plot-heat-maps-with-grid-lines-in-plots-jl-with-gr-as-backend/91996>\
**Category:** General Usage\
**Tags:** plotting, plots\
**Created:** [December 22, 2022, 10:13am UTC](https://discourse.julialang.org/t/how-to-plot-heat-maps-with-grid-lines-in-plots-jl-with-gr-as-backend/91996 "2022-12-22T10:13:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![singularitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/singularitti/32/17678_2.png) [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Post date:** [December 22, 2022, 10:13am UTC](https://discourse.julialang.org/t/how-to-plot-heat-maps-with-grid-lines-in-plots-jl-with-gr-as-backend/91996/1 "2022-12-22T10:13:37Z")

</div>

For example, the following code will produce a heat map:

```julia
using Plots

heatmap(rand(4, 4))

```

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

How do I add the grid lines between each of the squares? The option `grid = true` does not work.

---

<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:** [December 22, 2022, 10:30am UTC](https://discourse.julialang.org/t/how-to-plot-heat-maps-with-grid-lines-in-plots-jl-with-gr-as-backend/91996/2 "2022-12-22T10:30:11Z")

</div>

You can use `vline!` and `hline!`:

```julia
using Plots

M = rand(4, 5)
heatmap(M)
m, n = size(M)
vline!(0.5:(n+0.5), c=:black)
hline!(0.5:(m+0.5), c=:black)

```

And the usual line attributes: `ls=:dash`, etc.
