当前位置: 首页>>代码示例>>Python>>正文


Python colors.LogNorm方法代码示例

本文整理汇总了Python中matplotlib.colors.LogNorm方法的典型用法代码示例。如果您正苦于以下问题:Python colors.LogNorm方法的具体用法?Python colors.LogNorm怎么用?Python colors.LogNorm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.colors的用法示例。


在下文中一共展示了colors.LogNorm方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: plot

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import LogNorm [as 别名]
def plot(ax, x, y, xlabel, ylabel, axmin, axmax, text):
    a,b,c, im = ax.hist2d(
            x, y,
            bins=40, norm=LogNorm(), cmap="gray_r",
            range=([axmin,axmax],[axmin,axmax]))
    ax.plot([axmin,axmax], [axmin,axmax], c='k')
    #props = dict(boxstyle='round', facecolor='white', pad=0.1)
    ax.text(
            0.05, 0.8, text, 
            horizontalalignment='left', verticalalignment='bottom', 
            transform=ax.transAxes, fontsize=25)

    ax.set_xlabel(xlabel, fontsize=16)
    ax.set_ylabel(ylabel, fontsize=20)
    ax.tick_params(axis='y', labelsize=20)
    ax.tick_params(axis='x', labelsize=20)
    ax.set_xlim(axmin, axmax)
    ax.set_ylim(axmin, axmax)
    ax.yaxis.set_major_locator(
            MaxNLocator(nbins=5))
    ax.xaxis.set_major_locator(
            MaxNLocator(nbins=5))
    return im 
开发者ID:annayqho,项目名称:TheCannon,代码行数:25,代码来源:mass_age_comparison.py

示例2: _select_locator

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import LogNorm [as 别名]
def _select_locator(self, formatter):
        '''
        select a suitable locator
        '''
        if self.boundaries is None:
            if isinstance(self.norm, colors.NoNorm):
                nv = len(self._values)
                base = 1 + int(nv/10)
                locator = ticker.IndexLocator(base=base, offset=0)
            elif isinstance(self.norm, colors.BoundaryNorm):
                b = self.norm.boundaries
                locator = ticker.FixedLocator(b, nbins=10)
            elif isinstance(self.norm, colors.LogNorm):
                locator = ticker.LogLocator()
            else:
                locator = ticker.MaxNLocator(nbins=5)
        else:
            b = self._boundaries[self._inside]
            locator = ticker.FixedLocator(b) #, nbins=10)

        self.cbar_axis.set_major_locator(locator) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:23,代码来源:colorbar.py

示例3: _reset_locator_formatter_scale

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import LogNorm [as 别名]
def _reset_locator_formatter_scale(self):
        """
        Reset the locator et al to defaults.  Any user-hardcoded changes
        need to be re-entered if this gets called (either at init, or when
        the mappable normal gets changed: Colorbar.update_normal)
        """
        self.locator = None
        self.formatter = None
        if (isinstance(self.norm, colors.LogNorm)
                and self._use_auto_colorbar_locator()):
            # *both* axes are made log so that determining the
            # mid point is easier.
            self.ax.set_xscale('log')
            self.ax.set_yscale('log')

            self.minorticks_on()
        else:
            self.ax.set_xscale('linear')
            self.ax.set_yscale('linear') 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:21,代码来源:colorbar.py

示例4: config_axis

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import LogNorm [as 别名]
def config_axis(self):
        ax = self.ax
        if (isinstance(self.norm, colors.LogNorm)
                and self._use_auto_colorbar_locator()):
            # *both* axes are made log so that determining the
            # mid point is easier.
            ax.set_xscale('log')
            ax.set_yscale('log')

        if self.orientation == 'vertical':
            long_axis, short_axis = ax.yaxis, ax.xaxis
        else:
            long_axis, short_axis = ax.xaxis, ax.yaxis

        long_axis.set_label_position(self.ticklocation)
        long_axis.set_ticks_position(self.ticklocation)
        short_axis.set_ticks([])
        short_axis.set_ticks([], minor=True)

        self._set_label() 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:22,代码来源:colorbar.py

