gdleds commited on
Commit
f08f35a
·
verified ·
1 Parent(s): a7a7519

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +54 -7
app.py CHANGED
@@ -835,29 +835,37 @@ if page == "Exploration des données":
835
  )
836
 
837
  # ── Barres avec labels (Graph Objects)
 
 
 
 
838
  fig_top10_feux = go.Figure(
839
  data=go.Bar(
840
  x=df_count["Département"],
841
  y=df_count["Nombre de feux"],
842
  text=df_count["Nombre de feux"].apply(lambda x: f"{x:,}"),
843
  textposition="outside",
844
- textfont=dict(size=16, color="#2e2e2e"), # police foncée
 
845
  marker=dict(
846
  color="#627CFF",
847
  line=dict(color="black", width=1.5),
848
  ),
849
  )
850
  )
851
-
852
- # ── Mise en page inspirée de ta Fig 1
853
  fig_top10_feux.update_layout(
854
  title="🔥 Top 10 des départements avec le plus d’incendies",
855
  title_font_size=18,
856
- template="plotly_white", # fond clair + grille
857
  plot_bgcolor="rgba(245,248,255,1)",
858
  paper_bgcolor="rgba(245,248,255,1)",
859
- margin=dict(l=80, r=80, t=140, b=120),
860
- font=dict(size=16, color="black"), # police par défaut foncée
 
 
 
 
861
  xaxis=dict(
862
  title="Département",
863
  tickangle=-35,
@@ -867,9 +875,47 @@ if page == "Exploration des données":
867
  title="Nombre de feux",
868
  tickformat=",d",
869
  tickfont=dict(size=16),
 
870
  ),
 
871
  bargap=0.05,
872
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
873
 
874
  st.plotly_chart(fig_top10_feux, use_container_width=True)
875
 
@@ -894,6 +940,7 @@ elif page == "Résultats des modèles":
894
  query = """SELECT * FROM metrics"""
895
  df = pd.read_sql(query, engine)
896
  df = pd.DataFrame(df)
897
- print(df.tail(15))
 
898
 
899
  show_footer()
 
835
  )
836
 
837
  # ── Barres avec labels (Graph Objects)
838
+
839
+ y_max = df_count["Nombre de feux"].max()
840
+ y_range = [0, y_max * 1.15] # +15% d’espace en haut
841
+
842
  fig_top10_feux = go.Figure(
843
  data=go.Bar(
844
  x=df_count["Département"],
845
  y=df_count["Nombre de feux"],
846
  text=df_count["Nombre de feux"].apply(lambda x: f"{x:,}"),
847
  textposition="outside",
848
+ cliponaxis=False, # empêche le texte d’être coupé
849
+ textfont=dict(size=16, color="black"),
850
  marker=dict(
851
  color="#627CFF",
852
  line=dict(color="black", width=1.5),
853
  ),
854
  )
855
  )
856
+
 
857
  fig_top10_feux.update_layout(
858
  title="🔥 Top 10 des départements avec le plus d’incendies",
859
  title_font_size=18,
860
+ template="plotly_white",
861
  plot_bgcolor="rgba(245,248,255,1)",
862
  paper_bgcolor="rgba(245,248,255,1)",
863
+
864
+ # 🔑 marges ajustées
865
+ margin=dict(l=80, r=80, t=160, b=120),
866
+
867
+ font=dict(size=16, color="black"),
868
+
869
  xaxis=dict(
870
  title="Département",
871
  tickangle=-35,
 
875
  title="Nombre de feux",
876
  tickformat=",d",
877
  tickfont=dict(size=16),
878
+ range=y_range, # espace vertical forcé
879
  ),
880
+
881
  bargap=0.05,
882
  )
883
+
884
+ # fig_top10_feux = go.Figure(
885
+ # data=go.Bar(
886
+ # x=df_count["Département"],
887
+ # y=df_count["Nombre de feux"],
888
+ # text=df_count["Nombre de feux"].apply(lambda x: f"{x:,}"),
889
+ # textposition="outside",
890
+ # textfont=dict(size=16, color="black"), # police foncée
891
+ # marker=dict(
892
+ # color="#627CFF",
893
+ # line=dict(color="black", width=1.5),
894
+ # ),
895
+ # )
896
+ # )
897
+
898
+ # # ── Mise en page inspirée de ta Fig 1
899
+ # fig_top10_feux.update_layout(
900
+ # title="🔥 Top 10 des départements avec le plus d’incendies",
901
+ # title_font_size=18,
902
+ # template="plotly_white", # fond clair + grille
903
+ # plot_bgcolor="rgba(245,248,255,1)",
904
+ # paper_bgcolor="rgba(245,248,255,1)",
905
+ # margin=dict(l=80, r=80, t=140, b=120),
906
+ # font=dict(size=16, color="black"), # police par défaut foncée
907
+ # xaxis=dict(
908
+ # title="Département",
909
+ # tickangle=-35,
910
+ # tickfont=dict(size=16),
911
+ # ),
912
+ # yaxis=dict(
913
+ # title="Nombre de feux",
914
+ # tickformat=",d",
915
+ # tickfont=dict(size=16),
916
+ # ),
917
+ # bargap=0.05,
918
+ # )
919
 
920
  st.plotly_chart(fig_top10_feux, use_container_width=True)
921
 
 
940
  query = """SELECT * FROM metrics"""
941
  df = pd.read_sql(query, engine)
942
  df = pd.DataFrame(df)
943
+ st.dataframe(df.tail(15))
944
+
945
 
946
  show_footer()