Can't format plot ticks when Dates or strings are used as input

ultrapoci
Fri, 25 Aug 2023 10:48:09 +0000
General Usage

Consider this piece of code:

using Plots
plot(1:10, rand(10), xformatter = x -> "asd")

This correctly produces a plot where the ticks on the X axis are all the string “asd”.

If we instead do this:

using Plots
plot(string.(1:10), rand(10), xformatter = x -> "asd")

The X axis is not formatted anymore: the ticks are the number 1 to 10. The same happens if instead of strings, I use Date/Time/DateTime objects. How can I format plot ticks when using these objects?

4 posts - 3 participants