nruto commited on
Commit
9f5ca96
·
verified ·
1 Parent(s): 14832e2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -3,7 +3,7 @@
3
  # !pip install gradio
4
 
5
  import gradio as gr
6
- import matplotlib.pyplot as plt
7
  import pandas as pd
8
  import os
9
 
@@ -40,11 +40,8 @@ def show_pie_chart(): # Define the function to show the pie chart
40
  labels = ['Remaining Income', 'Expenses']
41
  sizes = [remaining_income, total_expenses]
42
 
43
- fig, ax = plt.subplots()
44
- ax.pie(sizes, labels=labels, autopct='%1.1f%%', startangle=90)
45
- ax.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle.
46
-
47
- plt.close(fig) # Prevents the figure from displaying in a separate window
48
  return fig # Return the figure to be displayed in Gradio
49
 
50
  def reset_data(): # Define the reset_data function
 
3
  # !pip install gradio
4
 
5
  import gradio as gr
6
+ import plotly.graph_objects as go # Import plotly for plotting
7
  import pandas as pd
8
  import os
9
 
 
40
  labels = ['Remaining Income', 'Expenses']
41
  sizes = [remaining_income, total_expenses]
42
 
43
+ # Create a pie chart using plotly
44
+ fig = go.Figure(data=[go.Pie(labels=labels, values=sizes, hole=.3)]) # Create a pie chart
 
 
 
45
  return fig # Return the figure to be displayed in Gradio
46
 
47
  def reset_data(): # Define the reset_data function