plotly.R icon indicating copy to clipboard operation
plotly.R copied to clipboard

ggplotly does not preserve drawing order of elements defined by geom_rect

Open janlimbeck opened this issue 2 years ago • 0 comments

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.


exampleBug.csv

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)


image

image

janlimbeck avatar Jun 13 '22 09:06 janlimbeck