harikrishnad1997 commited on
Commit
21bd1c0
1 Parent(s): 39c4d08

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +55 -0
app.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+ import seaborn as sns
4
+ import matplotlib.pyplot as plt
5
+
6
+ # Load the Iris dataset
7
+ iris_df = sns.load_dataset('iris')
8
+
9
+ # Function to plot histogram
10
+ def plot_histogram(csv_file, column):
11
+ # Read the CSV file
12
+ custom_df = pd.read_csv(csv_file)
13
+
14
+ # Plot histogram
15
+ plt.figure(figsize=(8, 6))
16
+ sns.histplot(custom_df[column])
17
+ plt.title(f'Histogram for {column}')
18
+ plt.xlabel(column)
19
+ plt.ylabel('Frequency')
20
+ return plt
21
+
22
+ # Function to plot scatter plot
23
+ def plot_scatter(csv_file, x_axis, y_axis):
24
+ # Read the CSV file
25
+ custom_df = pd.read_csv(csv_file)
26
+
27
+ # Plot scatter plot
28
+ plt.figure(figsize=(8, 6))
29
+ sns.scatterplot(x=x_axis, y=y_axis, data=custom_df)
30
+ plt.title(f'Scatter Plot ({x_axis} vs {y_axis})')
31
+ plt.xlabel(x_axis)
32
+ plt.ylabel(y_axis)
33
+ return plt
34
+
35
+ # Create the Gradio interface
36
+ iface = gr.Interface(
37
+ fn=plot_histogram,
38
+ inputs=["csv", "text"],
39
+ outputs="plot",
40
+ title="Histogram Plotter",
41
+ description="Upload a CSV file and select a column to plot its histogram."
42
+ )
43
+
44
+ # Add a second interface for scatter plot
45
+ scatter_iface = gr.Interface(
46
+ fn=plot_scatter,
47
+ inputs=["csv", "text", "text"],
48
+ outputs="plot",
49
+ title="Scatter Plotter",
50
+ description="Upload a CSV file and select X and Y columns to plot a scatter plot."
51
+ )
52
+
53
+ # Launch the Gradio interfaces
54
+ iface.launch(share=True)
55
+ scatter_iface.launch(share=True)