Python matplotlib.cm() Examples
The following are 30 code examples for showing how to use matplotlib.cm(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
You may check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
matplotlib
, or try the search function
.
Example 1
Project: neuropythy Author: noahbenson File: core.py License: GNU Affero General Public License v3.0 | 6 votes |
def apply_cmap(zs, cmap, vmin=None, vmax=None, unit=None, logrescale=False): ''' apply_cmap(z, cmap) applies the given cmap to the values in z; if vmin and/or vmax are passed, they are used to scale z. Note that this function can automatically rescale data into log-space if the colormap is a neuropythy log-space colormap such as log_eccentricity. To enable this behaviour use the optional argument logrescale=True. ''' zs = pimms.mag(zs) if unit is None else pimms.mag(zs, unit) zs = np.asarray(zs, dtype='float') if pimms.is_str(cmap): cmap = matplotlib.cm.get_cmap(cmap) if logrescale: if vmin is None: vmin = np.log(np.nanmin(zs)) if vmax is None: vmax = np.log(np.nanmax(zs)) mn = np.exp(vmin) u = zdivide(nanlog(zs + mn) - vmin, vmax - vmin, null=np.nan) else: if vmin is None: vmin = np.nanmin(zs) if vmax is None: vmax = np.nanmax(zs) u = zdivide(zs - vmin, vmax - vmin, null=np.nan) u[np.isnan(u)] = -np.inf return cmap(u)
Example 2
Project: defragTrees Author: sato9hara File: paper_synthetic2.py License: MIT License | 6 votes |
def plotTZ(filename=None): t = np.linspace(0, 1, 101) z = 0.25 + 0.5 / (1 + np.exp(- 20 * (t - 0.5))) + 0.05 * np.cos(t * 2 * np.pi) cmap = cm.get_cmap('cool') fig, (ax1, ax2) = plt.subplots(1, 2, gridspec_kw = {'width_ratios':[19, 1]}) poly1 = [[0, 0]] poly1.extend([[t[i], z[i]] for i in range(t.size)]) poly1.extend([[1, 0], [0, 0]]) poly2 = [[0, 1]] poly2.extend([[t[i], z[i]] for i in range(t.size)]) poly2.extend([[1, 1], [0, 1]]) poly1 = plt.Polygon(poly1,fc=cmap(0.0)) poly2 = plt.Polygon(poly2,fc=cmap(1.0)) ax1.add_patch(poly1) ax1.add_patch(poly2) ax1.set_xlabel('x1', size=22) ax1.set_ylabel('x2', size=22) ax1.set_title('True Data', size=28) colorbar.ColorbarBase(ax2, cmap=cmap, format='%.1f') ax2.set_ylabel('Output y', size=22) plt.show() if not filename is None: plt.savefig(filename, format="pdf", bbox_inches="tight") plt.close()
Example 3
Project: defragTrees Author: sato9hara File: paper_synthetic1.py License: MIT License | 6 votes |
def plotTZ(filename=None): cmap = cm.get_cmap('cool') fig, (ax1, ax2) = plt.subplots(1, 2, gridspec_kw = {'width_ratios':[19, 1]}) ax1.add_patch(pl.Rectangle(xy=[0, 0], width=0.5, height=0.5, facecolor=cmap(0.0), linewidth='2.0')) ax1.add_patch(pl.Rectangle(xy=[0.5, 0.5], width=0.5, height=0.5, facecolor=cmap(0.0), linewidth='2.0')) ax1.add_patch(pl.Rectangle(xy=[0, 0.5], width=0.5, height=0.5, facecolor=cmap(1.0), linewidth='2.0')) ax1.add_patch(pl.Rectangle(xy=[0.5, 0], width=0.5, height=0.5, facecolor=cmap(1.0), linewidth='2.0')) ax1.set_xlabel('x1', size=22) ax1.set_ylabel('x2', size=22) ax1.set_title('True Data', size=28) colorbar.ColorbarBase(ax2, cmap=cmap, format='%.1f') ax2.set_ylabel('Output y', size=22) plt.show() if not filename is None: plt.savefig(filename, format="pdf", bbox_inches="tight") plt.close()
Example 4
Project: Computable Author: ktraunmueller File: pyplot.py License: MIT License | 6 votes |
def set_cmap(cmap): """ Set the default colormap. Applies to the current image if any. See help(colormaps) for more information. *cmap* must be a :class:`~matplotlib.colors.Colormap` instance, or the name of a registered colormap. See :func:`matplotlib.cm.register_cmap` and :func:`matplotlib.cm.get_cmap`. """ cmap = cm.get_cmap(cmap) rc('image', cmap=cmap.name) im = gci() if im is not None: im.set_cmap(cmap) draw_if_interactive()
Example 5
Project: Computable Author: ktraunmueller File: pyplot.py License: MIT License | 6 votes |
def spy(Z, precision=0, marker=None, markersize=None, aspect='equal', hold=None, **kwargs): ax = gca() # allow callers to override the hold state by passing hold=True|False washold = ax.ishold() if hold is not None: ax.hold(hold) try: ret = ax.spy(Z, precision, marker, markersize, aspect, **kwargs) draw_if_interactive() finally: ax.hold(washold) if isinstance(ret, cm.ScalarMappable): sci(ret) return ret ################# REMAINING CONTENT GENERATED BY boilerplate.py ############## # This function was autogenerated by boilerplate.py. Do not edit as # changes will be lost
Example 6
Project: matplotlib-4-abaqus Author: Solid-Mechanics File: pyplot.py License: MIT License | 6 votes |
def set_cmap(cmap): """ Set the default colormap. Applies to the current image if any. See help(colormaps) for more information. *cmap* must be a :class:`~matplotlib.colors.Colormap` instance, or the name of a registered colormap. See :func:`matplotlib.cm.register_cmap` and :func:`matplotlib.cm.get_cmap`. """ cmap = cm.get_cmap(cmap) rc('image', cmap=cmap.name) im = gci() if im is not None: im.set_cmap(cmap) draw_if_interactive()
Example 7
Project: matplotlib-4-abaqus Author: Solid-Mechanics File: pyplot.py License: MIT License | 6 votes |
def spy(Z, precision=0, marker=None, markersize=None, aspect='equal', hold=None, **kwargs): ax = gca() # allow callers to override the hold state by passing hold=True|False washold = ax.ishold() if hold is not None: ax.hold(hold) try: ret = ax.spy(Z, precision, marker, markersize, aspect, **kwargs) draw_if_interactive() finally: ax.hold(washold) if isinstance(ret, cm.ScalarMappable): sci(ret) return ret ################# REMAINING CONTENT GENERATED BY boilerplate.py ############## # This function was autogenerated by boilerplate.py. Do not edit as # changes will be lost
Example 8
Project: neural-network-animation Author: miloharper File: pyplot.py License: MIT License | 6 votes |
def set_cmap(cmap): """ Set the default colormap. Applies to the current image if any. See help(colormaps) for more information. *cmap* must be a :class:`~matplotlib.colors.Colormap` instance, or the name of a registered colormap. See :func:`matplotlib.cm.register_cmap` and :func:`matplotlib.cm.get_cmap`. """ cmap = cm.get_cmap(cmap) rc('image', cmap=cmap.name) im = gci() if im is not None: im.set_cmap(cmap) draw_if_interactive()
Example 9
Project: neural-network-animation Author: miloharper File: pyplot.py License: MIT License | 6 votes |
def spy(Z, precision=0, marker=None, markersize=None, aspect='equal', hold=None, **kwargs): ax = gca() # allow callers to override the hold state by passing hold=True|False washold = ax.ishold() if hold is not None: ax.hold(hold) try: ret = ax.spy(Z, precision, marker, markersize, aspect, **kwargs) draw_if_interactive() finally: ax.hold(washold) if isinstance(ret, cm.ScalarMappable): sci(ret) return ret ################# REMAINING CONTENT GENERATED BY boilerplate.py ############## # This function was autogenerated by boilerplate.py. Do not edit as # changes will be lost
Example 10
Project: GraphicDesignPatternByPython Author: Relph1119 File: pyplot.py License: MIT License | 6 votes |
def gci(): """ Get the current colorable artist. Specifically, returns the current :class:`~matplotlib.cm.ScalarMappable` instance (image or patch collection), or *None* if no images or patch collections have been defined. The commands :func:`~matplotlib.pyplot.imshow` and :func:`~matplotlib.pyplot.figimage` create :class:`~matplotlib.image.Image` instances, and the commands :func:`~matplotlib.pyplot.pcolor` and :func:`~matplotlib.pyplot.scatter` create :class:`~matplotlib.collections.Collection` instances. The current image is an attribute of the current axes, or the nearest earlier axes in the current figure that contains an image. """ return gcf()._gci() ## Any Artist ## # (getp is simply imported)
Example 11
Project: GraphicDesignPatternByPython Author: Relph1119 File: pyplot.py License: MIT License | 6 votes |
def set_cmap(cmap): """ Set the default colormap. Applies to the current image if any. See help(colormaps) for more information. *cmap* must be a :class:`~matplotlib.colors.Colormap` instance, or the name of a registered colormap. See :func:`matplotlib.cm.register_cmap` and :func:`matplotlib.cm.get_cmap`. """ cmap = cm.get_cmap(cmap) rc('image', cmap=cmap.name) im = gci() if im is not None: im.set_cmap(cmap)
Example 12
Project: python3_ios Author: holzschu File: embedding_in_wx3_sgskip.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
def init_plot_data(self): a = self.fig.add_subplot(111) x = np.arange(120.0) * 2 * np.pi / 60.0 y = np.arange(100.0) * 2 * np.pi / 50.0 self.x, self.y = np.meshgrid(x, y) z = np.sin(self.x) + np.cos(self.y) self.im = a.imshow(z, cmap=cm.RdBu) # , interpolation='nearest') zmax = np.max(z) - ERR_TOL ymax_i, xmax_i = np.nonzero(z >= zmax) if self.im.origin == 'upper': ymax_i = z.shape[0] - ymax_i self.lines = a.plot(xmax_i, ymax_i, 'ko') self.toolbar.update() # Not sure why this is needed - ADS
Example 13
Project: python3_ios Author: holzschu File: test_colors.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_light_source_topo_surface(): """Shades a DEM using different v.e.'s and blend modes.""" fname = cbook.get_sample_data('jacksboro_fault_dem.npz', asfileobj=False) dem = np.load(fname) elev = dem['elevation'] # Get the true cellsize in meters for accurate vertical exaggeration # Convert from decimal degrees to meters dx, dy = dem['dx'], dem['dy'] dx = 111320.0 * dx * np.cos(dem['ymin']) dy = 111320.0 * dy dem.close() ls = mcolors.LightSource(315, 45) cmap = cm.gist_earth fig, axes = plt.subplots(nrows=3, ncols=3) for row, mode in zip(axes, ['hsv', 'overlay', 'soft']): for ax, ve in zip(row, [0.1, 1, 10]): rgb = ls.shade(elev, cmap, vert_exag=ve, dx=dx, dy=dy, blend_mode=mode) ax.imshow(rgb) ax.set(xticks=[], yticks=[])
Example 14
Project: python3_ios Author: holzschu File: pyplot.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
def gci(): """ Get the current colorable artist. Specifically, returns the current :class:`~matplotlib.cm.ScalarMappable` instance (image or patch collection), or *None* if no images or patch collections have been defined. The commands :func:`~matplotlib.pyplot.imshow` and :func:`~matplotlib.pyplot.figimage` create :class:`~matplotlib.image.Image` instances, and the commands :func:`~matplotlib.pyplot.pcolor` and :func:`~matplotlib.pyplot.scatter` create :class:`~matplotlib.collections.Collection` instances. The current image is an attribute of the current axes, or the nearest earlier axes in the current figure that contains an image. """ return gcf()._gci() ## Any Artist ## # (getp is simply imported)
Example 15
Project: python3_ios Author: holzschu File: pyplot.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
def set_cmap(cmap): """ Set the default colormap. Applies to the current image if any. See help(colormaps) for more information. *cmap* must be a :class:`~matplotlib.colors.Colormap` instance, or the name of a registered colormap. See :func:`matplotlib.cm.register_cmap` and :func:`matplotlib.cm.get_cmap`. """ cmap = cm.get_cmap(cmap) rc('image', cmap=cmap.name) im = gci() if im is not None: im.set_cmap(cmap)
Example 16
Project: nmp_qc Author: priba File: Plotter.py License: MIT License | 5 votes |
def plot_graph(self, am, position=None, cls=None, fig_name='graph.png'): with warnings.catch_warnings(): warnings.filterwarnings("ignore") g = nx.from_numpy_matrix(am) if position is None: position=nx.drawing.circular_layout(g) fig = plt.figure() if cls is None: cls='r' else: # Make a user-defined colormap. cm1 = mcol.LinearSegmentedColormap.from_list("MyCmapName", ["r", "b"]) # Make a normalizer that will map the time values from # [start_time,end_time+1] -> [0,1]. cnorm = mcol.Normalize(vmin=0, vmax=1) # Turn these into an object that can be used to map time values to colors and # can be passed to plt.colorbar(). cpick = cm.ScalarMappable(norm=cnorm, cmap=cm1) cpick.set_array([]) cls = cpick.to_rgba(cls) plt.colorbar(cpick, ax=fig.add_subplot(111)) nx.draw(g, pos=position, node_color=cls, ax=fig.add_subplot(111)) fig.savefig(os.path.join(self.plotdir, fig_name))
Example 17
Project: neuropythy Author: noahbenson File: core.py License: GNU Affero General Public License v3.0 | 5 votes |
def scale_for_cmap(cmap, x, vmin=Ellipsis, vmax=Ellipsis, unit=Ellipsis): ''' scale_for_cmap(cmap, x) yields the values in x rescaled to be appropriate for the given colormap cmap. The cmap must be the name of a colormap or a colormap object. For a given cmap argument, if the object is a colormap itself, it is treated as cmap.name. If the cmap names a colormap known to neuropythy, neuropythy will rescale the values in x according to a heuristic. ''' import matplotlib as mpl if isinstance(cmap, mpl.colors.Colormap): cmap = cmap.name (name, cm) = (None, None) if cmap not in colormaps: for (k,v) in six.iteritems(colormaps): if cmap in k: (name, cm) = (k, v) break else: (name, cm) = (cmap, colormaps[cmap]) if cm is not None: cm = cm if len(cm) == 3 else (cm + (None,)) (cm, (mn,mx), uu) = cm if vmin is Ellipsis: vmin = mn if vmax is Ellipsis: vmax = mx if unit is Ellipsis: unit = uu if vmin is Ellipsis: vmin = None if vmax is Ellipsis: vmax = None if unit is Ellipsis: unit = None x = pimms.mag(x) if unit is None else pimms.mag(x, unit) if name is not None and name.startswith('log_'): emn = np.exp(vmin) x = np.log(x + emn) vmin = np.nanmin(x) if vmin is None else vmin vmax = np.nanmax(x) if vmax is None else vmax return zdivide(x - vmin, vmax - vmin, null=np.nan)
Example 18
Project: neuropythy Author: noahbenson File: core.py License: GNU Affero General Public License v3.0 | 5 votes |
def guess_cortex_cmap(pname): ''' guess_cortex_cmap(proptery_name) yields a tuple (cmap, (vmin, vmax)) of a cortical color map appropriate to the given property name and the suggested value scaling for the cmap. If the given property is not a string or is not recognized then the log_eccentricity axis is used and the suggested vmin and vmax are None. ''' import matplotlib as mpl if isinstance(pname, mpl.colors.Colormap): pname = pname.name if not pimms.is_str(pname): return ('eccenflat', cmap_eccenflat, (None, None), None) if pname in colormaps: (cm,cmname) = (colormaps[pname],pname) else: # check each manually cm = None for (k,v) in six.iteritems(colormaps): if pname.endswith(k): (cmname,cm) = (k,v) break if cm is None: for (k,v) in six.iteritems(colormaps): if pname.startswith(k): (cmname,cm) = (k,v) break # we prefer log-eccentricity when possible if cm is None: return ('eccenflat', cmap_eccenflat, (None, None), None) if ('log_'+cmname) in colormaps: cmname = 'log_'+cmname cm = colormaps[cmname] return (cmname,) + (cm if len(cm) == 3 else cm + (None,))
Example 19
Project: NanoPlot Author: wdecoster File: utils.py License: GNU General Public License v3.0 | 5 votes |
def list_colormaps(): print("{}".format(", ".join([c.strip() for c in cm.cmap_d.keys()]))) sys.exit(0)
Example 20
Project: yolo2-pytorch Author: ruiminshen File: visualize.py License: GNU Lesser General Public License v3.0 | 5 votes |
def __init__(self, alpha=0.5, cmap=None): self.alpha = alpha self.cm = matplotlib.cm.get_cmap(cmap)
Example 21
Project: yolo2-pytorch Author: ruiminshen File: visualize.py License: GNU Lesser General Public License v3.0 | 5 votes |
def __call__(self, image, feature, debug=False): _feature = (feature * self.cm.N).astype(np.int) heatmap = self.cm(_feature)[:, :, :3] * 255 heatmap = cv2.resize(heatmap, image.shape[1::-1], interpolation=cv2.INTER_NEAREST) canvas = (image * (1 - self.alpha) + heatmap * self.alpha).astype(np.uint8) if debug: cv2.imshow('max=%f, sum=%f' % (np.max(feature), np.sum(feature)), canvas) cv2.waitKey(0) return canvas
Example 22
Project: yolo2-pytorch Author: ruiminshen File: visualize.py License: GNU Lesser General Public License v3.0 | 5 votes |
def __init__(self, config, state_dict, cmap=None): self.dot = graphviz.Digraph(node_attr=dict(config.items('digraph_node_attr')), graph_attr=dict(config.items('digraph_graph_attr'))) self.dot.format = config.get('graph', 'format') self.state_dict = state_dict self.var_name = {t._cdata: k for k, t in state_dict.items()} self.seen = set() self.index = 0 self.drawn = set() self.cm = matplotlib.cm.get_cmap(cmap) self.metric = eval(config.get('graph', 'metric')) metrics = [self.metric(t) for t in state_dict.values()] self.minmax = [min(metrics), max(metrics)]
Example 23
Project: yolo2-pytorch Author: ruiminshen File: visualize.py License: GNU Lesser General Public License v3.0 | 5 votes |
def _tensor_color(self, tensor): level = self._norm(self.metric(tensor)) fillcolor = self.cm(np.int(level * self.cm.N)) fontcolor = self.cm(self.cm.N if level < 0.5 else 0) return matplotlib.colors.to_hex(fillcolor), matplotlib.colors.to_hex(fontcolor)
Example 24
Project: cgpm Author: probcomp File: zero_corr.py License: Apache License 2.0 | 5 votes |
def plot_samples(samples, dist, noise, modelno, num_samples, timestamp): """Plot the observed samples and posterior samples side-by-side.""" print 'Plotting samples %s %f' % (dist, noise) fig, ax = plt.subplots(nrows=1, ncols=2) fig.suptitle( '%s (noise %1.2f, sample %d)' % (dist, noise, modelno), size=16) # Plot the observed samples. T = simulate_dataset(dist, noise, num_samples) # ax[0].set_title('Observed Data') ax[0].text( .5, .95, 'Observed Data', horizontalalignment='center', transform=ax[0].transAxes) ax[0].set_xlabel('x1') ax[0].set_ylabel('x2') ax[0].scatter(T[:,0], T[:,1], color='k', alpha=.5) ax[0].set_xlim(simulator_limits[dist][0]) ax[0].set_ylim(simulator_limits[dist][1]) ax[0].grid() # Plot posterior distribution. # ax[1].set_title('CrossCat Posterior Samples') ax[1].text( .5, .95, 'CrossCat Posterior Samples', horizontalalignment='center', transform=ax[1].transAxes) ax[1].set_xlabel('x1') clusters = set(samples[:,2]) colors = iter(matplotlib.cm.gist_rainbow( np.linspace(0, 1, len(clusters)+2))) for c in clusters: sc = samples[samples[:,2] == c][:,[0,1]] ax[1].scatter(sc[:,0], sc[:,1], alpha=.5, color=next(colors)) ax[1].set_xlim(ax[0].get_xlim()) ax[1].set_ylim(ax[0].get_ylim()) ax[1].grid() # Save. # fig.set_tight_layout(True) fig.savefig(filename_samples_figure(dist, noise, modelno, timestamp)) plt.close('all')
Example 25
Project: python-wifi-survey-heatmap Author: jantman File: heatmap.py License: GNU Affero General Public License v3.0 | 5 votes |
def _plot(self, a, key, title, gx, gy, num_x, num_y): pp.rcParams['figure.figsize'] = ( self._image_width / 300, self._image_height / 300 ) pp.title(title) # Interpolate the data rbf = Rbf( a['x'], a['y'], a[key], function='linear' ) z = rbf(gx, gy) z = z.reshape((num_y, num_x)) # Render the interpolated data to the plot pp.axis('off') # begin color mapping norm = matplotlib.colors.Normalize( vmin=min(a[key]), vmax=max(a[key]), clip=True ) mapper = cm.ScalarMappable(norm=norm, cmap='RdYlBu_r') # end color mapping image = pp.imshow( z, extent=(0, self._image_width, self._image_height, 0), cmap='RdYlBu_r', alpha=0.5, zorder=100 ) pp.colorbar(image) pp.imshow(self._layout, interpolation='bicubic', zorder=1, alpha=1) # begin plotting points for idx in range(0, len(a['x'])): pp.plot( a['x'][idx], a['y'][idx], marker='o', markeredgecolor='black', markeredgewidth=1, markerfacecolor=mapper.to_rgba(a[key][idx]), markersize=6 ) # end plotting points fname = '%s_%s.png' % (key, self._title) logger.info('Writing plot to: %s', fname) pp.savefig(fname, dpi=300) pp.close('all')
Example 26
Project: defragTrees Author: sato9hara File: RulePlotter.py License: MIT License | 5 votes |
def plotRule(mdl, X, d1, d2, alpha=0.8, filename='', rnum=-1, plot_line=[]): cmap = cm.get_cmap('cool') fig, (ax1, ax2) = plt.subplots(1, 2, gridspec_kw = {'width_ratios':[19, 1]}) if rnum <= 0: rnum = len(mdl.rule_) else: rnum = min(len(mdl.rule_), rnum) idx = np.argsort(mdl.weight_[:rnum]) for i in range(rnum): r = mdl.rule_[idx[i]] box, vmin, vmax = __r2boxWithX(r, X) if mdl.modeltype_ == 'regression': c = cmap(mdl.pred_[idx[i]]) elif mdl.modeltype_ == 'classification': r = mdl.pred_[idx[i]] / max(np.unique(mdl.pred_).size - 1, 1) c = cmap(r) ax1.add_patch(pl.Rectangle(xy=[box[0, d1], box[0, d2]], width=(box[1, d1] - box[0, d1]), height=(box[1, d2] - box[0, d2]), facecolor=c, linewidth='2.0', alpha=alpha)) if len(plot_line) > 0: for l in plot_line: ax1.plot(l[0], l[1], 'k--') ax1.set_xlabel('x1', size=22) ax1.set_ylabel('x2', size=22) ax1.set_title('Simplified Model (K = %d)' % (rnum,), size=28) colorbar.ColorbarBase(ax2, cmap=cmap, format='%.1f') ax2.set_ylabel('Predictor y', size=22) plt.show() if not filename == '': plt.savefig(filename, format="pdf", bbox_inches="tight") plt.close()
Example 27
Project: defragTrees Author: sato9hara File: RulePlotter.py License: MIT License | 5 votes |
def plotEachRule(mdl, X, d1, d2, alpha=0.8, filename='', rnum=-1, plot_line=[]): if rnum <= 0: rnum = len(mdl.rule_) else: rnum = min(len(mdl.rule_), rnum) m = rnum // 4 if m * 4 < rnum: m += 1 cmap = cm.get_cmap('cool') fig, ax = plt.subplots(m, 4 + 1, figsize=(4 * 4, 3 * m), gridspec_kw = {'width_ratios':[15, 15, 15, 15, 1]}) idx = np.argsort(mdl.weight_[:rnum]) for i in range(rnum): j = i // 4 k = i - 4 * j r = mdl.rule_[idx[i]] box, vmin, vmax = __r2boxWithX(r, X) if mdl.modeltype_ == 'regression': c = cmap(mdl.pred_[idx[i]]) elif mdl.modeltype_ == 'classification': r = mdl.pred_[idx[i]] / max(np.unique(mdl.pred_).size - 1, 1) c = cmap(r) ax[j, k].add_patch(pl.Rectangle(xy=[box[0, d1], box[0, d2]], width=(box[1, d1] - box[0, d1]), height=(box[1, d2] - box[0, d2]), facecolor=c, linewidth='2.0', alpha=alpha)) if len(plot_line) > 0: for l in plot_line: ax[j, k].plot(l[0], l[1], 'k--') ax[j, k].set_xlim([0, 1]) ax[j, k].set_ylim([0, 1]) if k == 3: cbar = colorbar.ColorbarBase(ax[j, -1], cmap=cmap, format='%.1f', ticks=[0.0, 0.5, 1.0]) cbar.ax.set_yticklabels([0.0, 0.5, 1.0]) ax[j, -1].set_ylabel('Predictor y', size=12) plt.show() if not filename == '': plt.savefig(filename, format="pdf", bbox_inches="tight") plt.close()
Example 28
Project: Computable Author: ktraunmueller File: pyplot.py License: MIT License | 5 votes |
def gci(): """ Get the current colorable artist. Specifically, returns the current :class:`~matplotlib.cm.ScalarMappable` instance (image or patch collection), or *None* if no images or patch collections have been defined. The commands :func:`~matplotlib.pyplot.imshow` and :func:`~matplotlib.pyplot.figimage` create :class:`~matplotlib.image.Image` instances, and the commands :func:`~matplotlib.pyplot.pcolor` and :func:`~matplotlib.pyplot.scatter` create :class:`~matplotlib.collections.Collection` instances. The current image is an attribute of the current axes, or the nearest earlier axes in the current figure that contains an image. """ return gcf()._gci()
Example 29
Project: Computable Author: ktraunmueller File: pyplot.py License: MIT License | 5 votes |
def autumn(): ''' set the default colormap to autumn and apply to current image if any. See help(colormaps) for more information ''' rc('image', cmap='autumn') im = gci() if im is not None: im.set_cmap(cm.autumn) draw_if_interactive() # This function was autogenerated by boilerplate.py. Do not edit as # changes will be lost
Example 30
Project: Computable Author: ktraunmueller File: pyplot.py License: MIT License | 5 votes |
def bone(): ''' set the default colormap to bone and apply to current image if any. See help(colormaps) for more information ''' rc('image', cmap='bone') im = gci() if im is not None: im.set_cmap(cm.bone) draw_if_interactive() # This function was autogenerated by boilerplate.py. Do not edit as # changes will be lost