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

Python plot.minmax_data函数代码示例

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

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



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

示例1: get_minmax_data

    def get_minmax_data(self):
        """
        Returns a dictionary with the bounding box data.

        The bounding box is computed to be as minimal as possible.
    
        EXAMPLES:

        An example without an angle::

            sage: p = ellipse((-2, 3), 1, 2)
            sage: d = p.get_minmax_data()
            sage: d['xmin']
            -3.0
            sage: d['xmax']
            -1.0
            sage: d['ymin']
            1.0
            sage: d['ymax']
            5.0

        The same example with a rotation of angle `\pi/2`::

            sage: p = ellipse((-2, 3), 1, 2, pi/2)
            sage: d = p.get_minmax_data()
            sage: d['xmin']
            -4.0
            sage: d['xmax']
            0.0
            sage: d['ymin']
            2.0
            sage: d['ymax']
            4.0
        """
        from sage.plot.plot import minmax_data

        epsilon = 0.000001
        cos_angle = cos(self.angle)

        if abs(cos_angle) > 1-epsilon:
            xmax = self.r1
            ymax = self.r2
        elif abs(cos_angle) < epsilon:
            xmax = self.r2
            ymax = self.r1
        else:
            sin_angle = sin(self.angle)
            tan_angle = sin_angle / cos_angle
            sxmax = ((self.r2*tan_angle)/self.r1)**2
            symax = (self.r2/(self.r1*tan_angle))**2
            xmax = (
                abs(self.r1 * cos_angle / sqrt(sxmax+1.)) +
                abs(self.r2 * sin_angle / sqrt(1./sxmax+1.)))
            ymax = (
                abs(self.r1 * sin_angle / sqrt(symax+1.)) +
                abs(self.r2 * cos_angle / sqrt(1./symax+1.)))
            
        return minmax_data([self.x - xmax, self.x + xmax],
                           [self.y - ymax, self.y + ymax],
                           dict=True)
开发者ID:dagss,项目名称:sage,代码行数:60,代码来源:ellipse.py


示例2: get_minmax_data

    def get_minmax_data(self):
        """
        Returns a dictionary with the bounding box data.

        EXAMPLES::

            sage: d = polygon([[1,2], [5,6], [5,0]], rgbcolor=(1,0,1))[0].get_minmax_data()
            sage: d['ymin']
            0.0
            sage: d['xmin']
            1.0

        ::

            sage: d = point((3, 3), rgbcolor=hue(0.75))[0].get_minmax_data()
            sage: d['xmin']
            3.0
            sage: d['ymin']
            3.0

        ::

            sage: l = line([(100, 100), (120, 120)])[0]
            sage: d = l.get_minmax_data()
            sage: d['xmin']
            100.0
            sage: d['xmax']
            120.0

        """
        from sage.plot.plot import minmax_data
        return minmax_data(self.xdata, self.ydata, dict=True)
开发者ID:chos9,项目名称:sage,代码行数:32,代码来源:primitive.py


示例3: get_minmax_data

    def get_minmax_data(self):
        """
        Returns a dictionary with the bounding box data.
        
        EXAMPLES::

            sage: b = bar_chart([-2.3,5,-6,12])
            sage: d = b.get_minmax_data()
            sage: d['xmin']
            0
            sage: d['xmax']
            4
        """
        return minmax_data([0, len(self.datalist)], self.datalist, dict=True)
开发者ID:bgxcpku,项目名称:sagelib,代码行数:14,代码来源:bar_chart.py


示例4: get_minmax_data

    def get_minmax_data(self):
        """
        Returns a dictionary with the bounding box data.
                
        EXAMPLES::

            sage: x,y = var('x,y')
            sage: d = plot_vector_field((.01*x,x+y), (x,10,20), (y,10,20))[0].get_minmax_data()
            sage: d['xmin']
            10.0
            sage: d['ymin']
            10.0
        """
        from sage.plot.plot import minmax_data
        return minmax_data(self.xpos_array, self.ypos_array, dict=True)
开发者ID:jwbober,项目名称:sagelib,代码行数:15,代码来源:plot_field.py


示例5: get_minmax_data

    def get_minmax_data(self):
        """
        Returns a dictionary with the bounding box data.

        EXAMPLES::

            sage: x,y = var('x,y')
            sage: f(x, y) = x^2 + y^2
            sage: d = density_plot(f, (3, 6), (3, 6))[0].get_minmax_data()
            sage: d['xmin']
            3.0
            sage: d['ymin']
            3.0
        """
        from sage.plot.plot import minmax_data
        return minmax_data(self.xrange, self.yrange, dict=True)
