Plots.jl plotly heatmap labels

I’d like to create a large heatmap using Plots.jl and plotly. which should look like this, where all y axis labels are shown, these align with the tool tip, and if I zoom in I get an increased granularity of the x axis dates (this also occurs with the y axis).

Made with `PlotlyJS.jl
using Dates, PlotlyJS
start_date = DateTime(2021, 1, 1)
rr =  rand(100,36)
xaxis = start_date:Dates.Month(1):start_date+Dates.Month(36)
yaxis = 15:115 |> collect .|> string
plot(heatmap(x=xaxis, y=yaxis, z=rr))

My understanding of Plots.jl is that if axis labels are given as strings they should all be shown, however, this is not the case. Here I get the following, note not all y labels are shown, if I zoom I don’t get any increased granularity (this also applies to the x axis), also the tool tip is less helpful with it not showing a date or a valid y axis label.

Made with `Plots.jl
using Dates, Plots
plotlyjs()
start_date = DateTime(2021, 1, 1)
rr =  rand(100,36)
xaxis = start_date:Dates.Month(1):start_date+Dates.Month(36)
yaxis = 15:115 |> collect .|> string
heatmap(xaxis, yaxis, rr)

How can I produce something like the top figure with Plots.jl?

In Plots.jl, you could try the following code:

using Dates, Plots; plotlyjs()

start_date = DateTime(2021, 1, 1)
rr =  rand(100,36)
xaxis = start_date:Dates.Month(1):start_date+Dates.Month(36)
DateTick = Dates.format.(xaxis, "yyyy-mm")
x = 1:length(xaxis)
yaxis = 15:115
heatmap(x, yaxis, rr, ticks=:native, xticks=(x,DateTick), xtickfontsize=5, xrot=45)

2 Likes

Thank you that’s great.