Dense gridlines in Plots.jl

In a MWE

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.

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

2 Likes

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”)

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 ) all waiting as a nice project for a merry contributor.
Crossref to the issue you opened https://github.com/JuliaPlots/Plots.jl/issues/736

1 Like

OK many thanks and sorry for the dup!

1 Like