Spaces:
Sleeping
Sleeping
import gradio as gr | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
def plot_graph(file): | |
# Read the CSV file | |
df = pd.read_csv(file.name) | |
# Generate a simple plot | |
plt.figure() | |
df.plot() | |
plt.title('Graph of Tabular Data') | |
plt.xlabel('X-axis') | |
plt.ylabel('Y-axis') | |
plt.grid(True) | |
# Save the plot to a file | |
plot_filename = 'plot.png' | |
plt.savefig(plot_filename) | |
plt.close() | |
return plot_filename | |
# Define the Gradio interface | |
interface = gr.Interface( | |
fn=plot_graph, | |
inputs=gr.File(label="Upload CSV File"), | |
outputs=gr.Image(type="filepath", label="Generated Graph"), | |
title="Tabular Data Plotter" | |
) | |
interface.launch() | |