我正在尝试消除蜡烛图中的日期时间间隙(这些间隙是股市关闭时的时间段,因此没有数据)。似乎找不到使用plotly图形对象的好方法。是否有可行的方法来解决这个问题?
我的代码如下(使用plotly图形对象):
import dash
import dash_core_components as dcc
import dash_table
import pandas as pd
import dash_html_components as html
import numpy as np
from dash.dependencies import Output, Input, State
import plotly.graph_objects as go
import yfinance as yf
import plotly.express as px
from datetime import datetime, timedelta
from pytz import timezone
import dash_bootstrap_components as dbc
df= yf.Ticker('aapl')
df = df.history(interval="5m",period="5d")
df["Datetime"] = df.index
trace1 = {
'x': df.Datetime,
'open': df.Open,
'close': df.Close,
'high': df.High,
'low': df.Low,
'type': 'candlestick',
'name': 'apple,
'showlegend': False
}
data = [trace1]
# Config graph layout
layout = go.Layout({
'title': {
'text': str(input_value) + ' Stock',
'font': {
'size': 15
}
},
'plot_bgcolor': '#2E2E2E'
})
fig = go.Figure(data=data, layout=layout)
fig.update_layout(xaxis_rangeslider_visible=False)
if __name__ == '__main__':
app.run_server(debug=True)