Spaces:
Runtime error
Runtime error
File size: 1,452 Bytes
c6379ae 9be415c da71915 c6379ae da71915 e94f3be ca1f7a3 da71915 e94f3be f305b38 da71915 ca1f7a3 c12e9d0 602a264 ca1f7a3 9445aeb da71915 602a264 da71915 f305b38 da71915 ee16303 ca1f7a3 ee16303 da71915 9445aeb da71915 9239ab3 da71915 9239ab3 da71915 9239ab3 f305b38 da71915 |
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
import gradio as gr
import pandas as pd
import matplotlib.pyplot as plt
def update_dropdowns(file):
if file is None:
return gr.Dropdown(choices=[]), gr.Dropdown(choices=[])
df = pd.read_csv(file)
columns = list(df.columns)
return gr.Dropdown(choices=columns), gr.Dropdown(choices=columns)
def create_scatter_plot(file, x_col, y_col):
if not file or not x_col or not y_col:
return None
df = pd.read_csv(file)
plt.figure(figsize=(10, 6))
plt.scatter(df[x_col], df[y_col])
plt.title(f"{x_col} vs {y_col}")
plt.xlabel(x_col)
plt.ylabel(y_col)
plt.grid(True)
plt.savefig("scatter_plot.png")
return "scatter_plot.png"
with gr.Blocks() as app:
gr.Markdown("# CSV Veri Görselleştirme Aracı")
with gr.Row():
csv_file = gr.File(label="CSV Dosyası Yükle", type="filepath")
with gr.Row():
x_axis = gr.Dropdown(label="X Ekseni Parametresi", interactive=True)
y_axis = gr.Dropdown(label="Y Ekseni Parametresi", interactive=True)
plot_button = gr.Button("Grafiği Oluştur")
with gr.Row():
plot_output = gr.Image(label="Scatter Plot")
csv_file.change(
fn=update_dropdowns,
inputs=csv_file,
outputs=[x_axis, y_axis]
)
plot_button.click(
fn=create_scatter_plot,
inputs=[csv_file, x_axis, y_axis],
outputs=plot_output
)
app.launch() |