File size: 635 Bytes
8152368
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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
    plt.savefig('plot.png')
    return 'plot.png'

# Define the Gradio interface
interface = gr.Interface(
    fn=plot_graph,
    inputs=gr.File(label="Upload CSV File"),
    outputs=gr.Image(type="file", label="Generated Graph"),
    title="Tabular Data Plotter"
)

interface.launch()