# Multiple x-axes with different ticks R

**URL:** <https://community.plotly.com/t/multiple-x-axes-with-different-ticks-r/70019>\
**Category:** Plotly R\
**Tags:** question\
**Created:** [November 17, 2022, 11:56pm UTC](https://community.plotly.com/t/multiple-x-axes-with-different-ticks-r/70019 "2022-11-17T23:56:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Npennell](https://avatars.discourse-cdn.com/v4/letter/n/3da27b/32.png) [@Npennell](https://community.plotly.com/u/Npennell)\
**Post date:** [November 17, 2022, 11:56pm UTC](https://community.plotly.com/t/multiple-x-axes-with-different-ticks-r/70019/1 "2022-11-17T23:56:00Z")

</div>

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](https://community.plotly.com/t/multiple-x-axes-with-different-ticks-depending-on-zoom-level/38634)) , 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

```

`
