Reputation: 185
I'm finding the solution to adjust the distance of y axis in plotly using python. Which parameter in plotly can help me to perform it?
This is for changing the tick value and tick name but I do not know how to disable auto-margin for y axis and change their distance.
import plotly.graph_objs as go
import pandas as pd
from plotly.offline import init_notebook_mode, iplot
from plotly.graph_objs import *
init_notebook_mode(connected=True)
This is the sample data
Time = {'trace1':[0.02123456,0.14564545,0.01456445,0.914564],
'trace2':[0.14564564,0.00245646,0.0045646,0.0345646],
'dd':['2019-09-09','2019-09-10','2019-09-11','2019-09-12']}
df = pd.DataFrame(Time,columns=['trace1','trace2','dd'])
create trace 1
trace1 = go.Scatter(x = df.dd,
y = df.trace1,
mode = "lines",
name = "trace1",
marker = dict(color = 'rgba(42, 140, 239, 1)')
)
create trace 2
trace2 = go.Scatter(x = df.dd,
y = df.trace2,
mode = "lines",
name = "trace2",
marker = dict(color = 'rgba(239, 140, 42, 1)'))
This is the code for create graph
data = [trace1,trace2]
layout = go.Layout(
title = 'Estimated Time',
xaxis = go.layout.XAxis(
tickformat = '%Y-%m-%d',
tickangle = 45),
yaxis = go.layout.YAxis(range = [0.001,1],
autorange = False,
title = "Seconds",
tickvals = [0.0010,0.0100,0.1000,1.0000],
ticktext= ["0.0010","0.0100","0.1000","1.0000"]
),
legend = dict(orientation="h",x=0.4,y = -0.2)
)
fig = dict(data = data, layout = layout)
iplot(fig)
Current result:
Expected result (no overlap):
Upvotes: 1
Views: 861
Reputation: 27370
In this particular case it looks like you want to make a logarithmic scale, so I'd recommend adding type='log'
to the arguments of go.Layout.Yaxis()
.
Upvotes: 1