Foros del Web » Programando para Internet » Python »

picking matplotlib python

Estas en el tema de picking matplotlib python en el foro de Python en Foros del Web. Tengo el siguiente código y necesito hacer click en una imagen y al hacer esto cambiar el valor [[1]] (por ejemplo) del arreglo im. Finalmente ...
  #1 (permalink)  
Antiguo 25/11/2015, 13:44
 
Fecha de Ingreso: noviembre-2015
Ubicación: México, D.F.
Mensajes: 1
Antigüedad: 8 años, 5 meses
Puntos: 0
picking matplotlib python

Tengo el siguiente código y necesito hacer click en una imagen y al hacer esto cambiar el valor [[1]] (por ejemplo) del arreglo im. Finalmente actualizar la gráfica

im[3] = ax.imshow([[1]], extent=(2, 3, 2, 3), picker=True, cmap=c, norm=norm, interpolation='nearest')

alguien se ha enfrentado a este problema y puede ayudarme a solucionarlo.

Gracias!


##
#!/usr/bin/env python

from __future__ import print_function
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
from matplotlib.patches import Rectangle
from matplotlib.text import Text
from matplotlib.image import AxesImage
import numpy as np
from numpy.random import rand

import numpy
from matplotlib.colors import ListedColormap
from matplotlib.colors import BoundaryNorm

# picking images (matplotlib.image.AxesImage)

COLOR=['blacK','blue','green','yellow','pink']
c=' '
c=ListedColormap(COLOR)
bounds=[-0.5,0.5,1.5,2.5,3.5,4.5]
norm = BoundaryNorm(bounds, c.N)
im=range(4)
fig, ax = plt.subplots()
im[0] = ax.imshow([[1]], extent=(1, 2, 1, 2), picker=True, cmap=c, norm=norm, interpolation='nearest')
im[1] = ax.imshow([[1]], extent=(2, 3, 1, 2), picker=True, cmap=c, norm=norm, interpolation='nearest')
im[2] = ax.imshow([[3]], extent=(1, 2, 2, 3), picker=True, cmap=c, norm=norm, interpolation='nearest')
im[3] = ax.imshow([[1]], extent=(2, 3, 2, 3), picker=True, cmap=c, norm=norm, interpolation='nearest')
ax.axis([0, 5, 0, 5])

def onpick4(event):
artist = event.artist
if isinstance(artist, AxesImage):
im = artist
A = im.get_extent()
print('onpick4 image',A)

img=ax.imshow([[1,2,3,4,5]], extent=(1, 1, 1, 1), picker=False, cmap=c, norm=norm, interpolation='nearest')
fig.canvas.mpl_connect('pick_event', onpick4)
cb=plt.colorbar(img, cmap=c, norm=norm, ticks=[0,1,2,3,4])
plt.show()

Etiquetas: enlazar, eventos
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 22:36.