0

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.

r2evans
  • 141,215
  • 6
  • 77
  • 149
  • 1
    An additional issue might be your `temp` variable as `scale_fill_viridis` is also a continuous scale. But that's only a guess. If that will not fix your issue we need [a minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) including a snippet of your data or some fake data. – stefan Feb 07 '23 at 18:20
  • Please provide enough code so others can better understand or reproduce the problem. – Community Feb 07 '23 at 21:22
  • @stefan, seems like the issue was the continuity of temp. I fixed that, and it worked. – Aishwarya Iyer Feb 08 '23 at 19:46

0 Answers0