Open cstjean opened 6 years ago
What's :native
supposed to do? In GR this prints the dates fine without it for example.
Also, it's kind of hard to copy from a picture :)
plot([DateTime(2017, 1, 1), DateTime(2017, 2, 1)], [1, 3])
plot([DateTime(2017, 1, 1), DateTime(2017, 2, 1)], [1, 3]; ticks = :native)
See #1382
Date
s and DateTime
s are handled by a recipe within plots that converts them to a number via Dates.value
julia> dt = now()
2018-03-08T14:17:39.982
julia> Dates.value(dt)
63656201859982
julia> dt = now()
2018-03-08T14:18:10.296
julia> Dates.value(dt)
63656201890296
Usually Plots automatically generates ticks and corresponding tick labels (in form a Date
/ DateTime
string) and passes this information (numerical values and tick labels) to the backends.
Setting ticks = :native
where it's implemented (Plotly(JS) and PyPlot, I think) tells Plots not to calculate tick positions and labels but use the backend's native algorithms for this. So in that case for Dates the backend only gets the Dates.value
converted integer values without tick labels or any information that these numbers are supposed to represent dates.
The problem actually is not related to Date
s and DateTime
s but to the fact that ticks = :native
and specifying a tick formatter
do not work well together:
plot(rand(10), formatter = x -> 1000x, ticks = :native)
plot(rand(10), formatter = x -> 1000x)
I can fix the DateTimes issue, for Plotly at least not sure about the other backends.
It may be hard to implement the formatter with ticks = :native
. I think PyPlot wants special python formatters not julia functions so it's not something you can just pass to the backend?
With
plotlyjs
,The corresponding PlotlyJS code works fine. cc. @apalugniok