情节显示为空情节

时间:2019-10-10 04:17:52

标签: python plot plotly

我正在尝试填充二维散点图。我有一个使用相同数据的3-d散点图,所以我知道数据有效。

我尝试用虚拟数字手动加载自己的数据,但该图仍然没有显示。因此,我认为这是我的格式问题。

@app.callback(
    Output("scat", "figure"),
    [Input("select-xaxis", "value"),
     Input("select-yaxis", "value"),
     Input("select-zaxis", "value"),
     Input("select-species", "value"),
     Input('studies', 'value'),
     Input('foams', 'value'),
     Input('surfactants', 'value'),
     Input('additives', 'value'),
     Input('lp', 'value')],
)
def update_scat(selected_x, selected_y, selected_z, selected_species, st, fo, sur, add, lp):
    c = dv[dv['Study'].isin(st)]
    le = c[c['Foam'].isin(fo)]
    an = le[le['Surfactant'].isin(sur)]
    ed = an[an['Additive'].isin(add)]
    cleaned = ed[ed['LiquidPhase'].isin(lp)]

    fig = [go.Figure(data=go.Scatter(
                            x=cleaned[selected_x].to_numpy(),
                            y=cleaned[selected_y].to_numpy(),
                            mode = 'markers',
                            marker = {
                                "size":20,
                                "color":cleaned[selected_species],
                            },
                            text="Study: " + cleaned.Study + "<br />Foam: " + cleaned.Foam + "<br />Surfactant: " + cleaned.Surfactant + "<br />Additive: " + cleaned.Additive + "<br />Liquid Phase: " + cleaned.LiquidPhase,))]

    return  {"data": fig,
            "layout": go.Layout(
                paper_bgcolor="#202020",
                height=938,
                xaxis={"title": f"{selected_x.title()}"}, 
                yaxis={"title": f"{selected_y.title()}"}, )
            }

下面是我的带有虚拟数字的代码示例,它没有给出错误,但仅显示空白图形而没有显示任何内容。另外,当我在上面的语句中返回fig.show()时,由于返回格式而出现错误,但是它在另一个选项卡中显示了正确的图形。我不明白为什么它不能在我的网站上加载。

def update_scat(selected_x, selected_y, selected_z, selected_species, st, fo, sur, add, lp):
    c = dv[dv['Study'].isin(st)]
    le = c[c['Foam'].isin(fo)]
    an = le[le['Surfactant'].isin(sur)]
    ed = an[an['Additive'].isin(add)]
    cleaned = ed[ed['LiquidPhase'].isin(lp)]

    fig = [go.Figure(data=go.Scatter(
                            x=[1,2,3,4,5,6,7,8,9,10],
                            y=[1,2,3,4,5,6,7,8,9,10],
                            mode = 'markers',
                            marker = {
                                "size":20,
                                "color":cleaned[selected_species],
                            },
                            text="Study: " + cleaned.Study + "<br />Foam: " + cleaned.Foam + "<br />Surfactant: " + cleaned.Surfactant + "<br />Additive: " + cleaned.Additive + "<br />Liquid Phase: " + cleaned.LiquidPhase,))]

    return  {"data": fig,
            "layout": go.Layout(
                paper_bgcolor="#202020",
                xaxis={"title": f"{selected_x.title()}"}, 
                yaxis={"title": f"{selected_y.title()}"}, )
            }

0 个答案:

没有答案