# Changing grid in Plots.jl?

**URL:** <https://discourse.julialang.org/t/changing-grid-in-plots-jl/38232>\
**Category:** New to Julia\
**Tags:** plots\
**Created:** [April 26, 2020, 11:23am UTC](https://discourse.julialang.org/t/changing-grid-in-plots-jl/38232 "2020-04-26T11:23:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [April 26, 2020, 11:23am UTC](https://discourse.julialang.org/t/changing-grid-in-plots-jl/38232/1 "2020-04-26T11:23:26Z")

</div>

Hello!

Basically I have something like this:

 ![image](https://global.discourse-cdn.com/julialang/original/2X/6/6e12d779b92a3b04f0f3e9a66174c563f163f279.png)

I want to make it into something like this, where the grey grid lines (so I want them removed as well) are replaced with the black ones I drew in paint:

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

Whenever I search “grid” on Google in connection with Julia it tells me about subplots etc. so I struggle a bit with finding the correct wording to do as I want.

Kind regards

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [April 26, 2020, 11:31am UTC](https://discourse.julialang.org/t/changing-grid-in-plots-jl/38232/2 "2020-04-26T11:31:11Z")

</div>

This works:

```julia
julia> plot(0:0.1:1, 0:0.1:1, xticks=[0,0.5,1], yticks=[0,0.5,1])

```

also have a look through these attributes:  
[http://docs.juliaplots.org/latest/generated/attributes\_axis/](http://docs.juliaplots.org/latest/generated/attributes_axis/)  
searching for “ticks” and “grid”.

---

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [April 26, 2020, 11:33am UTC](https://discourse.julialang.org/t/changing-grid-in-plots-jl/38232/3 "2020-04-26T11:33:46Z")

</div>

> [@mauro3](#):
>
> xticks=[0,0.5,1], yticks=[0,0.5,1]

Thanks for your simple solution, for now this is fine, but in the future it could be nice to have it as that, but keeping the axes.

Thanks for the link.

Kind regards

---

<div class="post-metadata">

**Author:** ![MA\_Laforge](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ma_laforge/32/385_2.png) [@MA\_Laforge](https://discourse.julialang.org/u/MA_Laforge)\
**Post date:** [April 27, 2020, 12:07am UTC](https://discourse.julialang.org/t/changing-grid-in-plots-jl/38232/4 "2020-04-27T00:07:47Z")

</div>

Indeed, it might be nice to have that feature added to Plots.jl. I suggest you open a new “issue” for your feature request in the Plots.jl repository:  
 → [GitHub · Where software is built](https://github.com/JuliaPlots/Plots.jl/issues)

Otherwise, the dev team may never add it to their “todo list”.

### (Temporary?) alternative:

In cases like this, you might want to look into tweaking the generated plot using backend-specific API. I am not familiar with all backends, but I can show an example with the InspectDR.jl backend ([GitHub - ma-laforge/InspectDR.jl: Fast, interactive Julia/GTK+ plots (+Smith charts +Gtk widget +Cairo-only images)](https://github.com/ma-laforge/InspectDR.jl)):

```julia-auto
using InspectDR
using Plots
using Colors
inspectdr()

plot(-1.4:0.1:1.4, -1.4:0.1:1.4)
pobj = gui() #Reference to InspectDR plot
splot = pobj.src.subplots[1] #Ref to subplot

#Add H/V markers @ origin:
black = RGB24(0, 0, 0)
markerline = line(color=black, style=:solid, width=3)
add(splot, hmarker(0, markerline))
add(splot, vmarker(0, markerline))
_frame = splot.layout[:frame_data]
    _frame.line = markerline #Match line from H/V markers
    splot.layout[:frame_data] = _frame #Must assign this way to "apply"

#Overwrite font because Plots.jl default font ("sans-serif") no longer
#properly supports UTF8 characters in newer Gtk distributions:
InspectDR.overwritefont!(splot.layout, fontname="Cambria")
InspectDR.refresh(pobj)

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/8/0/803f20119a7ef1cb9e75b6b2c766dca4121f37b5.png)

Note that the origin and grid lines will always display as desired, even if you pan/zoom in/out of the plot (ex: using ctrl+mousewheel or RMB+box-zoom)

### Adding InspectDR

Note: you will have to install/add InspectDR to your Julia environment to get this to work:

```julia-auto
] add InspectDR

```

### Alternative 2

Another alternative is, of course, to _ **directly** _ use the backend that best suits your needs in cases where the Plots.jl module cannot achieve what you are looking to do.

Don’t forget: you can still make a feature request by opening an “issue” in Plots.jl for the next time! Who knows? you might end up implementing the feature yourself!

---

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [April 27, 2020, 8:42am UTC](https://discourse.julialang.org/t/changing-grid-in-plots-jl/38232/5 "2020-04-27T08:42:43Z")

</div>

Thanks for your lengthy answer.

Nice to see that InspectDR can handle this case.

I might suggest it later on Github, but I would rather have them focus on other stuff. This was a bit of an edge case for me.

Kind regards
