Only plot a subset of x

@Albert_Zevelev, you can try the workflow herein.

using Dates, CSV, DataFrames, Plots; gr()
# link = "https://github.com/azev77/Synthetic_Control_in_Julia/raw/main/HP_q.csv"
df = CSV.read("HP_q.csv", DataFrame, missingstring="NA")
y = df[(df.loc .== "adelaide"), "HPGyy"]
t = df[(df.loc .== "adelaide"), "Date"]
t1 = Date.(t, dateformat"dduuuyyyy")
YrTick = year(minimum(t1)):year(maximum(t1))

plot(t1, y, lab="adelaide", color="green", xticks=false, legend=:topright)
plot!(xticks=(Date.(YrTick),YrTick),xtickfontsize=8,xlabel="Year", ylabel="HPGyy")
xaxis!(xrotation=45)

NB:

  • the years’ tick marks are placed at 01-Jan-YYYY, but this can be changed for any other preference.
  • Simplified date parsing using dateformat"dduuuyyyy" as per @pdeffebach’s example above
4 Likes