I have some data where I want to plot some quantity (ordinate) against dates (abscissa). The abscissa data are in
Dates.Date() format. When plotting (I tested Plots with unicodeplots back-end), the dates are given in seconds (I guess), and not in year-month-day.
Is there a way to specify that I want the time in year-month-day format? If so, can I specify the interval along the axis? [E.g., only the dates that occur in the data, or, say every 2 weeks?]
I can’t help with Plots.jl, but VegaLite.jl has pretty comprehensive support for time scales. I think the combination of the docs there and the original vega-lite docs should have enough info on that feature to make it work.
Also, see these examples by GMT
It’s supposed to be automatic in Plots - showing it in seconds would be a bug, but could also be a limitation of the unicodeplots backend. You can always format the x axis yourself by passing a function specifying what you want to the
Hm… seems like the problem lies with the UnicodePlots backend:
- The data:
- The plot using UnicodePlots as backend:
- With PyPlot as backend:
Here is my solution:
using Plots.PlotMeasures, LaTeXStrings
DateTick2= Dates.format.(DateTick, "d u Y")
Plots.plot!(Plot1, clim.Date[1:clim.N_Climate], clim.Pet[1:clim.N_Climate])
Plots.plot!(Plot1, xticks=(DateTick, DateTick2), xrotation=rad2deg(pi/3), framestyle = :origin)
I am using Godfly for my plots .and I want to represent the X-axis with months, the result I want to show in the plot is one-year data with an hourly resolution, and I want to represent the x-axis in terms of months that hours.