matplotlib-demo / app.py
ZachGF's picture
Update app.py
361143b verified
raw
history blame
707 Bytes
import gradio as gr
import pandas as pd
import matplotlib.pyplot as plt
def plot_graph(file):
df = pd.read_csv(file.name)
x_axis = 'Date'
y_axis = 'Count'
group_label = 'Species'
df[x_axis] = pd.to_datetime(df[x_axis])
plt.figure()
df.plot()
plt.legend(title=group_label)
plt.grid(True)
plt.xticks(rotation=45)
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()