• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python transforms.nonsingular函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中matplotlib.transforms.nonsingular函数的典型用法代码示例。如果您正苦于以下问题:Python nonsingular函数的具体用法?Python nonsingular怎么用?Python nonsingular使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_nonsingular

def test_nonsingular():
    # test for zero-expansion type cases; other cases may be added later
    zero_expansion = np.array([-0.001, 0.001])
    cases = [(0, np.nan), (0, 0), (0, 7.9e-317)]
    for args in cases:
        out = np.array(mtrans.nonsingular(*args))
        assert_array_equal(out, zero_expansion)
开发者ID:Allen-smith,项目名称:ctf-tools,代码行数:7,代码来源:test_transforms.py


示例2: view_limits

    def view_limits(self, vmin, vmax):
        'Try to choose the view limits intelligently'
        b = self._transform.base
        if vmax<vmin:
            vmin, vmax = vmax, vmin

        if not is_decade(abs(vmin), b):
            if vmin < 0:
                vmin = -decade_up(-vmin, b)
            else:
                vmin = decade_down(vmin, b)
        if not is_decade(abs(vmax), b):
            if vmax < 0:
                vmax = -decade_down(-vmax, b)
            else:
                vmax = decade_up(vmax, b)

        if vmin == vmax:
            if vmin < 0:
                vmin = -decade_up(-vmin, b)
                vmax = -decade_down(-vmax, b)
            else:
                vmin = decade_down(vmin, b)
                vmax = decade_up(vmax, b)
        result = mtransforms.nonsingular(vmin, vmax)
        return result
开发者ID:nlhepler,项目名称:matplotlib,代码行数:26,代码来源:ticker.py


示例3: __call__

    def __call__(self, x, pos=None):
        'Return the format for tick val *x* at position *pos*'


        vmin, vmax = self.axis.get_view_interval()
        vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander = 0.05)
        d = abs(vmax-vmin)
        b=self._base
        if x == 0:
            return '0'
        sign = np.sign(x)
        # only label the decades
        fx = math.log(abs(x))/math.log(b)
        isDecade = is_close_to_int(fx)
        if not isDecade and self.labelOnlyBase: s = ''
        #if 0: pass
        elif fx>10000: s= '%1.0e'%fx
        #elif x<1: s = '$10^{%d}$'%fx
        #elif x<1: s =  '10^%d'%fx
        elif fx<1: s =  '%1.0e'%fx
        else        : s =  self.pprint_val(fx,d)
        if sign == -1:
            s =  '-%s' % s

        return self.fix_minus(s)
开发者ID:nlhepler,项目名称:matplotlib,代码行数:25,代码来源:ticker.py


示例4: view_limits

    def view_limits(self, vmin, vmax):
        """
        Try to choose the view limits intelligently. In contrast to the stock
        LogLocator, this version always pads by one decade so that the contents
        of the largest and smallest histogram bins can be seen even if they
        fall on a decade.
        """
        b = self._base

        if vmax < vmin:
            vmin, vmax = vmax, vmin

        if self.axis.axes.name == 'polar':
            vmax = math.ceil(math.log(vmax) / math.log(b))
            vmin = b ** (vmax - self.numdecs)
            return vmin, vmax

        minpos = self.axis.get_minpos()

        if minpos <= 0 or not np.isfinite(minpos):
            raise ValueError(
                "Data has no positive values, and therefore can not be "
                "log-scaled.")

        if vmin <= minpos:
            vmin = minpos
        
        vmin = mticker.decade_down(vmin*(1-1e-10), self._base)
        vmax = mticker.decade_up(vmax*(1+1e-10), self._base)

        if vmin == vmax:
            vmin = mticker.decade_down(vmin, self._base)
            vmax = mticker.decade_up(vmax, self._base)
        result = mtransforms.nonsingular(vmin, vmax)
        return result
开发者ID:IceCube-SPNO,项目名称:dashi,代码行数:35,代码来源:ticks.py


示例5: get_view_interval

 def get_view_interval(self):
     vmin, vmax = self.axis.get_view_interval()
     if self.epoch:
         vmin -= float(self.epoch.gps)
         vmax -= float(self.epoch.gps)
     if self._scale:
         vmin /= self._scale
         vmax /= self._scale
     return mtransforms.nonsingular(vmin, vmax, expander = 0.05)
开发者ID:mcoughlin,项目名称:gwpy,代码行数:9,代码来源:ticks.py


示例6: __call__

    def __call__(self):
        vmin, vmax = self.axis.get_view_interval()
        vmin, vmax = nonsingular(vmin, vmax, expander = 0.05)
        vmin = vmin ** self.exponent
        vmax = vmax ** self.exponent
        if vmax<vmin:
            vmin, vmax = vmax, vmin

        ticklocs = np.linspace(vmin, vmax, num=self.numticks, endpoint=True)
        return self.raise_if_exceeds(ticklocs ** (1.0 / self.exponent))
