cone001
cone001

Reputation: 1153

python use plotly to plot time series without date gaps

I am using python3. I have a price quote series of 1 minute frequency. The quote is only available in trading hours. I tried to plot it using plotly, but there are gaps in non trading hours and weekends. How can I make this plot consecutive?

My code is like

ifBasisPlot=go.Scatter( x=ifBasis.date, y=ifBasis.basis, line=go.Line(width=1,color='blue'), name='basis' )

data = go.Data([ifBasisPlot])

ifBasisPlot_url = py.plot(data, filename='ifBasisPlot', auto_open=False,)

the plot and the data is here: https://plot.ly/~shuaihou96/14/if/

Upvotes: 5

Views: 2679

Answers (2)

Statham
Statham

Reputation: 4118

You can try to change this code

ifBasisPlot=go.Scatter( x=ifBasis.date, y=ifBasis.basis, line=go.Line(width=1,color='blue'), name='basis' )

into

ifBasisPlot=go.Scatter( x=range(len(ifBasis.date)), y=ifBasis.basis, line=go.Line(width=1,color='blue'), name='basis' )

Upvotes: 0

PaulDong
PaulDong

Reputation: 793

I believe there is an open PR for the plotly project. link

As mentioned in the PR, we could use a tickformat x axis attribute; @etpinard had made a proof of concept chart, but that may not work if zooming is involved.

Upvotes: 1

Related Questions