一个
Graph对象包含一个
figure。每个
figure都有
data和
layout属性。
您可以在
height中设置
layout。
dcc.Graph( id="my-graph", figure={ "data": [ {"x": [1, 2, 3], "y": [4, 1, 2], "type": "bar"}, {"x": [1, 2, 3], "y": [2, 4, 5], "type": "bar"}, ], "layout": { "title": "My Dash Graph", "height": 700, # px }, },)根据Plotly
figure对象架构,
height必须为大于或等于10的数字,并且其默认值为450(px)。
请记住,您可以创建一个
Graph对象并
figure稍后在破折号回调中进行设置。
例如,如果
valueof的
dcc.Slider影响
figure您的属性,则您
Graph将拥有:
import plotly.graph_objs as godcc.Graph(id="my-graph")@app.callback( output=Output("my-graph", "figure"), inputs=Input("slider", "value")])def update_my_graph(value): data = go.Data( [ go.Bar(x=[1, 2, 3], y=[4, 1, 2]), go.Bar(x=[1, 2, 3], y=[2, 4, 5]), ] layout = go.Layout( title="My Dash Graph", height=700 ) figure = go.Figure(data=data, layout=layout) return figure