开发者ID:glciampaglia,项目名称:editor-lifecycle,代码行数:10,代码来源:scale.py


示例7: tick_values

    def tick_values(self, vmin, vmax):
        vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander=1e-7,
                                             tiny=1e-13)

        self.ndays = float(abs(vmax - vmin))

        utime = cftime.utime(self.date_unit, self.calendar)
        lower = utime.num2date(vmin)
        upper = utime.num2date(vmax)

        resolution, n = self.compute_resolution(vmin, vmax, lower, upper)

        if resolution == 'YEARLY':
            # TODO START AT THE BEGINNING OF A DECADE/CENTURY/MILLENIUM as
            # appropriate.
            years = self._max_n_locator.tick_values(lower.year, upper.year)
            ticks = [cftime.datetime(int(year), 1, 1) for year in years]
        elif resolution == 'MONTHLY':
            # TODO START AT THE BEGINNING OF A DECADE/CENTURY/MILLENIUM as
            # appropriate.
            months_offset = self._max_n_locator.tick_values(0, n)
            ticks = []
            for offset in months_offset:
                year = lower.year + np.floor((lower.month + offset) / 12)
                month = ((lower.month + offset) % 12) + 1
                ticks.append(cftime.datetime(int(year), int(month), 1))
        elif resolution == 'DAILY':
            # TODO: It would be great if this favoured multiples of 7.
            days = self._max_n_locator_days.tick_values(vmin, vmax)
            ticks = [utime.num2date(dt) for dt in days]
        elif resolution == 'HOURLY':
            hour_unit = 'hours since 2000-01-01'
            hour_utime = cftime.utime(hour_unit, self.calendar)
            in_hours = hour_utime.date2num([lower, upper])
            hours = self._max_n_locator.tick_values(in_hours[0], in_hours[1])
            ticks = [hour_utime.num2date(dt) for dt in hours]
        elif resolution == 'MINUTELY':
            minute_unit = 'minutes since 2000-01-01'
            minute_utime = cftime.utime(minute_unit, self.calendar)
            in_minutes = minute_utime.date2num([lower, upper])
            minutes = self._max_n_locator.tick_values(in_minutes[0],
                                                      in_minutes[1])
            ticks = [minute_utime.num2date(dt) for dt in minutes]
        elif resolution == 'SECONDLY':
            second_unit = 'seconds since 2000-01-01'
            second_utime = cftime.utime(second_unit, self.calendar)
            in_seconds = second_utime.date2num([lower, upper])
            seconds = self._max_n_locator.tick_values(in_seconds[0],
                                                      in_seconds[1])
            ticks = [second_utime.num2date(dt) for dt in seconds]
        else:
            msg = 'Resolution {} not implemented yet.'.format(resolution)
            raise ValueError(msg)

        return utime.date2num(ticks)
开发者ID:SciTools,项目名称:nc-time-axis,代码行数:55,代码来源:__init__.py


示例8: view_limits

    def view_limits(self, dmin, dmax):
        """
        Set the view limits to the nearest multiples of base that
        contain the data
        """
        vmin = self._base.le(math.copysign(math.sqrt(abs(dmin)), dmin))
        vmax = self._base.ge(math.sqrt(dmax))
        if vmin == vmax:
            vmin -= 1
            vmax += 1

        return mtransforms.nonsingular(math.copysign(vmin**2, vmin), vmax**2)
开发者ID:dkriegner,项目名称:xrayutilities,代码行数:12,代码来源:mpl_helper.py


示例9: autoscale

    def autoscale(self):
        """
    Sets the view limits to the nearest multiples of base that contain the data.
        """
        # requires matplotlib >= 0.98.0
        (vmin, vmax) = self.axis.get_data_interval()

        locs = self._get_default_locs(vmin, vmax)
        (vmin, vmax) = locs[[0, -1]]
        if vmin == vmax:
            vmin -= 1
            vmax += 1
        return nonsingular(vmin, vmax)
开发者ID:pierregm,项目名称:scikits.timeseries,代码行数:13,代码来源:plotlib.py


示例10: tick_values

 def tick_values(self, vmin, vmax):
     """Return the ticks for this axis
     """
     vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander=1e-13,
                                                      tiny=1e-14)
     locs = self.bin_boundaries(vmin, vmax)
     prune = self._prune
     if prune == 'lower':
         locs = locs[1:]
     elif prune == 'upper':
         locs = locs[:-1]
     elif prune == 'both':
         locs = locs[1:-1]
     return self.raise_if_exceeds(locs)
开发者ID:mcoughlin,项目名称:gwpy,代码行数:14,代码来源:ticks.py


