# Remove weekend gaps from volume bar subplot

**URL:** <https://community.plotly.com/t/remove-weekend-gaps-from-volume-bar-subplot/52063>\
**Category:** Plotly R\
**Created:** [April 15, 2021, 7:30pm UTC](https://community.plotly.com/t/remove-weekend-gaps-from-volume-bar-subplot/52063 "2021-04-15T19:30:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rjmarshall17](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@rjmarshall17](https://community.plotly.com/u/rjmarshall17)\
**Post date:** [April 15, 2021, 7:30pm UTC](https://community.plotly.com/t/remove-weekend-gaps-from-volume-bar-subplot/52063/1 "2021-04-15T19:30:24Z")

</div>

Hi,

I am creating the attached chart in Jupyter notebook. I had seen that you should change the type of the xaxis to “category” to get rid of the weekend gaps. It seems to have worked for the OHLC subplot but not for the volume bar chart. How do I remove the gaps in the bar chart?

Thanks,

Rob

 ![chart](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/8/8640006a8d5654107f49ef8e9a050eb20c67314f.png)

---

<div class="post-metadata">

**Author:** ![rjmarshall17](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@rjmarshall17](https://community.plotly.com/u/rjmarshall17)\
**Post date:** [April 15, 2021, 7:35pm UTC](https://community.plotly.com/t/remove-weekend-gaps-from-volume-bar-subplot/52063/2 "2021-04-15T19:35:37Z")

</div>

Below is the code I’m using (Python3):

> import plotly.graph\_objects as go  
> import pandas\_ta as ta  
> from datetime import datetime, timedelta  
> import pandas as pd  
> import yfinance  
> from plotly.subplots import make\_subplots  
> from plotly.offline import init\_notebook\_mode  
> from [plotly.io](http://plotly.io) import write\_image  
> init\_notebook\_mode()
> 
> amzn = yfinance.Ticker(‘AMZN’).history(‘max’)  
> start = (datetime.now() - timedelta(days=90)).strftime(‘%Y-%m-%d’)  
> end = datetime.now().strftime(‘%Y-%m-%d’)  
> amzn.ta.willr(append=True)  
> amzn.ta.sma(length=7, append=True)  
> amzn.ta.sma(length=20, append=True)

> fig = make\_subplots(rows=3, cols=1,  
> shared\_xaxes=True,  
> vertical\_spacing=0.05,  
> subplot\_titles=(‘OHLC’, ‘Volume’,“Williams %R”),  
> row\_heights = [1000,500,500],  
> )
> 
> fig.add\_trace(go.Ohlc(x=amzn.loc[start:end].index,  
> open=amzn.loc[start:end][‘open’],  
> high=amzn.loc[start:end][‘high’],  
> low=amzn.loc[start:end][‘low’],  
> close=amzn.loc[start:end][‘close’],  
> name=‘OHLC’),  
> row=1,col=1)
> 
> fig.add\_trace(go.Bar(x=amzn.loc[start:end].index,  
> y=amzn.loc[start:end][‘volume’],  
> showlegend=False),  
> row=2, col=1)
> 
> sma7 = go.Scatter(x=amzn.loc[start:end].index,  
> y=amzn.loc[start:end][‘SMA\_7’],  
> mode=‘lines’,  
> name=‘SMA 7’)  
> fig.add\_trace(sma7, row=1, col=1)
> 
> sma20 = go.Scatter(x=amzn.loc[start:end].index,  
> y=amzn.loc[start:end][‘SMA\_20’],  
> mode=‘lines’,  
> name=‘SMA 20’)  
> fig.add\_trace(sma20, row=1, col=1)
> 
> fig.add\_trace(go.Scatter(x=amzn.loc[start:end].index,  
> y=amzn.loc[start:end][‘WILLR\_14’],  
> showlegend=True),  
> row=3,  
> col=1)
> 
> fig.update\_layout(xaxis={‘type’: ‘category’},xaxis\_rangeslider\_visible=False, width=1000, height=800)  
> write\_image(fig, “/home/rob/tmp/chart.png”,format=‘png’)  
> fig.show()
