Here is what my data looks like:
A tibble: 6 x 6
DATE_OF_DAMAGE countweight month dayn day week
1 2017-08-01 00:00:00 1747. Aug Tue 1 31
2 2017-07-25 00:00:00 1673. Jul Tue 25 30
3 2017-07-19 00:00:00 1659. Jul Wed 19 29
4 2017-07-26 00:00:00 1619. Jul Wed 26 30
5 2017-07-12 00:00:00 1616. Jul Wed 12 28
6 2017-06-27 00:00:00 1604. Jun Tue 27 26
Using this plot code I am able to generate a calendar over the year, however when I use ggplotly
the facet spacing gets messy.
cal<-ggplot(as.data.frame(DIRT_temporal),aes(x=dayn, y=week)) + geom_tile(aes(fill=countweight)) +
#coord_equal(ratio = 1) +
scale_fill_viridis(guide_legend(title="Weighted Count"))+
facet_wrap(~month, nrow=3,scales="free") +
geom_text(aes(label=day), color="white", size=3) +
# hide y-axis ticks and labels
theme(axis.ticks.y = element_blank()) +
theme(axis.text.y = element_blank()) +
# hide main x and y-axis titles
theme(axis.title.x = element_blank()) +
theme(axis.title.y = element_blank()) +
# move x-axis labels (week names) to top, hide ticks
scale_x_discrete(position = "top") +
theme(axis.ticks.x = element_blank()) +
# move panel title (month names) outside (above week names)
theme(strip.placement = "outside") +
theme(strip.text.x = element_text(size = "14", hjust = 0)) +
# center-aligned plot title
ggtitle("Title") +
theme(plot.title = element_text(size = "16", hjust = 0.5),
plot.margin=unit(c(10,10,10,10),"points")
)
Now when I use
ggplotly(cal"
it results in different cell sizes and moving the labels. How can I fix this to be an interactive replicate of the ggplot2 output?