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

Python sympy.Plot类代码示例

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

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



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

示例1: main

def main():

    print(__doc__)

    x = symbols('x')

    # a numpy array we can apply the ufuncs to
    grid = np.linspace(-1, 1, 1000)

    # set mpmath precision to 20 significant numbers for verification
    mpmath.mp.dps = 20

    print("Compiling legendre ufuncs and checking results:")

    # Let's also plot the ufunc's we generate
    plot1 = Plot(visible=False)
    for n in range(6):

        # Setup the SymPy expression to ufuncify
        expr = legendre(n, x)
        print("The polynomial of degree %i is" % n)
        pprint(expr)

        # This is where the magic happens:
        binary_poly = ufuncify(x, expr)

        # It's now ready for use with numpy arrays
        polyvector = binary_poly(grid)

        # let's check the values against mpmath's legendre function
        maxdiff = 0
        for j in range(len(grid)):
            precise_val = mpmath.legendre(n, grid[j])
            diff = abs(polyvector[j] - precise_val)
            if diff > maxdiff:
                maxdiff = diff
        print("The largest error in applied ufunc was %e" % maxdiff)
        assert maxdiff < 1e-14

        # We can also attach the autowrapped legendre polynomial to a sympy
        # function and plot values as they are calculated by the binary function
        g = implemented_function('g', binary_poly)
        plot1[n] = g(x), [200]

    print("Here's a plot with values calculated by the wrapped binary functions")
    plot1.show()
开发者ID:ChaliZhg,项目名称:sympy,代码行数:46,代码来源:autowrap_ufuncify.py


示例2: plot_beam

def plot_beam(beam, **kwargs):
    """Plot the beam radius as it propagates in space.
    Uses pyglet and ctype libraries

    Parameters
    ==========
    
    beam : BeamParameter for gaussian beam
    z_range : plot range for the beam propagation coordinate

    See Also
    ========    
    
    BeamParameter
    plot_beam2
    
    Examples
    ========
    
    >>> from sympy.physics.gaussopt import BeamParameter, plot_beam
    >>> b = BeamParameter(530e-9, 1, w=1e-5)
    >>> plot_beam(b,z_range=2*b.z_r)    
    """
    
    if len(kwargs) != 1:
        raise ValueError("The function expects only one named argument")    
    elif 'z_range' in kwargs :
        z_range = sympify(kwargs['z_range'])
    else :
        raise ValueError(filldedent('''
            The functions expects the z_range as a named argument'''))

    x = symbols('x')
    # TODO beam.w_0 * 
    # pyglet needs to have better zoom adjustment for geting a normal view
    weist_d = sqrt(1+(x/beam.z_r)**2)
    
    p = Plot(visible=False)
    
    p[1] = weist_d, 'color=black', [x, -z_range, z_range, int(beam.w_0**-1)]
    p[2] = -weist_d, 'color=black', [x, -z_range, z_range, int(beam.w_0**-1)]
    
    p.adjust_all_bounds()
    p.show()
开发者ID:Enchanter12,项目名称:sympy,代码行数:44,代码来源:gaussopt.py


示例3: _test_plot_log

 def _test_plot_log(self):
     from sympy import Plot
     p=Plot(log(x), [x,0,6.282,4], 'mode=polar', visible=False)
     p.wait_for_calculations()
开发者ID:certik,项目名称:sympy-oldcore,代码行数:4,代码来源:test_plotting.py


示例4: test_plot_3d_parametric

 def test_plot_3d_parametric(self):
     from sympy import Plot
     p=Plot(sin(x), cos(x), x/5.0, [x, 0, 6.282, 4], visible=False)
     p.wait_for_calculations()
开发者ID:certik,项目名称:sympy-oldcore,代码行数:4,代码来源:test_plotting.py


示例5: test_plot_3d_spherical

 def test_plot_3d_spherical(self):
     from sympy import Plot
     p=Plot(1, [x,0,6.282,4], [y,0,3.141,4], 'mode=spherical;style=wireframe', visible=False)
     p.wait_for_calculations()
开发者ID:certik,项目名称:sympy-oldcore,代码行数:4,代码来源:test_plotting.py


示例6: test_plot_3d_cylinder

 def test_plot_3d_cylinder(self):
     from sympy import Plot
     p=Plot(1/y, [x,0,6.282,4], [y,-1,1,4], 'mode=polar;style=solid', visible=False)
     p.wait_for_calculations()
开发者ID:certik,项目名称:sympy-oldcore,代码行数:4,代码来源:test_plotting.py


示例7: test_plot_2d_polar

 def test_plot_2d_polar(self):
     from sympy import Plot
     p=Plot(1/x, [x,-1,1,4], 'mode=polar', visible=False)
     p.wait_for_calculations()
开发者ID:certik,项目名称:sympy-oldcore,代码行数:4,代码来源:test_plotting.py


示例8: test_plot_3d_discontinuous

 def test_plot_3d_discontinuous(self):
     from sympy import Plot
     p=Plot(1/x, [x, -3, 3, 6], [y, -1, 1, 1], visible=False)
     p.wait_for_calculations()
开发者ID:certik,项目名称:sympy-oldcore,代码行数:4,代码来源:test_plotting.py


示例9: test_plot_3d

 def test_plot_3d(self):
     from sympy import Plot
     p=Plot(x*y, [x, -5, 5, 5], [y, -5, 5, 5], visible=False)
     p.wait_for_calculations()
开发者ID:certik,项目名称:sympy-oldcore,代码行数:4,代码来源:test_plotting.py


示例10: test_plot_2d_discontinuous

def test_plot_2d_discontinuous():
    from sympy import Plot
    p=Plot(1/x, [x, -1, 1, 2], visible=False)
    p.wait_for_calculations()
开发者ID:KevinGoodsell,项目名称:sympy,代码行数:4,代码来源:test_plotting.py


示例11: test_plot_2d

def test_plot_2d():
    from sympy import Plot
    p=Plot(x, [x, -5, 5, 4], visible=False)
    p.wait_for_calculations()
开发者ID:KevinGoodsell,项目名称:sympy,代码行数:4,代码来源:test_plotting.py


示例12: test_plot_integral

def test_plot_integral():
    # Make sure it doesn't treat x as an independent variable
    from sympy import Plot, Integral
    p = Plot(Integral(z*x, (x, 1, z), (z, 1, y)), visible=False)
    p.wait_for_calculations()
开发者ID:101man,项目名称:sympy,代码行数:5,代码来源:test_plotting.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python sympy.Poly类代码示例发布时间:2022-05-27
下一篇:
Python sympy.Piecewise类代码示例发布时间: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