ypeng16 commited on
Commit
c2ea0ca
·
verified ·
1 Parent(s): ccf54e2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -5
app.py CHANGED
@@ -699,12 +699,26 @@ else:
699
  st.warning(err_msg)
700
  else:
701
  fig, ax = plt.subplots(figsize=(6, 5))
702
- sns.heatmap(corr_matrix, annot=True, fmt=".2f", cmap="coolwarm", center=0, ax=ax)
703
- ax.tick_params(axis='x', labelsize=9)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
704
  ax.tick_params(axis='y', labelsize=9)
705
  ax.set_xlabel("")
706
  ax.set_ylabel("")
707
- country_fullname = country_mapping.get(selected_region, selected_region)
708
- title_str = f"{country_fullname} - {selected_commodity} ({start_year}–{end_year})"
709
- ax.set_title(title_str)
710
  st.pyplot(fig)
 
699
  st.warning(err_msg)
700
  else:
701
  fig, ax = plt.subplots(figsize=(6, 5))
702
+
703
+ mask = np.triu(np.ones_like(corr_matrix, dtype=bool))
704
+
705
+ sns.heatmap(
706
+ corr_matrix,
707
+ mask=mask,
708
+ cmap="coolwarm",
709
+ annot=True,
710
+ fmt=".2f",
711
+ center=0,
712
+ square=True,
713
+ linewidths=0.5,
714
+ cbar_kws={"shrink": 0.7},
715
+ ax=ax
716
+ )
717
+
718
+ ax.tick_params(axis='x', labelrotation=45, labelsize=9)
719
  ax.tick_params(axis='y', labelsize=9)
720
  ax.set_xlabel("")
721
  ax.set_ylabel("")
722
+ ax.set_title(f"{country_mapping.get(selected_region, selected_region)} - {selected_commodity} ({start_year}–{end_year})", fontsize=12, pad=12)
723
+
 
724
  st.pyplot(fig)