示例5: config_axis

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import LogNorm [as 别名]
def config_axis(self):
        ax = self.ax
        if (isinstance(self.norm, colors.LogNorm)
                and self._use_auto_colorbar_locator()):
            # *both* axes are made log so that determining the
            # mid point is easier.
            ax.set_xscale('log')
            ax.set_yscale('log')

        if self.orientation == 'vertical':
            long_axis, short_axis = ax.yaxis, ax.xaxis
        else:
            long_axis, short_axis = ax.xaxis, ax.yaxis

        long_axis.set_label_position(self.ticklocation)
        long_axis.set_ticks_position(self.ticklocation)
        short_axis.set_ticks([])
        short_axis.set_ticks([], minor=True)
        self._set_label() 
开发者ID:holzschu,项目名称:python3_ios,代码行数:21,代码来源:colorbar.py

示例6: test_colorbar_autotickslog

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import LogNorm [as 别名]
def test_colorbar_autotickslog():
    # Test new autotick modes...
    with rc_context({'_internal.classic_mode': False}):
        fig, ax = plt.subplots(2, 1)
        x = np.arange(-3.0, 4.001)
        y = np.arange(-4.0, 3.001)
        X, Y = np.meshgrid(x, y)
        Z = X * Y
        pcm = ax[0].pcolormesh(X, Y, 10**Z, norm=LogNorm())
        cbar = fig.colorbar(pcm, ax=ax[0], extend='both',
                            orientation='vertical')

        pcm = ax[1].pcolormesh(X, Y, 10**Z, norm=LogNorm())
        cbar2 = fig.colorbar(pcm, ax=ax[1], extend='both',
                            orientation='vertical', shrink=0.4)
        np.testing.assert_almost_equal(cbar.ax.yaxis.get_ticklocs(),
                10**np.arange(-12, 12.2, 4.))
        np.testing.assert_almost_equal(cbar2.ax.yaxis.get_ticklocs(),
                10**np.arange(-12, 13., 12.)) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:21,代码来源:test_colorbar.py

示例7: test_colorbar_renorm

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import LogNorm [as 别名]
def test_colorbar_renorm():
    x, y = np.ogrid[-4:4:31j, -4:4:31j]
    z = 120000*np.exp(-x**2 - y**2)

    fig, ax = plt.subplots()
    im = ax.imshow(z)
    cbar = fig.colorbar(im)

    norm = LogNorm(z.min(), z.max())
    im.set_norm(norm)
    cbar.set_norm(norm)
    cbar.locator = LogLocator()
    cbar.formatter = LogFormatter()
    cbar.update_normal(im)
    assert np.isclose(cbar.vmin, z.min())

    norm = LogNorm(z.min() * 1000, z.max() * 1000)
    im.set_norm(norm)
    cbar.set_norm(norm)
    cbar.update_normal(im)
    assert np.isclose(cbar.vmin, z.min() * 1000)
    assert np.isclose(cbar.vmax, z.max() * 1000) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:24,代码来源:test_colorbar.py

示例8: heatmap

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import LogNorm [as 别名]
def heatmap(df,fname=None,cmap='seismic',log=False):
    """Plot a heat map"""

    from matplotlib.colors import LogNorm
    f=plt.figure(figsize=(8,8))
    ax=f.add_subplot(111)
    norm=None
    df=df.replace(0,.1)
    if log==True:
        norm=LogNorm(vmin=df.min().min(), vmax=df.max().max())
    hm = ax.pcolor(df,cmap=cmap,norm=norm)
    plt.colorbar(hm,ax=ax,shrink=0.6,norm=norm)
    plt.yticks(np.arange(0.5, len(df.index), 1), df.index)
    plt.xticks(np.arange(0.5, len(df.columns), 1), df.columns, rotation=90)
    #ax.axvline(4, color='gray'); ax.axvline(8, color='gray')
    plt.tight_layout()
    if fname != None:
        f.savefig(fname+'.png')
    return ax 
开发者ID:dmnfarrell,项目名称:smallrnaseq,代码行数:21,代码来源:plotting.py

示例9: norm

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import LogNorm [as 别名]
def norm(self, norm):

        if norm == "lin":
            self.pixels.norm = Normalize()
        elif norm == "log":
            self.pixels.norm = LogNorm()
            self.pixels.autoscale()  # this is to handle matplotlib bug #5424
        elif norm == "symlog":
            self.pixels.norm = SymLogNorm(linthresh=1.0)
            self.pixels.autoscale()
        elif isinstance(norm, Normalize):
            self.pixels.norm = norm
        else:
            raise ValueError(
                "Unsupported norm: '{}', options are 'lin',"
                "'log','symlog', or a matplotlib Normalize object".format(norm)
            )

        self.update(force=True)
        self.pixels.autoscale() 
开发者ID:cta-observatory,项目名称:ctapipe,代码行数:22,代码来源:mpl_camera.py

示例10: plot_weightings

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import LogNorm [as 别名]
def plot_weightings(self, weightings, ax, name='Weightings', mode='log', color='YlOrRd'):
        assert weightings.shape.__len__() == 2, "plot weightings: need 2D matrix as data"
        if mode == 'log':
            norm = colors.LogNorm(vmin=1e-3, vmax=1)
        else:
            norm = colors.Normalize(vmin=0, vmax=1)
        img = ax.imshow(np.transpose(weightings), interpolation='nearest', norm=norm, cmap=color,
                        aspect='auto')  # gist_stern
        ax.set_adjustable('box-forced')
        if self.title:
            ax.set_ylabel(name, size=self.text_size)
        if self.legend:
            box = ax.get_position()
            ax.set_position([box.x0 - 0.001, box.y0, box.width, box.height])
            axColor = plt.axes([box.x0 + box.width + 0.005, box.y0, 0.005, box.height])
            cb = plt.colorbar(img, cax=axColor, orientation="vertical")
            for l in cb.ax.yaxis.get_ticklabels():
                l.set_size(self.text_size) 
开发者ID:JoergFranke,项目名称:ADNC,代码行数:20,代码来源:plot_functions.py

示例11: plot_fees

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import LogNorm [as 别名]
def plot_fees(forwarding_events):
    """
    Plots forwarding fees and effective fee rate in color code.

    :param forwarding_events:
    """
    times = []
    amounts = []
    color = []
    for f in forwarding_events:
        times.append(datetime.datetime.fromtimestamp(f['timestamp']))
        amounts.append(f['fee_msat'])
        color.append(f['effective_fee'])
    plt.xticks(rotation=45)
    plt.scatter(times, amounts, c=color, norm=colors.LogNorm(vmin=1E-6, vmax=1E-3), s=2)
    plt.yscale('log')
    plt.ylabel('Fees [msat]')
    plt.ylim((0.5, 1E+6))
    plt.colorbar(label='effective feerate (base + rate)')
    plt.show() 
开发者ID:bitromortac,项目名称:lndmanage,代码行数:22,代码来源:example_fwding_summary.py

示例12: __init__

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import LogNorm [as 别名]
def __init__(self, fig, gs, pupil_grid, maxdim,
                 yaxis_ticks_position='left', **kwargs):
        self.fig = fig
        self.fig.subplots.append(self)

        self.gs = gs
        self.pupil_grid = pupil_grid
        self.maxdim = maxdim

        if 'title' in kwargs:
            self.title = kwargs.pop('title', None)
        kwargs['cmap'] = kwargs.get('cmap', "RdBu_r")

        if 'norm' in kwargs:
            self.norm = kwargs.pop('norm', None)
        else:
            vmin = kwargs.get('vmin') if 'vmin' in kwargs else None
            vmax = kwargs.get('vmax') if 'vmax' in kwargs else None
            self.norm = LogNorm(vmin=vmin, vmax=vmax)

        self.plot_kwargs = kwargs
        self.yaxis_ticks_position = yaxis_ticks_position

        self.update_data() 
开发者ID:mjhoptics,项目名称:ray-optics,代码行数:26,代码来源:analysisfigure.py

示例13: init_fig

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import LogNorm [as 别名]
def init_fig(*args, **kwargs):
            '''Initialize figures.'''
            fig = tfmpl.create_figure(figsize=(8,6))
            ax = fig.add_subplot(111, projection='3d', elev=50, azim=-30)
            ax.w_xaxis.set_pane_color((1.0,1.0,1.0,1.0))
            ax.w_yaxis.set_pane_color((1.0,1.0,1.0,1.0))
            ax.w_zaxis.set_pane_color((1.0,1.0,1.0,1.0))
            ax.set_title('Gradient descent on Beale surface')
            ax.set_xlabel('$x$')
            ax.set_ylabel('$y$')
            ax.set_zlabel('beale($x$,$y$)')
        
            xx, yy = np.meshgrid(np.linspace(-4.5, 4.5, 40), np.linspace(-4.5, 4.5, 40))
            zz = beale(xx, yy)
            ax.plot_surface(xx, yy, zz, norm=LogNorm(), rstride=1, cstride=1, edgecolor='none', alpha=.8, cmap=cm.jet)
            ax.plot([3], [.5], [beale(3, .5)], 'k*', markersize=5)
            
            for o in optimizers:
                path, = ax.plot([],[],[], label=o[1])
                paths.append(path)

            ax.legend(loc='upper left')
            fig.tight_layout()

            return fig, paths 
开发者ID:cheind,项目名称:tf-matplotlib,代码行数:27,代码来源:sgd.py

示例14: make_amplitude_cmap

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import LogNorm [as 别名]
def make_amplitude_cmap(
    mapname="gray", vmin=1, vmax=1e5, ncolors=64, outname="amplitude-cog.cpt"
):
    """Write default colormap (amplitude-cog.cpt) for isce amplitude images.

    Uses a LogNorm colormap by default since amplitude return values typically
    span several orders of magnitude.

    Parameters
    ----------
    mapname : str
        matplotlib colormap name
    vmin : float
        data value mapped to lower end of colormap
    vmax : float
        data value mapped to upper end of colormap
    ncolors : int
        number of discrete mapped values between vmin and vmax

    """
    cmap = plt.get_cmap(mapname)
    # NOTE for strong contrast amp return:
    # cNorm = colors.Normalize(vmin=1e3, vmax=1e4)
    cNorm = colors.LogNorm(vmin=vmin, vmax=vmax)
    scalarMap = cmx.ScalarMappable(norm=cNorm, cmap=cmap)
    vals = np.linspace(vmin, vmax, ncolors, endpoint=True)
    write_cmap(outname, vals, scalarMap)

    return outname 
开发者ID:scottyhq,项目名称:dinosar,代码行数:31,代码来源:__init__.py

示例15: validation

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import LogNorm [as 别名]
def validation():
    orig = np.load("%s/val_label.npz" %DATA_DIR)['arr_0']
    cannon = np.load("%s/val_cannon_labels.npz" %DATA_DIR)['arr_0']
    snr = np.load("%s/val_SNR.npz" %DATA_DIR)['arr_0']
    choose = snr > 50

    labels = ["$\mathrm{T}_{\mathrm{eff}}$ (K)", "$\log g$ (dex)", "[M/H]", "[a/Fe]"]
    mins = [4000, 0.5, -2.5, -0.1]
    maxs = [5500, 3.5, 0.0, 0.5]

    fig,axarr = plt.subplots(4,1, figsize=(4,10))#, sharey=True)
    props = dict(boxstyle='round', facecolor='white')

    for i in range(0,4):
        diff = cannon[:,i][choose] - orig[:,i][choose]
        bias = np.mean(diff)
        scat = np.std(diff)
        text1 = "Bias: %s\nRMS Scatter: %s" %(str(round_sig(bias)), str(round_sig(scat)))
        axarr[i].hist2d(
                orig[:,i][choose], cannon[:,i][choose], bins=20,
                range=[[mins[i], maxs[i]], [mins[i], maxs[i]]],
                cmap = "gray_r", norm=LogNorm())
        axarr[i].text(
                0.05, 0.95, text1, horizontalalignment='left',
                verticalalignment='top', transform=axarr[i].transAxes, bbox=props)
        axarr[i].plot(
                [mins[i],maxs[i]],[mins[i],maxs[i]], c='k', 
                linestyle='--', label="x=y")
        axarr[i].set_xlabel(labels[i]+" from Orig. Pipeline", fontsize=16)
        axarr[i].set_ylabel(labels[i]+" from Cannon", fontsize=16)
        axarr[i].set_xlim(mins[i], maxs[i])
        axarr[i].set_ylim(mins[i], maxs[i])
        #axarr[i].legend()
        #axarr[i].set_colorbar()
    fig.tight_layout()
    #plt.show()
    plt.savefig("1to1_validation.png") 
开发者ID:annayqho,项目名称:TheCannon,代码行数:39,代码来源:validation_plots.py


注:本文中的matplotlib.colors.LogNorm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。