alihmaou commited on
Commit
d0941c6
·
1 Parent(s): efe4f94

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -3
app.py CHANGED
@@ -61,10 +61,29 @@ def analyse_comparaison_territoires(table_territoire = "selected_data_stats_prop
61
 
62
 
63
  def plot_analyse_histogramme(code_variable = "NPERR"):
64
- 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}' \
65
  /*union select 'National' territoire,code_variable, variable, modalite, proportion_reference proportion from agr_comparaison_territoires where code_variable = '{code_variable}' */
66
- order by 5 """).to_df().hvplot.barh( x='modalite', y="Pourcentage de population estimé (%)", legend='bottom_right', height=400, width=800 , group_label=None)
67
- return histo
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
 
69
  def run_territoire_histo(filtre_territoire="95", lib_territoire="Val Oise", code_variable="TYPL"):
70
  prepare_data(filtre_territoire,lib_territoire)
 
61
 
62
 
63
  def plot_analyse_histogramme(code_variable = "NPERR"):
64
+ 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}' \
65
  /*union select 'National' territoire,code_variable, variable, modalite, proportion_reference proportion from agr_comparaison_territoires where code_variable = '{code_variable}' */
66
+ order by 5 """).to_df()
67
+ plot = df.hvplot.barh(
68
+ x='modalite',
69
+ y="Pourcentage de population estimé (%)",
70
+ legend='bottom_right',
71
+ height=400,
72
+ width=800,
73
+ group_label=None,
74
+ color='modalite', # Assign a color based on the 'modalite' field
75
+ cmap='Category20', # Use a categorical color map
76
+ hover_cols=['territoire', 'variable'] # Add more columns to hover tool
77
+ )
78
+ # Improve aesthetics
79
+ plot.opts(
80
+ xlabel="Modalité",
81
+ ylabel="Pourcentage de population estimé (%)",
82
+ tools=['hover'], # Enable hover tool
83
+ show_grid=True, # Show grid
84
+ fontscale=1.2 # Increase font scale for better readability
85
+ )
86
+ return plot
87
 
88
  def run_territoire_histo(filtre_territoire="95", lib_territoire="Val Oise", code_variable="TYPL"):
89
  prepare_data(filtre_territoire,lib_territoire)