Hi, I’m facing an issue when using time data for grouped bars. Please find the issue summary and please share if you have any idea!
Plotly time yaxis doesn’t work rightly when using grouped bars with time formated data.
With one bar (fig2) when the time data is sorted the yaxis is right but when the data is not sorted (fig1) and add second bar (fig1+fig2) to the same plot the yaxis is mixed.
Any idea on this strange behaviour with time series data?
import plotly.graph_objs as go
import pandas as pd
from plotly.offline import init_notebook_mode, iplot
init_notebook_mode(connected=True)
x1 = [1,2,3,4,5,6,7,8,9,10,11,12,13,14]
x2 = [1,2,3,4,5,6,7,8,9,10,11,12,13,14]
d1 = pd.Series(['1.10.28','1.09.97','1.09.44','1.10.05',
'1.11.21','1.09.63','1.09.90','1.10.28',
'1.10.09','1.09.68','1.09.96','1.10.28',
'1.10.75','1.11.43']) #data is not sorted
d2 = pd.Series(['1.09.38','1.09.43','1.09.64','1.09.70',
'1.09.93','1.10.04','1.10.32','1.10.43',
'1.10.43','1.10.74','1.10.95','1.11.17',
'1.11.27','1.12.55']) #data is sorted
y1 = pd.to_datetime(d1, format='%M.%S.%f').dt.time
y2 = pd.to_datetime(d2, format='%M.%S.%f').dt.time
trace1 = go.Bar(x=x1,y=y1)
trace2 = go.Bar(x=x2,y=y2)
layout = go.Layout(yaxis={'type': 'time','tickformat': '%M.%S.%f'})
fig1 = go.Figure(data = [trace1], layout=layout)
fig1.layout.title='fig1 - yaxis is ok'
fig2 = go.Figure(data = [trace2], layout=layout)
fig2.layout.title='fig2 - yaxis is ok'
fig3 = go.Figure(data = [trace1,trace2], layout=layout)
fig3 - yaxis is wrong'