plotly.R
plotly.R copied to clipboard
ggplotly does not preserve drawing order of elements defined by geom_rect
When creating a ggplot with geom_rect the order in which the data is provided is honored. Once converted via ggplotly the drawing order changes and therefore geom_rect objects may e.g. no longer be visible. I would expect that the display between the original plot and the converted plot are the same.
pltData <- read.csv('exampleBug.csv')
plt <- ggplot(data = pltData) +
geom_rect(aes(ymax = yMax, ymin = yMin,
xmax = xMax, xmin = xMin,
fill = TornadoCase))
# gives the desired bebaviour
plt
# changes drawing order
ggplotly(plt)