Plots... with Dates along abscissa axis?

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.

1 Like

Also, see these examples by GMT

1 Like

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 xformatter argument.

Hm… seems like the problem lies with the UnicodePlots backend:

Here is my solution:

			using Plots.PlotMeasures, LaTeXStrings
				using Plots;pgfplotsx()
				using Dates

         DateTick=Date[1]:Day(30):Date[N_Climate]
         DateTick2= Dates.format.(DateTick, "d u Y")

	Plot1=Plots.plot(layout=1)
	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)

1 Like

Hay
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.