简体   繁体   中英

cufflinks remove gaps in candlestick charts

I am using cufflinks for plotting candlestick charts in jupyter notebook. How to remove gaps of non trading days in chart. In plotly we can update layout ['xaxis']['type'] to 'category'. How can we update the same for a QuantFig in cufflinks. Follwowing is my code.

import cufflinks as cf
import pandas as pd
import plotly
from plotly import tools
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
print("List of Cufflinks Themes : ", cf.getThemes())

cf.set_config_file(theme='pearl',sharing='public',offline=True)
daily = pd.read_csv('data.csv',index_col=0,parse_dates=True)

qf=cf.QuantFig(daily,title='my test chart',legend='left',name='Test')
qf.add_volume()

qf.iplot()

This did the trick for me:

fig = qf.iplot(kind='candle')
fig.update_xaxes(
    rangebreaks=[
        dict(bounds=["sat", "mon"]), #hide weekends
    ]
)

(described here: https://plotly.com/python/time-series/#hiding-weekends-and-holidays )

You may try this

qf=cf.QuantFig(daily,title='my test chart',legend='left',name='Test')
qf.add_volume()

fig = qf.figure()
fig.update_xaxes(
    rangebreaks=[dict(bounds=["sat", "mon"])])
fig.show()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM