Mohidadil commited on
Commit
e8c561c
·
1 Parent(s): 2447c82

Updated app.py after bug fix

Browse files
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -788,12 +788,20 @@ def main():
788
  color_discrete_sequence=px.colors.qualitative.Set1)
789
  st.plotly_chart(fig, use_container_width=True)
790
  else:
791
- plt.figure(figsize=(10, 5), facecolor='#1C2526')
792
- plt.pie(pie_df, labels=pie_df.index, autopct='%1.1f%%', colors=px.colors.qualitative.Set1)
793
- plt.title(f"Pie Chart of {x_col}")
794
- plt.gcf().set_facecolor('#1C2526')
795
- st.pyplot(plt)
796
- plt.clf()
 
 
 
 
 
 
 
 
797
 
798
  # Box Plot
799
  if st.checkbox("Show Box Plot") and x_col:
 
788
  color_discrete_sequence=px.colors.qualitative.Set1)
789
  st.plotly_chart(fig, use_container_width=True)
790
  else:
791
+ # Convert Plotly RGB strings to matplotlib-accepted hex colors
792
+ def rgb_to_hex(rgb_str):
793
+ rgb_str = rgb_str.replace('rgb(', '').replace(')', '')
794
+ r, g, b = map(int, rgb_str.split(','))
795
+ return '#%02x%02x%02x' % (r, g, b)
796
+
797
+ colors_hex = [rgb_to_hex(c) for c in px.colors.qualitative.Set1]
798
+
799
+ plt.figure(figsize=(10, 5), facecolor='#1C2526')
800
+ plt.pie(pie_df, labels=pie_df.index, autopct='%1.1f%%', colors=colors_hex)
801
+ plt.title(f"Pie Chart of {x_col}")
802
+ plt.gcf().set_facecolor('#1C2526')
803
+ st.pyplot(plt)
804
+ plt.clf()
805
 
806
  # Box Plot
807
  if st.checkbox("Show Box Plot") and x_col: