def _plt_topomap(ax, epoch, proj='default', res=100, im_frame=0.02, # empty space around sensors in the im colorspace=None, **im_kwargs): colorspace = _base.read_cs_arg(epoch, colorspace) handles = {} Y = epoch.get_epoch_data() Ymap = epoch.sensor.get_im_for_topo(Y, proj=proj, res=res, frame=im_frame) emin = -im_frame emax = 1 + im_frame map_kwargs = {'origin': "lower", 'extent': (emin, emax, emin, emax)} if colorspace.cmap: im_kwargs.update(map_kwargs) im_kwargs.update(colorspace.get_imkwargs()) handles['im'] = ax.imshow(Ymap, **im_kwargs) # contours if colorspace.contours: #print "contours: {0}".format(colorspace.contours) map_kwargs.update(colorspace.get_contour_kwargs()) h = ax.contour(Ymap, **map_kwargs) handles['contour'] = h return handles
def _plt_im_array(ax, epoch, dims=('time', 'sensor'), colorspace=None, **kwargs): handles = [] colorspace = _base.read_cs_arg(epoch, colorspace) data = epoch.get_data(dims) if data.ndim > 2: # print data.shape assert data.shape[0] == 1 data = data[0] if colorspace.cmap: im_kwargs = kwargs.copy() im_kwargs.update(colorspace.get_imkwargs()) h = ax.imshow(data, origin='lower', **im_kwargs) handles.append(h) if colorspace.contours: c_kwargs = kwargs.copy() c_kwargs.update(colorspace.get_contour_kwargs()) h = ax.contour(data, **c_kwargs) handles.append(h) return handles
def _ax_butterfly(ax, layers, sensors=None, ylim=None, extrema=False, title='{name}', xlabel=True, ylabel=True, color=None, **plot_kwargs): """ Arguments --------- ylim: y axis limits (scalar or (min, max) tuple) """ handles = [] xmin = [] xmax = [] name = '' for l in layers: colorspace = _base.read_cs_arg(l) if not colorspace.cmap: continue if color is None: plot_kwargs['color'] = l.properties.get('color', 'k') elif color is True: pass # no color kwarg to use mpl's color_cycle else: plot_kwargs['color'] = color # plot if extrema: h = _plt_extrema(ax, l, **plot_kwargs) else: h = _plt_uts(ax, l, sensors=sensors, **plot_kwargs) handles.append(h) xmin.append(l.time[0]) xmax.append(l.time[-1]) if not name: name = getattr(l, 'name', '') # axes decoration l = layers[0] if xlabel is True: xlabel = 'Time [s]' if ylabel is True: ylabel = l.properties.get('unit', None) if ylim is None: ylim = l.properties.get('ylim', None) ax.set_xlim(min(xmin), max(xmax)) if ylim: if np.isscalar(ylim): ax.set_ylim(-ylim, ylim) else: y_min, y_max = ylim ax.set_ylim(y_min, y_max) if xlabel not in [False, None]: ax.set_xlabel(xlabel) if ylabel not in [False, None]: ax.set_ylabel(ylabel) # ax.yaxis.set_offset_position('right') ax.yaxis.offsetText.set_va('top') ax.x_fmt = "t = %.3f s" if isinstance(title, str): ax.set_title(title.format(name=name)) return handles