'How to change tickmode for all subplots of facet_grid

I want to change the tickmode of all xaxis/yaxis in all subplots to "auto" but the number of subplots changes. I tried the following code. It works for the first col/row. How do I make it work for all cols/rows?

ggplot(data = mtcars, aes(x = hp, y = mpg, color = am)) +
  geom_point() +
  facet_grid(cyl ~ gear, labeller = label_both) +
  theme_light()
ggplotly() %>% layout(xaxis = list(tickmode = "auto"), yaxis = list(tickmode = "auto"))

I found some code for python, but it seems that the for_each_xaxis() function doesn't exist in R.

tia



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source