How to set spaces between candles in python plotly?
This is the graph with DateTime axis, but Time is not consistent:
With df.index is working well:
Data slices:
Time Open High Low Close Volume
0 2022-04-01 00:00:02.502538 45504.0 45544.5 45495.0 45495.0 509900
1 2022-04-01 00:00:55.818934 45492.0 45492.0 45443.0 45443.0 333000
2 2022-04-01 00:01:05.303659 45439.5 45473.0 45424.0 45473.0 964500
3 2022-04-01 00:02:40.018852 45476.5 45524.0 45476.5 45524.0 65500
4 2022-04-01 00:02:57.990307 45529.0 45563.0 45514.5 45523.5 340100
5 2022-04-01 00:03:19.070886 45512.5 45542.5 45493.5 45542.5 263900
6 2022-04-01 00:04:33.603519 45544.5 45580.0 45530.0 45580.0 1840600
7 2022-04-01 00:09:43.052953 45580.5 45582.5 45533.5 45582.5 840400
8 2022-04-01 00:12:04.238964 45584.5 45635.0 45584.5 45635.0 1360300
9 2022-04-01 00:13:08.160715 45636.0 45639.5 45589.5 45589.5 2591600
10 2022-04-01 00:15:12.092263 45589.0 45613.5 45563.5 45613.5 583400
11 2022-04-01 00:17:57.196397 45614.5 45616.0 45567.5 45567.5 138100
12 2022-04-01 00:18:35.417509 45565.5 45581.0 45531.0 45581.0 1686000
13 2022-04-01 00:22:21.569982 45583.5 45614.5 45564.5 45564.5 1220900
14 2022-04-01 00:30:55.179803 45563.0 45563.0 45512.5 45512.5 419000
15 2022-04-01 00:31:44.580263 45511.5 45511.5 45462.0 45462.0 350600
16 2022-04-01 00:32:10.126260 45461.0 45461.0 45412.0 45412.0 1213400
17 2022-04-01 00:32:18.380608 45410.0 45410.0 45360.0 45408.0 1580500
18 2022-04-01 00:33:34.613927 45412.5 45454.0 45405.0 45454.0 456700
19 2022-04-01 00:35:32.598759 45458.0 45473.0 45424.0 45473.0 488200
Code:
from plotly.figure_factory import create_candlestick
df=pd.read_csv('test.txt')
fig = create_candlestick(df['Open'], df['High'], df['Low'], df['Close'], dates=df['Time'])
#fig.update_xaxes(dtick=1)
#fig.update_xaxes(anchor="free")
fig.show()