def _addItem(self, axes, item): mplAxes = self._axes[axes] if isinstance(item, items.Curve): x, y = item.getData(copy=False) line = Line2D(xdata=x, ydata=y, color=item.color, marker=item.marker, linewidth=item.linewidth, linestyle=item.linestyle, zorder=item.z) # TODO error bars, scatter plot.. # TODO set picker mplAxes.add_line(line) self._items[item] = line elif isinstance(item, items.Image): # TODO ModestImage, set picker data = item.getData(copy=False) if len(data.shape) == 3: # RGB(A) images image = AxesImage(mplAxes, origin='lower', interpolation='nearest') else: # Colormap # TODO use own colormaps cmap = cm.get_cmap(item.colormap.cmap) if item.colormap.norm == 'log': norm = LogNorm(item.colormap.vbegin, item.colormap.vend) else: norm = Normalize(item.colormap.vbegin, item.colormap.vend) image = AxesImage(mplAxes, origin='lower', cmap=cmap, norm=norm, interpolation='nearest') image.set_data(data) image.set_zorder(item.z) height, width = data.shape[0:2] xmin, ymin = item.origin xmax = xmin + item.scale[0] * width ymax = xmax + item.scale[1] * height # set extent (left, right, bottom, top) if image.origin == 'upper': image.set_extent((xmin, xmax, ymax, ymin)) else: image.set_extent((xmin, xmax, ymin, ymax)) mplAxes.add_artist(image) self._items[item] = image else: logger.warning('Unsupported item type %s' % str(type(item)))