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


Python Plot.show方法代码示例

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


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

示例1: main

# 需要导入模块: from sympy import Plot [as 别名]
# 或者: from sympy.Plot import show [as 别名]
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,代码行数:48,代码来源:autowrap_ufuncify.py

示例2: plot_beam

# 需要导入模块: from sympy import Plot [as 别名]
# 或者: from sympy.Plot import show [as 别名]
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,代码行数:46,代码来源:gaussopt.py


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