开发者ID:ProgVal,项目名称:sage,代码行数:16,代码来源:density_plot.py


示例6: get_minmax_data

    def get_minmax_data(self):
        """
        Returns a dictionary with the bounding box data. Notice
        that, for text, the box is just the location itself.

        EXAMPLES::

            sage: T = text("Where am I?",(1,1))
            sage: t=T[0]
            sage: t.get_minmax_data()['ymin']
            1.0
            sage: t.get_minmax_data()['ymax']
            1.0
        """
        from sage.plot.plot import minmax_data
        return minmax_data([self.x], [self.y], dict=True)
开发者ID:drupel,项目名称:sage,代码行数:16,代码来源:text.py


示例7: get_minmax_data

    def get_minmax_data(self):
        """
        Get minimum and maximum horizontal and vertical ranges
        for the Histogram object.

        EXAMPLES::

            sage: H = histogram([10,3,5], normed=True); h = H[0]
            sage: h.get_minmax_data()
            {'xmax': 10.0, 'xmin': 3.0, 'ymax': 0.4761904761904765, 'ymin': 0}
            sage: G = histogram([random() for _ in range(500)]); g = G[0]
            sage: g.get_minmax_data() # random output
            {'xmax': 0.99729312925213209, 'xmin': 0.00013024562219410285, 'ymax': 61, 'ymin': 0}
            sage: Y = histogram([random()*10 for _ in range(500)], range=[2,8]); y = Y[0]
            sage: ymm = y.get_minmax_data(); ymm['xmax'], ymm['xmin']
            (8.0, 2.0)
            sage: Z = histogram([[1,3,2,0], [4,4,3,3]]); z = Z[0]
            sage: z.get_minmax_data()
            {'xmax': 4.0, 'xmin': 0, 'ymax': 2, 'ymin': 0}
        """
        import numpy
        options=self.options()
        opt=dict(range = options.pop('range',None),
                 bins = options.pop('bins',None),
                 normed = options.pop('normed',None),
                 weights = options.pop('weights', None))
 
        #check to see if a list of datasets
        if not hasattr(self.datalist[0],'__contains__' ):
            ydata,xdata=numpy.histogram(self.datalist, **opt)
            return minmax_data(xdata,[0]+list(ydata), dict=True)
        else:
            m = { 'xmax': 0, 'xmin':0, 'ymax':0, 'ymin':0}
            if not options.pop('stacked',None):
                for d in self.datalist:
                    ydata, xdata = numpy.histogram(d,**opt)
                    m['xmax'] = max([m['xmax']] + list(xdata))
                    m['xmin'] = min([m['xmin']] + list(xdata))
                    m['ymax'] = max([m['ymax']] + list(ydata))
                return m
            else:
                for d in self.datalist:
                    ydata, xdata = numpy.histogram(d,**opt)
                    m['xmax'] = max([m['xmax']] + list(xdata))
                    m['xmin'] = min([m['xmin']] + list(xdata))
                    m['ymax'] = m['ymax'] + max(list(ydata))
                return m
开发者ID:robertwb,项目名称:sage,代码行数:47,代码来源:histogram.py


示例8: get_minmax_data

    def get_minmax_data(self):
        """
        Returns a dictionary with the bounding box data.
        
        EXAMPLES::

            sage: p = circle((3, 3), 1)
            sage: d = p.get_minmax_data()
            sage: d['xmin']
            2.0
            sage: d['ymin']
            2.0
        """
        from sage.plot.plot import minmax_data
        return minmax_data([self.x - self.r, self.x + self.r],
                           [self.y - self.r, self.y + self.r],
                           dict=True)
开发者ID:bgxcpku,项目名称:sagelib,代码行数:17,代码来源:circle.py


示例9: get_minmax_data

    def get_minmax_data(self):
        """
        Returns a dictionary with the bounding box data.

        EXAMPLES::

            sage: D = disk((5,4), 1, (pi/2, pi))
            sage: d = D.get_minmax_data()
            sage: d['xmin']
            4.0
            sage: d['ymin']
            3.0
            sage: d['xmax']
            6.0
            sage: d['ymax']
            5.0

        """
        from sage.plot.plot import minmax_data

        return minmax_data([self.x - self.r, self.x + self.r], [self.y - self.r, self.y + self.r], dict=True)
