Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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)
|