[英]Increase size of Plotly / Dash Figure
I have the following code:我有以下代码:
import numpy as np
from dash import Dash, html
from dash import dcc
import dash_bootstrap_components as dbc
import plotly.graph_objects as go
app = Dash(external_stylesheets=[dbc.themes.BOOTSTRAP])
app.layout = html.Div(
dbc.Row(
[
dbc.Col([
dcc.Graph(
id='figure',
figure={
'data': [go.Surface(
z=np.zeros((1000, 1000)),
colorscale='algae',
opacity=0.9,
showscale=False
)]}
)
],
md=12)
]
)
)
My output looks as follows:我的输出如下所示:
How do I make sure that the size of figure increases like below:如何确保图形的大小增加如下:
Your code describes the graph settings directly, which can be modified by adding layout information to it in dictionary form.您的代码直接描述了图形设置,可以通过以字典形式向其添加布局信息来对其进行修改。 I have removed the fixed size and set it to 600 pixels in height and width.
我已删除固定大小并将其高度和宽度设置为 600 像素。 I have also reduced the number of columns the graph needs and placed it as centered.
我还减少了图表所需的列数并将其居中放置。
import numpy as np
from dash import Dash, html
from dash import dcc
import dash_bootstrap_components as dbc
import plotly.graph_objects as go
#from jupyter_dash import JupyterDash
app = Dash(external_stylesheets=[dbc.themes.BOOTSTRAP])
#app = JupyterDash(external_stylesheets=[dbc.themes.BOOTSTRAP])
app.layout = html.Div(
dbc.Row(
[
dbc.Col([
dcc.Graph(
id='figure',
figure={
'data': [go.Surface(
z=np.zeros((1000, 1000)),
colorscale='algae',
opacity=0.9,
showscale=False)],
'layout':{
'autosize':False,
'height':600,
'width':600}
}
)
],
md=8)
], justify='center',
)
)
if __name__ == "__main__":
#app.run_server(mode='inline')
app.run_server()
Add "margin" property in layout likewise -同样在布局中添加“margin”属性 -
[![import numpy as np
from dash import Dash, html
from dash import dcc
import dash_bootstrap_components as dbc
import plotly.graph_objects as go
#from jupyter_dash import JupyterDash
app = Dash(external_stylesheets=\[dbc.themes.BOOTSTRAP\])
#app = JupyterDash(external_stylesheets=\[dbc.themes.BOOTSTRAP\])
app.layout = html.Div(
dbc.Row(
\[
dbc.Col(\[
dcc.Graph(
id='figure',
figure={
'data': \[go.Surface(
z=np.zeros((1000, 1000)),
colorscale='algae',
opacity=0.9,
showscale=False)\],
'layout':{
'autosize':False,
'height':600,
'width':600,
'margin': {"t":"5","b":"5","l":"5","r":"5"}
}
}
)
\],
md=8)
\], justify='center',
)
)
if __name__ == "__main__":
#app.run_server(mode='inline')
app.run_server()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.