开发者ID:saraedum,项目名称:sage,代码行数:21,代码来源:disk.py


示例10: get_minmax_data

    def get_minmax_data(self):
        """
        Returns a dictionary with the bounding box data.

        EXAMPLES::

            sage: m = matrix_plot(matrix([[1,3,5,1],[2,4,5,6],[1,3,5,7]]))[0]
            sage: list(sorted(m.get_minmax_data().items()))
            [('xmax', 3.5), ('xmin', -0.5), ('ymax', -0.5), ('ymin', 2.5)]

        """
        from sage.plot.plot import minmax_data
        limits= minmax_data(self.xrange, self.yrange, dict=True)
        if self.options()['origin']!='lower':
            # flip y-axis so that the picture looks correct.
            limits['ymin'],limits['ymax']=limits['ymax'],limits['ymin']

        # center the matrix so that, for example, the square representing the
        # (0,0) entry is centered on the origin.
        for k,v in limits.iteritems():
            limits[k]-=0.5
        return limits
开发者ID:sageb0t,项目名称:testsage,代码行数:22,代码来源:matrix_plot.py


示例11: get_minmax_data

    def get_minmax_data(self):
        """
        Returns a dictionary with the bounding box data.

        The bounding box is computed as minimal as possible.

        EXAMPLES:

        An example without angle::

            sage: p = arc((-2, 3), 1, 2)
            sage: d = p.get_minmax_data()
            sage: d['xmin']
            -3.0
            sage: d['xmax']
            -1.0
            sage: d['ymin']
            1.0
            sage: d['ymax']
            5.0

        The same example with a rotation of angle `\pi/2`::

            sage: p = arc((-2, 3), 1, 2, pi/2)
            sage: d = p.get_minmax_data()
            sage: d['xmin']
            -4.0
            sage: d['xmax']
            0.0
            sage: d['ymin']
            2.0
            sage: d['ymax']
            4.0
        """
        from sage.plot.plot import minmax_data

        twopi = 2*pi

        s1 = self.s1
        s2 = self.s2
        s = s2-s1
        s1 = fmod(s1,twopi)
        if s1 < 0: s1 += twopi
        s2 = fmod(s1 + s,twopi)
        if s2 < 0: s2 += twopi

        r1 = self.r1
        r2 = self.r2

        angle = fmod(self.angle,twopi)
        if angle < 0: angle += twopi

        epsilon = float(0.0000001)

        cos_angle = cos(angle)
        sin_angle = sin(angle)

        if cos_angle > 1-epsilon:
            xmin=-r1; ymin=-r2
            xmax=r1; ymax=r2
            axmin = pi; axmax = 0
            aymin = 3*pi/2; aymax = pi/2

        elif cos_angle < -1+epsilon:
            xmin=-r1; ymin=-r2
            xmax=r1; ymax=r2
            axmin=0; axmax=pi
            aymin=pi/2; aymax=3*pi/2

        elif sin_angle > 1-epsilon:
            xmin=-r2; ymin=-r1
            xmax=r2; ymax=r1
            axmin = pi/2; axmax = 3*pi/2
            aymin = pi; aymax = 0

        elif sin_angle < -1+epsilon:
            xmin=-r2; ymin=-r1
            xmax=r2; ymax=r1
            axmin = 3*pi/2; axmax = pi/2
            aymin = 0; aymax = pi

        else:
            tan_angle = sin_angle / cos_angle
            axmax = atan(-r2/r1*tan_angle)
            if axmax < 0: axmax += twopi
            xmax = (
              r1 * cos_angle * cos(axmax) -
              r2 * sin_angle * sin(axmax))
            if xmax < 0:
                xmax = -xmax
                axmax = fmod(axmax+pi,twopi)
            xmin = -xmax
            axmin = fmod(axmax + pi,twopi)

            aymax = atan(r2/(r1*tan_angle))
            if aymax < 0: aymax += twopi
            ymax = (
              r1 * sin_angle * cos(aymax) +
              r2 * cos_angle * sin(aymax))
            if ymax < 0:
#.........这里部分代码省略.........
开发者ID:BlairArchibald,项目名称:sage,代码行数:101,代码来源:arc.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python primitive.GraphicPrimitive类代码示例发布时间:2022-05-27
下一篇:
Python misc.setup_for_eval_on_grid函数代码示例发布时间: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