def new_series(self, x=None, y=None, z=None, colorbar=False, plotid=0, style='xy', **kw): plot, names, rd = self._series_factory(x, y, plotid=plotid, **kw) if style in ['xy', 'cmap_scatter']: if style == 'cmap_scatter': c = 'c1' self.series[plotid][1] += (c,) self.plots[plotid].data.set_data(c, []) names += (c,) return plot.plot(names, **rd) else: rd['xbounds'] = (0, 1) if 'xbounds' not in kw else kw.get('xbounds') rd['ybounds'] = (0, 1) if 'ybounds' not in kw else kw.get('ybounds') cmap = 'hot' if 'cmap' not in kw else kw.get('cmap') rd['poly_cmap'] = color_map_name_dict.get(cmap) rd['colormap'] = color_map_name_dict.get(cmap) zname = self.zdataname_generators[plotid].next() plot.data.set_data(zname, z) contour = plot.img_plot(zname, **rd)[0] plot.contour_plot(zname, type='poly', **rd) if 'levels' in kw: contour.levels = kw.get('levels') return contour, plot
def _plot_from_collection(plot, suffix, collection): """ Plot in Chaco Plot object `plot` given MPL Collection `collection`. """ xname = "cx_{0}".format(suffix) yname = "cy_{0}".format(suffix) cname = "cc_{0}".format(suffix) if isinstance(collection, mcoll.PathCollection): # then assume it is the data plotted via Axes.scatter ofs = collection.get_offsets() plot.data.set_data(xname, ofs[:, 0]) plot.data.set_data(yname, ofs[:, 1]) colarr = collection.get_array() if colarr is not None: plot.data.set_data(cname, colarr) cmap = collection.get_cmap() color_mapper = color_map_name_dict.get( cmap.name, color_map_name_dict["jet"]) plot.plot( (xname, yname, cname), type="cmap_scatter", color_mapper=color_mapper) # Note: I think this can result in different dot # colors because I don't know the color mapper works # in the same way in MPL and Chaco. Right way to do # it is to use ``get_facecolor()`` directly, but I # could not find the way to directly set dot colors. else: plot.plot( (xname, yname), type="scatter", color=tuple(*collection.get_facecolor()))
def new_series(self, x=None, y=None, z=None, colorbar=False, plotid=0, style='xy', **kw): plot, names, rd = self._series_factory(x, y, plotid=plotid, **kw) if style in ['xy', 'cmap_scatter']: if style == 'cmap_scatter': c = 'c1' self.series[plotid][1] += (c, ) if z is None: z = array([]) self.plots[plotid].data.set_data(c, z) names += (c, ) rd['type'] = style elif style == 'xy': if 'type' not in rd: rd['type'] = 'line' return plot.plot(names, **rd) else: rd['xbounds'] = (0, 1) if 'xbounds' not in kw else kw.get('xbounds') rd['ybounds'] = (0, 1) if 'ybounds' not in kw else kw.get('ybounds') cmap = 'hot' if 'cmap' not in kw else kw.get('cmap') rd['poly_cmap'] = color_map_name_dict.get(cmap) rd['colormap'] = color_map_name_dict.get(cmap) zname = next(self.zdataname_generators[plotid]) plot.data.set_data(zname, z) contour = plot.img_plot(zname, **rd)[0] plot.contour_plot(zname, type='poly', **rd) if 'levels' in kw: contour.levels = kw.get('levels') return contour, plot
def build_unconstrained_thermal_history(self, datacontainer, pid=4, contour=True): self.set_x_title('t (Ma)', plotid=pid) self.set_y_title('Temp (C)', plotid=pid) self.set_y_limits(min_=100, plotid=pid) if contour: if not self.zdataname_generators: self.zdataname_generators = [name_generator('z')] else: self.zdataname_generators.append(name_generator('z')) zname = next(self.zdataname_generators[-1]) x = [10, 350] y = [100, 600] plot, names, rd = self._series_factory(x, y, plotid=pid) plot.data.set_data(zname, datacontainer) rd['xbounds'] = tuple(x) rd['ybounds'] = tuple(y) cmap = 'yarg' cmap = color_map_name_dict.get(cmap) rd['colormap'] = cmap # contour = plot.img_plot(zname, # hide_grids=False, # **rd)[0] pline = plot.contour_plot(zname, hide_grids=False, **rd)[0] ppoly = plot.contour_plot(zname, type='poly', poly_cmap=cmap, hide_grids=False, **rd)[0] # self.groups['unconstrained_thermal_history'].append([pline, ppoly]) # remove zoom self.plots[pid].overlays.pop() return [pline, ppoly] else: plots = [] for s in datacontainer: xs = s[:, 0] ys = s[:, 1] a, _ = self.new_series(xs, ys) plots.append(a) return plots
def build_unconstrained_thermal_history(self, datacontainer, pid=4, contour=True): self.set_x_title('t (Ma)', plotid=pid) self.set_y_title('Temp (C)', plotid=pid) self.set_y_limits(min=100, plotid=pid) if contour: if not self.zdataname_generators: self.zdataname_generators = [name_generator('z')] else: self.zdataname_generators.append(name_generator('z')) zname = self.zdataname_generators[-1].next() x = [10, 350] y = [100, 600] plot, names, rd = self._series_factory(x, y, plotid=pid) plot.data.set_data(zname, datacontainer) rd['xbounds'] = tuple(x) rd['ybounds'] = tuple(y) cmap = 'yarg' cmap = color_map_name_dict.get(cmap) rd['colormap'] = cmap # contour = plot.img_plot(zname, # hide_grids=False, # **rd)[0] pline = plot.contour_plot(zname, hide_grids=False, **rd)[0] ppoly = plot.contour_plot(zname, type='poly', poly_cmap=cmap, hide_grids=False, **rd)[0] # self.groups['unconstrained_thermal_history'].append([pline, ppoly]) # remove zoom self.plots[pid].overlays.pop() # self.plotcontainer.draw_order = ['background', 'underlay', 'image', 'plot', 'selection', 'border', 'annotation', 'overlay'] return [pline, ppoly] else: plots = [] for s in datacontainer: xs = s[:, 0] ys = s[:, 1] a, _ = self.new_series(xs, ys) plots.append(a) return plots