I would like to increase the white space between the last data point on the two-line graphs and the secondary y-axis. Right now the endpoints are being squeezed to the extreme end. My graph is shown below.
I would like to increase the white space between the last data point on the two-line graphs and the secondary y-axis. Right now the endpoints are being squeezed to the extreme end. My graph is shown below.
You can accomplish this by adding blank spaces to the prefix of each of the y-axis tickmarks on the secondary y-axis. I've done this with some finance timeseries data below.
import pandas as pd
import plotly.graph_objects as go
from plotly.subplots import make_subplots
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv')
fig = make_subplots(specs=[[{"secondary_y": True}]])
fig.add_trace(go.Scatter(
x=df['Date'],
y=df['AAPL.High'],
name='AAPL High'),
secondary_y=False
)
fig.add_trace(go.Scatter(
x=df['Date'],
y=df['AAPL.Volume'],
name='AAPL Volume'),
secondary_y=True
)
## add as many spaces as desired
fig.update_yaxes(tickprefix = " ", secondary_y=True)
fig.show()