File size: 931 Bytes
8152368
 
 
 
 
 
f5d1103
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8152368
f5d1103
 
a30008c
 
 
 
8152368
 
bc683d5
 
 
a30008c
bc683d5
 
8152368
bc683d5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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(figsize=(10, 5))
    for label, group_df in df.groupby(group_label):
        plt.plot(group_df[x_axis], group_df[y_axis], label=label)

    
    plt.title(f'{y_axis} of {group_label} over {x_axis}')
    plt.xlabel(x_axis)
    plt.ylabel(y_axis)
    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()