简体   繁体   English

python Dash中的子图(Side to side)

[英]Subplot ( Side to side ) in python Dash

import dash
import dash_html_components as html
import dash_core_components as dcc

app = dash.Dash()
app.layout = html.Div([
    html.Div([
        html.Div(dcc.Graph(id='g1', figure={'data': [{'y': [1, 2, 3]}]}), className="six columns",style={"width": 500, "margin": 0}),

        html.Div(dcc.Graph(id='g2', figure={'data': [{'y': [1, 2, 3]}]}), className="six columns",style={"width": 500, "margin": 0}),

    ], className="row")
])

if __name__ == '__main__':
    app.run_server(debug=True)

The above code supposed to be side to side like this:上面的代码应该像这样并排:

It supposed to produce and I am looking for它应该生产,我正在寻找

But unfortunately, The above code produce I am getting like this:但不幸的是,上面的代码产生了我这样的:

Got the solution from one of my colleagues从我的一位同事那里得到了解决方案

import dash
import dash_html_components as html
import dash_core_components as dcc
app = dash.Dash()
app.layout = html.Div([
    html.Div([
        html.Div(
          dcc.Graph(id='g1', 
                    figure={'data': [{'y': [1, 2, 3]}]}), 
                    className="six columns",
                    style={"width":500, "margin": 0, 'display': 'inline-block'}
                ),
        html.Div(
          dcc.Graph(id='g2', 
                    figure={'data': [{'y': [1, 2, 3]}]}), 
                    className="six columns",
                    style={"width":500, "margin": 0, 'display': 'inline-block'}
                ),
    ], className="row")
])
if __name__ == '__main__':
    app.run_server(debug=True)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM