pasuntaxih commited on
Commit
2e0acec
路
verified 路
1 Parent(s): c30cf8e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -17
app.py CHANGED
@@ -2,32 +2,18 @@ import gradio as gr
2
  import numpy as np
3
  import matplotlib.pyplot as plt
4
 
5
- # Inicializar una figura y ejes al comienzo
6
- fig, ax = plt.subplots()
7
- ax.set_xlim(0, 10)
8
- ax.set_ylim(0, 10)
9
- plt.axis('off')
10
-
11
  def draw_rectangle(color, x, y, width, height):
 
12
  rect = plt.Rectangle((x, y), width, height, color=color)
13
  ax.add_patch(rect)
14
-
15
- # Funci贸n principal para la interfaz
16
- def draw_rectangles(color, x, y, width, height):
17
- # Limpiar ejes antes de dibujar un nuevo rect谩ngulo
18
- ax.clear()
19
  ax.set_xlim(0, 10)
20
  ax.set_ylim(0, 10)
21
  plt.axis('off')
22
-
23
- draw_rectangle(color, x, y, width, height)
24
-
25
- # Dibujar la figura actualizada
26
- fig.canvas.draw()
27
  return fig
28
 
29
  iface = gr.Interface(
30
- fn=draw_rectangles,
31
  inputs=[
32
  gr.ColorPicker(label="Color del Rect谩ngulo"),
33
  gr.Slider(0, 10, 1, label="Posici贸n X"),
 
2
  import numpy as np
3
  import matplotlib.pyplot as plt
4
 
 
 
 
 
 
 
5
  def draw_rectangle(color, x, y, width, height):
6
+ fig, ax = plt.subplots()
7
  rect = plt.Rectangle((x, y), width, height, color=color)
8
  ax.add_patch(rect)
 
 
 
 
 
9
  ax.set_xlim(0, 10)
10
  ax.set_ylim(0, 10)
11
  plt.axis('off')
12
+ plt.close(fig)
 
 
 
 
13
  return fig
14
 
15
  iface = gr.Interface(
16
+ fn=draw_rectangle,
17
  inputs=[
18
  gr.ColorPicker(label="Color del Rect谩ngulo"),
19
  gr.Slider(0, 10, 1, label="Posici贸n X"),