plotly.R
plotly.R copied to clipboard
xaxis/yaxis in layout of subplots does only apply to first subplot instead of all subplots
In https://plotly.com/r/subplots/#customizing-subplot-axes it is described, that xaxis/yaxis apply to all axis in the subplots.
After a figure with subplots is created using the subplot function, its axis properties (title, font, range, grid style, etc.) can be customized using the xaxis and yaxis graph object figure methods. By default, these methods apply to all of the x axes or y axes in the figure. The row and col arguments can be used to control which axes are targeted by the update.
As it can be seen at the example, it only aplies to the first subplot. A shorter example with the use of ggplotly is provided below. There the layout only works for the first row and first column.
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"))