Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何防止plotly图表标题在地物更新后左对齐?_Python_Plotly_Plotly Dash - Fatal编程技术网

Python 如何防止plotly图表标题在地物更新后左对齐?

Python 如何防止plotly图表标题在地物更新后左对齐?,python,plotly,plotly-dash,Python,Plotly,Plotly Dash,我的dash应用程序中有一个绘图,最初的标题位于绘图上方的中心。但是,一旦我更新了图形,标题就会左对齐。我不明白为什么会出现这种情况,我想知道我怎样才能防止标题本身移动,而不是保持在情节上方的中心位置。以下是我的dash应用程序的代码: 导入破折号 将仪表板核心组件作为dcc导入 将dash_html_组件导入为html 从dash.dependencies导入输入、输出和状态 导入plotly.graph_objs作为go 从nba_api.stats.static导入玩家 从nba_api.

我的dash应用程序中有一个绘图,最初的标题位于绘图上方的中心。但是,一旦我更新了图形,标题就会左对齐。我不明白为什么会出现这种情况,我想知道我怎样才能防止标题本身移动,而不是保持在情节上方的中心位置。以下是我的dash应用程序的代码:

导入破折号
将仪表板核心组件作为dcc导入
将dash_html_组件导入为html
从dash.dependencies导入输入、输出和状态
导入plotly.graph_objs作为go
从nba_api.stats.static导入玩家
从nba_api.stats.endpoints.shotchartdetail导入shotchartdetail
球场形状=[]
外部线条形状=dict(
type='rect',
xref='x',
yref='y',
x0='-250',
y0='-47.5',,
x1='250',
y1='422.5',
行=dict(
color='rgba(10,10,10,1)',
宽度=1
)
)
法庭形状。附加(外部线条形状)
环箍形状=dict(
type='circle',
xref='x',
yref='y',
x0='7.5',
y0='7.5',
x1='-7.5',
y1='-7.5',
行=dict(
color='rgba(10,10,10,1)',
宽度=1
)
)
球场形状。附加(环形)
篮板_形=dict(
type='rect',
xref='x',
yref='y',
x0='-30',,
y0='-7.5',,
x1='30',
y1='-6.5',
行=dict(
color='rgba(10,10,10,1)',
宽度=1
),
fillcolor='rgba(10,10,10,1)'
)
球场形状。附加(篮板形状)
外部三秒形状=dict(
type='rect',
xref='x',
yref='y',
x0='-80',,
y0='-47.5',,
x1='80',
y1='143.5',
行=dict(
color='rgba(10,10,10,1)',
宽度=1
)
)
法庭形状。附加(外部三个第二个形状)
内部三个截面形状=dict(
type='rect',
xref='x',
yref='y',
x0='-60',,
y0='-47.5',,
x1='60',
y1='143.5',
行=dict(
color='rgba(10,10,10,1)',
宽度=1
)
)
法庭形状。附加(内部三个第二个形状)
左\u线\u形=dict(
type='line',
xref='x',
yref='y',
x0='-220',,
y0='-47.5',,
x1='-220',,
y1='92.5',
行=dict(
color='rgba(10,10,10,1)',
宽度=1
)
)
法庭形状。附加(左线形状)
右\u线\u形=dict(
type='line',
xref='x',
yref='y',
x0='220',
y0='-47.5',,
x1='220',
y1='92.5',
行=dict(
color='rgba(10,10,10,1)',
宽度=1
)
)   
法庭形状。附加(右线形状)
三点圆弧形状=dict(
type='path',
xref='x',
yref='y',
path='M-22092.5C-70300、70300、22092.5',
行=dict(
color='rgba(10,10,10,1)',
宽度=1
)
)
庭院形状。附加(三点弧形)
中心\圆\形状=dict(
type='circle',
xref='x',
yref='y',
x0='60',
y0='482.5',
x1='-60',
y1='362.5',
行=dict(
color='rgba(10,10,10,1)',
宽度=1
)
)
法庭形状。附加(中心圆形状)
res_圆_形=dict(
type='circle',
xref='x',
yref='y',
x0='20',
y0='442.5',
x1='-20',,
y1='402.5',
行=dict(
color='rgba(10,10,10,1)',
宽度=1
)
)
庭院形状。附加(圆形)
罚球圈形(
type='circle',
xref='x',
yref='y',
x0='60',
y0='200',
x1='-60',
y1='80',
行=dict(
color='rgba(10,10,10,1)',
宽度=1
)
)
球场形状。附加(罚球形状)
res_面积_形状=dict(
type='circle',
xref='x',
yref='y',
x0='40',
y0='40',
x1='-40',,
y1='-40',
行=dict(
color='rgba(10,10,10,1)',
宽度=1,
破折号
)
)
球场形状。附加(区域形状)
外部_样式表=['https://codepen.io/chriddyp/pen/bWLwgP.css']
app=dash.dash(名称,外部样式表=外部样式表)
app.layout=html.Div([
html.Div([
图(
id='shot-graph',
身材={
“布局”:go.layout(
title=“测试”,
形状=球场形状,
高度=800,
宽度=1000,
xaxis=dict(
showgrid=False,
范围=[-300300],
showticklabels=False,
零线=假
),
yaxis=dict(
showgrid=False,
范围=[-100500],
showticklabels=False,
零线=假
)
)
},
配置={
“displayModeBar”:False
}
),
],style={'margin':'auto','width':'50%}),
html.Div([
dcc.Input(id='playerName-state',type='text',value='Brook Lopez'),
dcc.输入(id='season-state',type='text',value='2018-19'),
按钮('Submit',id='Button')
],style={'margin-left':'675px'})
])
@app.callback(
输出('shot-graph','figure'),
[输入('按钮','点击')],
陈述=[
状态(组件id='playerName-State',组件属性='value'),
状态(组件\u id='State',组件\u属性='value')]
)
def更新图(点击次数、播放名称、季节):
playerID=players。通过全名(str(playerName))[0]['id']查找玩家
shotchart\u detail=shotchart detail(球队id=0,球员id=playerID,赛季nullable=str(赛季),上下文度量值\u simple=“FGA”)
shotData=shotchart\u detail.get\u data\u frames()[0]
shotData[“LOC_X”]*=-1
已拍摄镜头=shotData.loc[shotData.SHOT\u已拍摄镜头=1]
未命中的镜头=shotData.loc[shotData.SHOT\u make\u标志==0]
图=go.Figure()
图添加跟踪(去散点(x=已拍摄[“LOC\u x”]、y=已拍摄[“LOC\u y”]、mode='markers',marker\u color=“BLUE”、name=“已拍摄”))
图:添加跟踪(go.散射(x=未命中的镜头[“LOC\U x”]、y=未命中的镜头[“LOC\U y”]、模式=标记、标记