I’m trying to recreate a plot with multiple axis with different ticks as seen in a different users post (Multiple x-axes with different ticks depending on zoom level) , but in R.
The two plots by MaartenB are what am trying to create, but my plot is a grouped bar chart as opposed to stacked, but I can’t seem to get the same affect he has for his x-axis.
I’ve had a look at the R > Fundamentals > Multiple Axes pages but that has not helped.
This is the code I currently have:
`
set up
fig1 <- plot_ly()
2022
fig1 <- fig1 %>% add_trace(data = plot_data_2022, x = ~Order, y = ~Count,
type = 'bar', name = '2022',
hovertemplate = paste('<br>Week: %{x:.%}<br>',
'<b>Regisations that week: %{y:.%}</b>')
)
2023
fig1 <- fig1 %>% add_trace(data = plot_data_2023, x = ~Order, y = ~Count,
type = 'bar', name = '2023',
hovertemplate = paste('<br>Week: %{x:.%}<br>',
'<b>Regisations that week: %{y:.%}</b>')
)
format
fig1 <- fig1 %>% layout(title = "Members Number", barmode = 'group',
yaxis = list(title = "Count"),
xaxis = list(
title = "Date",
ticktext = seq(1:67),
tickvals = plot_data_2022$Order,
tickmode = "array"),
xaxis2 = list(ticktext = seq(10, 60, 10),
tickvals = seq(10, 60, 10),
tickmode = "array",
overlaying= 'x',
dtick = 7),
hovermode = "x unified")
call plot
fig1
`