Python 如何仅在仪表板应用程序上显示白色参考?

Python 如何仅在仪表板应用程序上显示白色参考?,python,plotly,plotly-dash,line-plot,Python,Plotly,Plotly Dash,Line Plot,我正在尝试在dash中部署一些应用程序,但是,尽管下拉列表显示正确,但没有调用绘图 我已经尝试了很多不同的东西,但它总是去一个白色的参考 import dash import dash_core_components as dcc import dash_html_components as html from dash.dependencies import Input, Output, State import numpy as np import pandas as pd import p

我正在尝试在dash中部署一些应用程序,但是,尽管下拉列表显示正确,但没有调用绘图

我已经尝试了很多不同的东西,但它总是去一个白色的参考

import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
import numpy as np
import pandas as pd
import plotly.graph_objs as go
import plotly.express as px
import plotly.io as pio
from plotly.colors import n_colors
from plotly.subplots import make_subplots


df = pd.read_csv('movies.csv', encoding = "ISO-8859-1")


df.columns = df.columns.str.capitalize()
    
###################### APP ############################

app = dash.Dash(__name__)


app.layout = html.Div([
    
    html.Div([
        dcc.Graph(id = 'our_graph')
    ],className = 'nine columns'),

    html.Div([

        html.Br(),
        html.Label(['Choose Country / Genre / Company:'],style={'font-weight': 'bold', "text-align": "center"}),
        dcc.Dropdown(id = 'country_drop',
            options = [{'label':country, 'value':country} for country in df['Country'].unique()],
            value = 'USA',
            multi = False,
            disabled=False,
            clearable=True,
            searchable=True,
            placeholder='Choose Country...',
            className='form-dropdown',
            style={'width':"90%"},
            persistence='string',
            persistence_type='memory'),

        dcc.Dropdown(id= 'genre_drop',
            options = [{'label': genre, 'value' : genre} for genre in df['Genre'].unique()],
            value = 'Drama',
            multi = False,
            disabled=False,
            clearable=True,
            searchable=True,
            placeholder='Choose Genre..',
            className='form-dropdown',
            style={'width':"90%"},
            persistence='string',
            persistence_type='memory'),

        dcc.Dropdown(id = 'company_drop',
            options = [{'label':company, 'value':company} for company in df['Company'].unique()],
            value = 'Paramount Pictures',
            multi = False,
            disabled=False,
            clearable=True,
            searchable=True,
            placeholder='Choose Company..',
            className='form-dropdown',
            style={'width':"90%"},
            persistence='string',
            persistence_type='memory'),

        ],className='three columns')

])


####################Callbacks#######################

@app.callback(
    dash.dependencies.Output('our_graph', 'figure'),
    [dash.dependencies.Input("company_drop", "value"),
     dash.dependencies.Input("country_drop", "value"),
     dash.dependencies.Input("genre_drop", "value")
     ]
)
def plots(country, genre,company):
    new_df = df.loc[(df['Country'] == country) & (df['Genre'] == genre) & (df['Company'] == company)]
    revenue_df = new_df.groupby(by = ['Year'])['Gross','Budget'].sum()
    fig = px.line(revenue_df, x=revenue_df.index, y=revenue_df.columns, title = 'Which Country has the highest revenue by category?',
                labels=dict(x="Year", y= 'Amount of $ in billions'))
    return fig


#Run App
if __name__ == '__main__': 
    app.run_server(debug=False)`

如果有人能帮我…我是个乞丐,但尽管可能很简单,但我已经在两天内寻找解决方案了…

数据不显示的原因是下拉列表的顺序和graph函数接收数据的顺序不同,因此获取的数据不存在,导致错误

@app.callback(
    dash.dependencies.Output('our_graph', 'figure'),
    dash.dependencies.Input("company_drop", "value"),
     dash.dependencies.Input("country_drop", "value"),
     dash.dependencies.Input("genre_drop", "value"))

def plots(company, country, genre):
    new_df = df[(df['Country'] == country) & (df['Genre'] == genre) & (df['Company'] == company)]
    revenue_df = new_df.groupby(by = ['Year'])[['Gross','Budget']].sum()
    revenue_df.reset_index(inplace=True)

    fig = px.line(revenue_df,
                  x='Year',
                  y=['Gross', 'Budget'],
                  title='Which Country has the highest revenue by category?',
                 ) 
    
    fig.update_xaxes(title_text='YEAR')
    fig.update_yaxes(title_text='Amount of $ in billions')
    return fig

如果您有玩具数据,我可以在我的环境中验证,但是您能提供数据吗?@r-初学者@r-初学者很抱歉再次打扰您,但是您找到什么了吗?我真的很绝望