pasuntaxih commited on
Commit
ea58dab
·
verified ·
1 Parent(s): 1be1326

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -2,11 +2,12 @@ import gradio as gr
2
  import numpy as np
3
  import matplotlib.pyplot as plt
4
 
5
- def draw_rectangles(colors, xs, ys, widths, heights):
 
6
  figs = []
7
  for color, x, y, width, height in zip(colors, xs, ys, widths, heights):
8
  fig, ax = plt.subplots()
9
- rect = plt.Rectangle((x, y), width, height, color=color)
10
  ax.add_patch(rect)
11
  ax.set_xlim(0, 10)
12
  ax.set_ylim(0, 10)
@@ -17,7 +18,7 @@ def draw_rectangles(colors, xs, ys, widths, heights):
17
  iface = gr.Interface(
18
  fn=draw_rectangles,
19
  inputs=[
20
- gr.ColorPicker(label="Colores de los Rectángulos", type="text", default=["blue", "red"]),
21
  gr.Slider(0, 10, 1, label="Posiciones X", default=[3, 6]),
22
  gr.Slider(0, 10, 1, label="Posiciones Y", default=[3, 4]),
23
  gr.Slider(0, 10, 1, label="Anchos", default=[2, 3]),
 
2
  import numpy as np
3
  import matplotlib.pyplot as plt
4
 
5
+ def draw_rectangles(color_string, xs, ys, widths, heights):
6
+ colors = color_string.split(',') # Convertimos el string de colores en una lista
7
  figs = []
8
  for color, x, y, width, height in zip(colors, xs, ys, widths, heights):
9
  fig, ax = plt.subplots()
10
+ rect = plt.Rectangle((x, y), width, height, color=color.strip()) # Eliminamos espacios en caso necesario
11
  ax.add_patch(rect)
12
  ax.set_xlim(0, 10)
13
  ax.set_ylim(0, 10)
 
18
  iface = gr.Interface(
19
  fn=draw_rectangles,
20
  inputs=[
21
+ gr.Textbox(label="Colores de los Rectángulos (separados por comas)", type="text", default="blue,red"),
22
  gr.Slider(0, 10, 1, label="Posiciones X", default=[3, 6]),
23
  gr.Slider(0, 10, 1, label="Posiciones Y", default=[3, 4]),
24
  gr.Slider(0, 10, 1, label="Anchos", default=[2, 3]),