I have been trying to create a hourly heatmap with ggplot with a 8760x32 dataframe. Here each row corresponds to an hour, and each row to one of the facet grid rows I wanted to create.
I initially encountered the error "Discrete value supplied to continuous scale" while adding the scale_y_continuous(trans="reverse", breaks = unique(NewRoom$time))
portion of the code. I fixed it by ensuring y was numeric, and now the code wherein p is created, and x and y axes are added runs smoothly.
However, when I attempt to plot p, it still shows me the same error. Why could that be? I'd appreciate inputs.
I'm attaching my code below
p <- ggplot(NewRoom,aes(date,time,fill=temp)) +
geom_tile(color= "white",size=0.1) +
scale_fill_viridis(name="Hrly Temps C",option ="C")
p <- p + facet_grid(Bdrmno~month)
p <- p + scale_y_continuous(trans="reverse", breaks = unique(NewRoom$time))
p <- p + scale_x_continuous(breaks =c(1,10,20,31))
I tried to fix the code by adding the scale_y_continuous
and scale_x_continuous
components. However, though now it allows me to add these components, which it did not before, it still provides the same error when I plot the heatmap.