Spaces:
Sleeping
Sleeping
Update app.py
Browse files60 unmodified lines6162636465666768697060 unmodified linesdef plot_analyse_histogramme(code_variable = "NPERR"):histo = ddb.sql(f"""select lib_territoire territoire, code_variable, variable, modalite, proportion_locale "Pourcentage de population estimé (%)" from agr_comparaison_territoires where code_variable = '{code_variable}' \/*union select 'National' territoire,code_variable, variable, modalite, proportion_reference proportion from agr_comparaison_territoires where code_variable = '{code_variable}' */order by 5 """).to_df().hvplot.barh( x='modalite', y="Pourcentage de population estimé (%)", legend='bottom_right', height=400, width=800 , group_label=None)return histodef run_territoire_histo(filtre_territoire="95", lib_territoire="Val Oise", code_variable="TYPL"):prepare_data(filtre_territoire,lib_territoire)60 unmodified lines616263646566676869707172737475767778798081828384858687888960 unmodified linesdef plot_analyse_histogramme(code_variable = "NPERR"):df = ddb.sql(f"""select lib_territoire territoire, code_variable, variable, modalite, proportion_locale "Pourcentage de population estimé (%)" from agr_comparaison_territoires where code_variable = '{code_variable}' \/*union select 'National' territoire,code_variable, variable, modalite, proportion_reference proportion from agr_comparaison_territoires where code_variable = '{code_variable}' */order by 5 """).to_df()plot = df.hvplot.barh(x='modalite',y="Pourcentage de population estimé (%)",legend='bottom_right',height=400,width=800,group_label=None,color='modalite', # Assign a color based on the 'modalite' fieldcmap='Category20', # Use a categorical color maphover_cols=['territoire', 'variable'] # Add more columns to hover tool)# Improve aestheticsplot.opts(xlabel="Modalité",ylabel="Pourcentage de population estimé (%)",tools=['hover'], # Enable hover toolshow_grid=True, # Show gridfontscale=1.2 # Increase font scale for better readability)return plotdef run_territoire_histo(filtre_territoire="95", lib_territoire="Val Oise", code_variable="TYPL"):prepare_data(filtre_territoire,lib_territoire)
app.py+22-3