# Dense gridlines in Plots.jl

**URL:** <https://discourse.julialang.org/t/dense-gridlines-in-plots-jl/1499>\
**Category:** Visualization\
**Tags:** question, plotting\
**Created:** [January 15, 2017, 6:52pm UTC](https://discourse.julialang.org/t/dense-gridlines-in-plots-jl/1499 "2017-01-15T18:52:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [January 15, 2017, 6:52pm UTC](https://discourse.julialang.org/t/dense-gridlines-in-plots-jl/1499/1 "2017-01-15T18:52:13Z")

</div>

In a MWE

```julia
using Plots
x = Date(1990,1):Dates.Month(1):Date(2016,1)
y = [rand()+1.0 for _ in x]
plot(x, y)

```

how could I get vertical grid lines at every year (eg on Jan 1) or every 5 years in the plot? Using various backends I get 1 or 2.

---

<div class="post-metadata">

**Author:** ![tbreloff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbreloff/32/68_2.png) [@tbreloff](https://discourse.julialang.org/u/tbreloff)\
**Post date:** [January 15, 2017, 8:04pm UTC](https://discourse.julialang.org/t/dense-gridlines-in-plots-jl/1499/2 "2017-01-15T20:04:38Z")

</div>

> [@Tamas\_Papp](#):
>
> y = [rand()+1.0 for \_ in x]

```julia
plot(x, y, xticks=map(Int,filter(d->Dates.month(d)==1&&Dates.year(d)%5==0, x)))

```

![](https://global.discourse-cdn.com/julialang/original/3X/7/d/7d3ee6db79faed13bb06f9d4280be94a5ffafef0.png)

---

<div class="post-metadata">

**Author:** ![Samuel\_Danthine](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samuel_danthine/32/4168_2.png) [@Samuel\_Danthine](https://discourse.julialang.org/u/Samuel_Danthine)\
**Post date:** [March 16, 2017, 11:34am UTC](https://discourse.julialang.org/t/dense-gridlines-in-plots-jl/1499/3 "2017-03-16T11:34:05Z")

</div>

Hello

rerunning a series of plots this morning to correct the titles, and all grid lines are suddenly plain black (they were dash grey yesterday). Only thing I can figure is it is linked to this new warning I got:

sys:1: MatplotlibDeprecationWarning: The set\_axis\_bgcolor function was deprecated in version 2.0. Use set\_facecolor instead.

I use Plots with the Pyplot backend. Any clues as to how to change the grid lines back? (And in general, change the grid line styling.

Many thanks  
Samuel

My code:  
using Plots  
pyplot()  
x1=dfhedge[:Date]  
x2=Dates.format(x1, “yy”)

plot(dfhedge[:Date], dfhedge[:USEqhedgedInd], label=“US Equity Hedged”, color=“blue”, linestyle=:dash,title=“Dollar equity portfolio cum. performance, Unhedged vs. Hedged”,  
xlabel=“year”,  
ylabel=“Index, December 1980=1”,  
xticks = (x1[1:8:szh], x2[1:8:szh]),xtickfont = font(10, “Courier”))

plot!(dfhedge[:Date], dfhedge[:EqIUSCHFNorm], label=“US Equity in CHF”, color=“Red”,linestyle=:solid)  
savefig(“USEq.pdf”)

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [March 16, 2017, 12:18pm UTC](https://discourse.julialang.org/t/dense-gridlines-in-plots-jl/1499/4 "2017-03-16T12:18:10Z")

</div>

`Pkg.checkout("Plots")`. This is due to matplotlib taking a major version jump (to 2.0.0), something that Plots have no control over. But Plots master implements a dashed line. There is a desire to give larger control of grid lines to the user (see the discussion here: [https://github.com/JuliaPlots/Plots.jl/pull/721](https://github.com/JuliaPlots/Plots.jl/pull/721) ) all waiting as a nice project for a merry contributor.  
Crossref to the issue you opened [https://github.com/JuliaPlots/Plots.jl/issues/736](https://github.com/JuliaPlots/Plots.jl/issues/736)

---

<div class="post-metadata">

**Author:** ![Samuel\_Danthine](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samuel_danthine/32/4168_2.png) [@Samuel\_Danthine](https://discourse.julialang.org/u/Samuel_Danthine)\
**Post date:** [March 16, 2017, 12:41pm UTC](https://discourse.julialang.org/t/dense-gridlines-in-plots-jl/1499/5 "2017-03-16T12:41:48Z")

</div>

OK many thanks and sorry for the dup!