示例11: plot

    def plot(self, experiment, **kwargs):
        """Plot a faceted histogram view of a channel"""
        
        #kwargs.setdefault('histtype', 'stepfilled')
        #kwargs.setdefault('alpha', 0.5)
        kwargs.setdefault('edgecolor', 'none')
        #kwargs.setdefault('mincnt', 1)
        #kwargs.setdefault('bins', 'log')
        kwargs.setdefault('antialiased', True)
        
        if not self.subset:
            x = experiment.data
        else:
            x = experiment.query(self.subset)
            
        xmin, xmax = (np.amin(x[self.xchannel]), np.amax(x[self.xchannel]))
        ymin, ymax = (np.amin(x[self.ychannel]), np.amax(x[self.ychannel]))
        # to avoid issues with singular data, expand the min/max pairs
        xmin, xmax = mtrans.nonsingular(xmin, xmax, expander=0.1)
        ymin, ymax = mtrans.nonsingular(ymin, ymax, expander=0.1)
        
        extent = (xmin, xmax, ymin, ymax)
        kwargs.setdefault('extent', extent)
        
        xbins = num_hist_bins(experiment[self.xchannel])
        ybins = num_hist_bins(experiment[self.ychannel])
        bins = np.mean([xbins, ybins])
        
        kwargs.setdefault('bins', bins) # Do not move above.  don't ask.

        g = sns.FacetGrid(x, 
                          col = (self.xfacet if self.xfacet else None),
                          row = (self.yfacet if self.yfacet else None),
                          hue = (self.huefacet if self.huefacet else None))
        
        g.map(plt.hexbin, self.xchannel, self.ychannel, **kwargs)
开发者ID:Weiss-Lab,项目名称:cytoflow,代码行数:36,代码来源:hexbin.py


示例12: view_limits

    def view_limits(self, vmin, vmax):
        'Try to choose the view limits intelligently'
        b = self._base
        
        if vmax < vmin:
            vmin, vmax = vmax, vmin

        if self.axis.axes.name == 'polar':
            vmax = math.ceil(math.log(vmax - self.zero) / math.log(b))
            vmin = b ** (vmax - self.numdecs)
            return vmin, vmax

        minpos = self.axis.get_minpos()

        if (self.sign > 0.0) :
            if vmax <= self.zero or not np.isfinite(minpos):
                raise ValueError(
                    "Data has no positive values, and therefore can not be "
                    "log-scaled.")
        else:
            if vmin >= self.zero or not np.isfinite(minpos):
                raise ValueError(
                    "Data has no positive values, and therefore can not be "
                    "log-scaled.")
            
        if not is_decade((vmin - self.zero) * self.sign, self._base):
            if self.sign > 0.0:
                vmin = decade_down((vmin - self.zero) * self.sign, self._base) + self.zero
            else:
                vmin = decade_up((vmin - self.zero) * self.sign, self._base) * self.sign + self.zero
        if not is_decade((vmax - self.zero) * self.sign, self._base):
            if self.sign > 0.0:
                vmax = decade_up((vmax - self.zero) * self.sign, self._base) + self.zero
            else:
                vmax = decade_down((vmax - self.zero) * self.sign, self._base) * self.sign + self.zero
        if vmin == vmax:
            if (self.sign > 0.0):
                vmin = decade_down((vmin - self.zero) * self.sign, self._base) + self.zero
                vmax = decade_up((vmax - self.zero) * self.sign, self._base) + self.zero
            else:
                vmin = decade_up((vmin - self.zero) * self.sign, self._base) * self.sign + self.zero
                vmax = decade_down((vmax - self.zero) * self.sign, self._base) * self.sign + self.zero
            
        result = mtransforms.nonsingular(vmin, vmax)
        return result
开发者ID:brownjustinmichael,项目名称:KEPLER-Utilities,代码行数:45,代码来源:shiftlog.py


示例13: autoscale

    def autoscale(self):
        'Try to choose the view limits intelligently'
        self.verify_intervals()

        vmin, vmax = self.dataInterval.get_bounds()
        if vmax<vmin:
            vmin, vmax = vmax, vmin

        minpos = self.dataInterval.minpos()

        if minpos<=0:
            raise RuntimeError('No positive data to plot')
        if vmin<=0:
            vmin = minpos
        if not is_decade(vmin,self._base): vmin = decade_down(vmin,self._base)
        if not is_decade(vmax,self._base): vmax = decade_up(vmax,self._base)
        if vmin==vmax:
            vmin = decade_down(vmin,self._base)
            vmax = decade_up(vmax,self._base)
        return mtrans.nonsingular(vmin, vmax)
开发者ID:reflectometry,项目名称:osrefl,代码行数:20,代码来源:ticker.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python transforms.offset_copy函数代码示例发布时间:2022-05-27
下一篇:
Python transforms.interval_contains函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap