Setting X Axis Using Plots

I’m trying to plot stock prices which are daily but not on weekends. When I run this code

using Dates, DataFrames, Plots
df = DataFrame(Date=today()+Month(-1):Day(1):today(), rtn = rand(Float64, 32))
ticks = round.(df.Date, Week(1)) |> unique
delete!(df, [10, 11, 17, 18])
       plt = Plots.plot(df.Date, df.rtn,
             xlabel = "Date",
             ylabel = "Cumulative Return",
             xticks = (ticks, Dates.format.(ticks, "mm/dd/yy")),
             xlims = Dates.value.([df.Date[1], df.Date[end]]),
             xrot = 60,
             color = :red,

The labels for the x axis go off the scale. Shouldn’t xlim take care of this?

No, the two are independent of each other, consider:

julia> plot(rand(5), 
            xlims = (0, 3), xticks = (1:0.1:4, string.(1:0.1:4)), 
            right_margin =, xrot = 50)

which gives


here I’ve deliberately made the problem worse by adding to the right_margin. You see that as long as there are ticklabels provided in xticks and there’s space on the figure (which I control here by right_margin), ticks will be shown.