I have a linegraph with twolines it in. On the x-Axis there is the time, on the y-Axes the values. On the y-Axis I want to set the space between the ticks manually.
I tried setting the values of the ticks manually, but that does not add/remove space/height of the ticks
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv')
df['Date']=pd.to_datetime(df['Date'])
dfg = df.groupby([pd.Grouper(key='Date', freq='M'), 'direction']).size().to_frame('counts')
dfg.reset_index(inplace=True)
layout = Layout(
title='Foo',
plot_bgcolor='rgba(0,0,0,0)',
yaxis = dict(
tickmode = 'array',
tickvals = [0, 0.5, 1, 1.5, ..., 5, 6, 7, ..., 10.5, 11, 11.5, 12, ...],
)
)
fig = go.Figure()
for d,c in zip(dfg['direction'].unique(), ['red','green']):
dfs = dfg.query('direction == @d')
fig.add_trace(
go.Scatter(
x=dfs['Date'],
y=dfs['counts'],
mode='lines',
line=dict(
color=c,
width=3
),
name=d
)
)
fig.show()
Note: The data I added here is not my real data. It's just some data to work with.
You need to scale your y data as you want, and then provide the ticks values and tick text
Assume:
y=[1,1.1,1.2,1.3,5,10,11,11.1,11.2,11.3]
y_trans=custom_trans(y) -> [1,2,3,4,5,6,7,8,9,10] # index
----------
go.Scatter(,y=y_trans,)
----------
fig.update_yaxes(
ticktext=["1", "1.1", "1.2", "5","10", ...],
tickvals=[1,2,3,5,6,..] #index position from y_trans
)
This is a very weird request though, and I would rather plot the difference in the two lines if it makes sense, or choose another method of visualizing, try log y axis?