Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import pandas as pd
|
3 |
+
import matplotlib.pyplot as plt
|
4 |
+
|
5 |
+
def plot_graph(file):
|
6 |
+
# Read the CSV file
|
7 |
+
df = pd.read_csv(file.name)
|
8 |
+
# Generate a simple plot
|
9 |
+
plt.figure()
|
10 |
+
df.plot()
|
11 |
+
plt.title('Graph of Tabular Data')
|
12 |
+
plt.xlabel('X-axis')
|
13 |
+
plt.ylabel('Y-axis')
|
14 |
+
plt.grid(True)
|
15 |
+
# Save the plot to a file
|
16 |
+
plt.savefig('plot.png')
|
17 |
+
return 'plot.png'
|
18 |
+
|
19 |
+
# Define the Gradio interface
|
20 |
+
inputs = gr.inputs.File(label="Upload CSV File")
|
21 |
+
outputs = gr.outputs.Image(type="file", label="Generated Graph")
|
22 |
+
|
23 |
+
gr.Interface(fn=plot_graph, inputs=inputs, outputs=outputs, title="Tabular Data Plotter").launch()
|