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

Python plotting.plot函数代码示例

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

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



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

示例1: plotgrid_and_save

def plotgrid_and_save(name):
    tmp_file = TmpFileManager.tmp_file

    x = Symbol('x')
    y = Symbol('y')
    z = Symbol('z')
    p1 = plot(x)
    p2 = plot_parametric((sin(x), cos(x)), (x, sin(x)), show=False)
    p3 = plot_parametric(cos(x), sin(x), adaptive=False, nb_of_points=500, show=False)
    p4 = plot3d_parametric_line(sin(x), cos(x), x, show=False)
    # symmetric grid
    p = PlotGrid(2, 2, p1, p2, p3, p4)
    p.save(tmp_file('%s_grid1' % name))
    p._backend.close()

    # grid size greater than the number of subplots
    p = PlotGrid(3, 4, p1, p2, p3, p4)
    p.save(tmp_file('%s_grid2' % name))
    p._backend.close()

    p5 = plot(cos(x),(x, -pi, pi), show=False)
    p5[0].line_color = lambda a: a
    p6 = plot(Piecewise((1, x > 0), (0, True)), (x, -1, 1), show=False)
    p7 = plot_contour((x**2 + y**2, (x, -5, 5), (y, -5, 5)), (x**3 + y**3, (x, -3, 3), (y, -3, 3)), show=False)
    # unsymmetric grid (subplots in one line)
    p = PlotGrid(1, 3, p5, p6, p7)
    p.save(tmp_file('%s_grid3' % name))
    p._backend.close()
开发者ID:bjodah,项目名称:sympy,代码行数:28,代码来源:test_plot.py


示例2: main

def main():
    '''
    legendre_polynomial.py : ルジャンドルの多項式
    '''
    x = symbols("x")
    psi = [1,x,x**2,x**3,x**100]
    phy = schmidt(psi)
    plot(phy[0],phy[1],phy[2],phy[3],phy[4],(x, -1.5, 1.5),ylim=(-1.5,1.5),ylabel='',xlabel='')
开发者ID:spre55,项目名称:grad_prog,代码行数:8,代码来源:gso_legendre_pol.py


示例3: solve_plot_equations

def solve_plot_equations(eq1, eq2, x, y):
    # Solve
    solution = solve((eq1, eq2), dict=True)
    if solution:
        print('x: {0} y: {1}'.format(solution[0][x], solution[0][y]))
    else:
        print('No solution found')
    # Plot
    eq1_y = solve(eq1,'y')[0]
    eq2_y = solve(eq2, 'y')[0]
    plot(eq1_y, eq2_y, legend=True)
开发者ID:KentFujii,项目名称:doing_math,代码行数:11,代码来源:graphic_eq_solve.py


示例4: plot

def plot():
    e = Symbol('e')
    y = Symbol('y')
    n = Symbol('n')
    generalized_vc_bounds = (original_vc_bound, rademacher_penalty_bound)
    growth_function_bound = generate_growth_function_bound(50)
    p1 = plot(original_vc_bound(n, 0.05, growth_function_bound), (n,100, 15000), show=False, line_color = 'black')
    p2 = plot(rademacher_penalty_bound(n, 0.05, growth_function_bound), (n,100, 15000), show=False, line_color = 'blue')
    plot_implicit(Eq(e, parrondo_van_den_broek_right(e, n, 0.05, growth_function_bound)), (n,100, 15000), (e,0,5))
    # plot_implicit(Eq(e, devroye(e, n, 0.05, growth_function_bound)), (n,100, 1000), (e,0,5))
    p1.extend(p2)
    p1.show()
开发者ID:zhiyanfoo,项目名称:caltech-machine-learning,代码行数:12,代码来源:hw4.py


示例5: test_issue_15265

def test_issue_15265():
    from sympy.core.sympify import sympify
    from sympy.core.singleton import S

    matplotlib = import_module('matplotlib', min_module_version='1.1.0', catch=(RuntimeError,))
    if not matplotlib:
        skip("Matplotlib not the default backend")

    x = Symbol('x')
    eqn = sin(x)

    p = plot(eqn, xlim=(-S.Pi, S.Pi), ylim=(-1, 1))
    p._backend.close()

    p = plot(eqn, xlim=(-1, 1), ylim=(-S.Pi, S.Pi))
    p._backend.close()

    p = plot(eqn, xlim=(-1, 1), ylim=(sympify('-3.14'), sympify('3.14')))
    p._backend.close()

    p = plot(eqn, xlim=(sympify('-3.14'), sympify('3.14')), ylim=(-1, 1))
    p._backend.close()

    raises(ValueError,
        lambda: plot(eqn, xlim=(-S.ImaginaryUnit, 1), ylim=(-1, 1)))

    raises(ValueError,
        lambda: plot(eqn, xlim=(-1, 1), ylim=(-1, S.ImaginaryUnit)))

    raises(ValueError,
        lambda: plot(eqn, xlim=(-S.Infinity, 1), ylim=(-1, 1)))

    raises(ValueError,
        lambda: plot(eqn, xlim=(-1, 1), ylim=(-1, S.Infinity)))
开发者ID:Lenqth,项目名称:sympy,代码行数:34,代码来源:test_plot.py


示例6: test_append_issue_7140

def test_append_issue_7140():
    x = Symbol('x')
    p1 = plot(x)
    p2 = plot(x**2)
    p3 = plot(x + 2)

    # append a series
    p2.append(p1[0])
    assert len(p2._series) == 2

    with raises(TypeError):
        p1.append(p2)

    with raises(TypeError):
        p1.append(p2._series)
开发者ID:abhi98khandelwal,项目名称:sympy,代码行数:15,代码来源:test_plot.py


示例7: plot_and_save_4

def plot_and_save_4(name):
    tmp_file = TmpFileManager.tmp_file

    x = Symbol('x')
    y = Symbol('y')
    z = Symbol('z')

    ###
    # Examples from the 'advanced' notebook
    ###

    # XXX: This raises the warning "The evaluation of the expression is
    # problematic. We are trying a failback method that may still work. Please
    # report this as a bug." It has to use the fallback because using evalf()
    # is the only way to evaluate the integral. We should perhaps just remove
    # that warning.

    with warnings.catch_warnings(record=True) as w:
        i = Integral(log((sin(x)**2 + 1)*sqrt(x**2 + 1)), (x, 0, y))
        p = plot(i, (y, 1, 5))
        p.save(tmp_file('%s_advanced_integral' % name))
        p._backend.close()
        # Make sure no other warnings were raised
        for i in w:
            assert issubclass(i.category, UserWarning)
            assert "The evaluation of the expression is problematic" in str(i.message)
开发者ID:Lenqth,项目名称:sympy,代码行数:26,代码来源:test_plot.py


示例8: plot_and_save_5

def plot_and_save_5(name):
    tmp_file = TmpFileManager.tmp_file

    x = Symbol('x')
    y = Symbol('y')
    z = Symbol('z')

    s = Sum(1/x**y, (x, 1, oo))
    p = plot(s, (y, 2, 10))
    p.save(tmp_file('%s_advanced_inf_sum' % name))
    p._backend.close()

    p = plot(Sum(1/x, (x, 1, y)), (y, 2, 10), show=False)
    p[0].only_integers = True
    p[0].steps = True
    p.save(tmp_file('%s_advanced_fin_sum' % name))
    p._backend.close()
开发者ID:Lenqth,项目名称:sympy,代码行数:17,代码来源:test_plot.py


示例9: main

def main():
    x = symbols("x")
    rho = (1 - x**2)**(-1/2)
    color = ["b","r","g","k","c","m","y"]

    T = rodrigues_formula(rho)
    p = []


    for i in range(7):
        t = simplify(T[i])
        print ("T(",i,") = ", t)
        if i > 0 :
            p.append( plot(T[i],(x,-1.1,1.1),ylim=(-1.1,1.1),show=False,line_color=color[i]) )
            p[0].extend(p[i])
        else:
            p.append( plot((T[i],(x,-1.1,1.1)),ylim=(-1.1,1.1),show=False,line_color=color[i]) )
    p[0].show()
开发者ID:spre55,项目名称:grad_prog,代码行数:18,代码来源:chebyshev.py


示例10: plot_all_Ant_fits

def plot_all_Ant_fits( AntEqtbl_split ):
    """
    plot_all_Ant_fits = plot_all_Ant_fits( AntEqtbl_split )

    EXAMPLES of USAGE:
    propane_dat = cleaned_Phase_data("propane")
    propane_plts = plot_all_Ant_fits( propane_dat.AntEqParams )
    """
    fits = []
    for row in AntEqtbl_split:
        fit = AntoineEqn.subs(dict(zip([A,B,C], [float(no) for no in row[2:5]])))
        fits.append( fit )
    to_plot = []
    for fit, row in zip(fits, AntEqtbl_split):
        range = (T, float(row[0]), float(row[1]))
        to_plot.append( (fit.rhs, range ) )
    plot( *to_plot )
    return to_plot
开发者ID:ernestyalumni,项目名称:Propulsion,代码行数:18,代码来源:LiquidVaporEq.py


示例11: test_append_issue_7140

def test_append_issue_7140():
    matplotlib = import_module('matplotlib', min_module_version='1.1.0', catch=(RuntimeError,))
    if not matplotlib:
        skip("Matplotlib not the default backend")

    x = Symbol('x')
    p1 = plot(x)
    p2 = plot(x**2)
    p3 = plot(x + 2)

    # append a series
    p2.append(p1[0])
    assert len(p2._series) == 2

    with raises(TypeError):
        p1.append(p2)

    with raises(TypeError):
        p1.append(p2._series)
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:19,代码来源:test_plot.py


示例12: plot_and_save_6

def plot_and_save_6(name):
    tmp_file = TmpFileManager.tmp_file

    x = Symbol('x')
    y = Symbol('y')
    z = Symbol('z')

    ###
    # Test expressions that can not be translated to np and generate complex
    # results.
    ###
    plot(sin(x) + I*cos(x)).save(tmp_file())
    plot(sqrt(sqrt(-x))).save(tmp_file())
    plot(LambertW(x)).save(tmp_file())
    plot(sqrt(LambertW(x))).save(tmp_file())

    #Characteristic function of a StudentT distribution with nu=10
    plot((meijerg(((1 / 2,), ()), ((5, 0, 1 / 2), ()), 5 * x**2 * exp_polar(-I*pi)/2)
            + meijerg(((1/2,), ()), ((5, 0, 1/2), ()),
                5*x**2 * exp_polar(I*pi)/2)) / (48 * pi), (x, 1e-6, 1e-2)).save(tmp_file())
开发者ID:Lenqth,项目名称:sympy,代码行数:20,代码来源:test_plot.py


示例13: main

def main():
    x = symbols("x")

    m = Rational(1,3) #1/3
    k = 2 #Rational(1,2)
    rho = (1 - (k**2) * (x**2) )**(-m)
    color = ["b","r","g","k","c","m","y"]

    T = rodrigues_formula(rho,m,k)
    p = []


    for i in range(7):
        t = simplify(T[i])
        print ("T(",i,") = ", t)
        if i > 0 :
            p.append( plot(T[i],(x,-0.52,0.52),ylim=(-1.1,1.1),show=False,line_color=color[i]) )
            p[0].extend(p[i])
        else:
            p.append( plot((T[i],(x,-0.52,0.52)),ylim=(-1.1,1.1),show=False,line_color=color[i]) )
    p[0].show()
开发者ID:spre55,项目名称:grad_prog,代码行数:21,代码来源:chebyshev_extend.py


示例14: plot_and_save_4

def plot_and_save_4(name):
    tmp_file = TmpFileManager.tmp_file

    x = Symbol('x')
    y = Symbol('y')
    z = Symbol('z')

    ###
    # Examples from the 'advanced' notebook
    ###

    # XXX: This raises the warning "The evaluation of the expression is
    # problematic. We are trying a failback method that may still work. Please
    # report this as a bug." It has to use the fallback because using evalf()
    # is the only way to evaluate the integral. We should perhaps just remove
    # that warning.

    with warns(UserWarning, match="The evaluation of the expression is problematic"):
        i = Integral(log((sin(x)**2 + 1)*sqrt(x**2 + 1)), (x, 0, y))
        p = plot(i, (y, 1, 5))
        p.save(tmp_file('%s_advanced_integral' % name))
        p._backend.close()
开发者ID:bjodah,项目名称:sympy,代码行数:22,代码来源:test_plot.py


示例15: plot_and_save_3

def plot_and_save_3(name):
    tmp_file = TmpFileManager.tmp_file

    x = Symbol('x')
    y = Symbol('y')
    z = Symbol('z')

    ###
    # Examples from the 'colors' notebook
    ###

    p = plot(sin(x))
    p[0].line_color = lambda a: a
    p.save(tmp_file('%s_colors_line_arity1' % name))

    p[0].line_color = lambda a, b: b
    p.save(tmp_file('%s_colors_line_arity2' % name))
    p._backend.close()

    p = plot(x*sin(x), x*cos(x), (x, 0, 10))
    p[0].line_color = lambda a: a
    p.save(tmp_file('%s_colors_param_line_arity1' % name))

    p[0].line_color = lambda a, b: a
    p.save(tmp_file('%s_colors_param_line_arity2a' % name))

    p[0].line_color = lambda a, b: b
    p.save(tmp_file('%s_colors_param_line_arity2b' % name))
    p._backend.close()

    p = plot3d_parametric_line(sin(x) + 0.1*sin(x)*cos(7*x),
             cos(x) + 0.1*cos(x)*cos(7*x),
        0.1*sin(7*x),
        (x, 0, 2*pi))
    p[0].line_color = lambdify_(x, sin(4*x))
    p.save(tmp_file('%s_colors_3d_line_arity1' % name))
    p[0].line_color = lambda a, b: b
    p.save(tmp_file('%s_colors_3d_line_arity2' % name))
    p[0].line_color = lambda a, b, c: c
    p.save(tmp_file('%s_colors_3d_line_arity3' % name))
    p._backend.close()

    p = plot3d(sin(x)*y, (x, 0, 6*pi), (y, -5, 5))
    p[0].surface_color = lambda a: a
    p.save(tmp_file('%s_colors_surface_arity1' % name))
    p[0].surface_color = lambda a, b: b
    p.save(tmp_file('%s_colors_surface_arity2' % name))
    p[0].surface_color = lambda a, b, c: c
    p.save(tmp_file('%s_colors_surface_arity3a' % name))
    p[0].surface_color = lambdify_((x, y, z), sqrt((x - 3*pi)**2 + y**2))
    p.save(tmp_file('%s_colors_surface_arity3b' % name))
    p._backend.close()

    p = plot3d_parametric_surface(x * cos(4 * y), x * sin(4 * y), y,
             (x, -1, 1), (y, -1, 1))
    p[0].surface_color = lambda a: a
    p.save(tmp_file('%s_colors_param_surf_arity1' % name))
    p[0].surface_color = lambda a, b: a*b
    p.save(tmp_file('%s_colors_param_surf_arity2' % name))
    p[0].surface_color = lambdify_((x, y, z), sqrt(x**2 + y**2 + z**2))
    p.save(tmp_file('%s_colors_param_surf_arity3' % name))
    p._backend.close()
开发者ID:Lenqth,项目名称:sympy,代码行数:62,代码来源:test_plot.py


示例16: plot_and_save

def plot_and_save(name):
    x = Symbol('x')
    y = Symbol('y')
    z = Symbol('z')

    ###
    # Examples from the 'introduction' notebook
    ###

    p = plot(x)
    p = plot(x*sin(x),x*cos(x))
    p.extend(p)
    p[0].line_color = lambda a : a
    p[1].line_color='b'
    p.title = 'Big title'
    p.xlabel = 'the x axis'
    p[1].label = 'straight line'
    p.legend = True
    p.aspect_ratio = (1,1)
    p.xlim = (-15,20)
    p.save(tmp_file('%s_basic_options_and_colors.png' % name))

    p.extend(plot(x+1))
    p.append(plot(x+3,x**2)[1])
    p.save(tmp_file('%s_plot_extend_append.png' % name))

    p[2] = plot(x**2, (x, -2, 3))
    p.save(tmp_file('%s_plot_setitem.png' % name))

    p = plot(sin(x),(x,-2*pi,4*pi))
    p.save(tmp_file('%s_line_explicit.png' % name))

    p = plot(sin(x))
    p.save(tmp_file('%s_line_default_range.png' % name))

    p = plot((x**2, (x, -5, 5)), (x**3, (x, -3, 3)))
    p.save(tmp_file('%s_line_multiple_range.png' % name))


    #parametric 2d plots.
    #Single plot with default range.
    plot_parametric(sin(x), cos(x)).save(tmp_file())

    #Single plot with range.
    p = plot_parametric(sin(x), cos(x), (x, -5, 5))
    p.save(tmp_file('%s_parametric_range.png' % name))

    #Multiple plots with same range.
    p = plot_parametric((sin(x), cos(x)), (x, sin(x)))
    p.save(tmp_file('%s_parametric_multiple.png' % name))

    #Multiple plots with different ranges.
    p = plot_parametric((sin(x), cos(x), (x, -3, 3)), (x, sin(x), (x, -5, 5)))
    p.save(tmp_file('%s_parametric_multiple_ranges.png' % name))

    #depth of recursion specified.
    p = plot_parametric(x, sin(x), depth=13)
    p.save(tmp_file('%s_recursion_depth' % name))

    #No adaptive sampling.
    p = plot_parametric(cos(x), sin(x), adaptive=False, nb_of_points=500)
    p.save(tmp_file('%s_adaptive' % name))

    #3d parametric plots
    p = plot3d_parametric_line(sin(x),cos(x),x)
    p.save(tmp_file('%s_3d_line.png' % name))

    p = plot3d_parametric_line((sin(x), cos(x), x, (x, -5, 5)), (cos(x), sin(x), x, (x, -3, 3)))
    p.save(tmp_file('%s_3d_line_multiple' % name))

    p = plot3d_parametric_line(sin(x), cos(x), x, nb_of_points=30)
    p.save(tmp_file('%s_3d_line_points' % name))

    # 3d surface single plot.
    p = plot3d(x * y)
    p.save(tmp_file('%s_surface.png' % name))

    # Multiple 3D plots with same range.
    p = plot3d(-x * y, x * y, (x, -5, 5))
    p.save(tmp_file('%s_surface_multiple' % name))

    # Multiple 3D plots with different ranges.
    p = plot3d((x * y, (x, -3, 3), (y, -3, 3)), (-x * y, (x, -3, 3), (y, -3, 3)))
    p.save(tmp_file('%s_surface_multiple_ranges' % name))

    # Single Parametric 3D plot
    p = plot3d_parametric_surface(sin(x + y), cos(x - y), x - y)
    p.save(tmp_file('%s_parametric_surface' % name))

    # Multiple Parametric 3D plots.
    p = plot3d_parametric_surface((x*sin(z),x*cos(z),z, (x, -5, 5), (z, -5, 5)),
                (sin(x + y), cos(x - y), x - y, (x, -5, 5), (y, -5, 5)))
    p.save(tmp_file('%s_parametric_surface.png' % name))

    ###
    # Examples from the 'colors' notebook
    ###

    p = plot(sin(x))
    p[0].line_color = lambda a : a
#.........这里部分代码省略.........
开发者ID:StefenYin,项目名称:sympy,代码行数:101,代码来源:test_plot.py


示例17: Symbol

from sympy.plotting import plot
from sympy import Symbol
x = Symbol('x')
plot(2*x+3)
开发者ID:JSONMartin,项目名称:codingChallenges,代码行数:4,代码来源:sympy_graph.py


示例18: ploteq

def ploteq(*args, **kwargs):
    """軸のアスペクト比を均等にプロットするための関数である。broken。以下の方法で均等なプロットを見ることはできるが、Plot._backend を生成するためには plot(..., show=False) とはできないようである。なので均等ではないプロットと均等なプロットとが両方表示されてしまう。しかし何にせよ、均等なプロットを見ることはできている。それらが両方表示されるのは好ましいと考えることもできる。"""
    p = plot(*args, **kwargs)
    p._backend.ax.set_aspect("equal")
    return p._backend.fig
开发者ID:ubuntuh,项目名称:github,代码行数:5,代码来源:ipython_qtconsole_init.py


示例19: raw_input

from sympy import *
from sympy.plotting import plot
import sys

exprstr = raw_input('Enter an expression in terms of x and y: ')

x = Symbol('x')
try:
	expr1 = sympify(exprstr)
except SympifyError:
	print ('Invalid input(s)')
	sys.exit("Exiting")

p = plot(expr1, legend = true, show = false)
p.show()
开发者ID:NTomtishen,项目名称:MathWithPython,代码行数:15,代码来源:ExprGrapher.py


示例20: plotExpressioFromTo

 def plotExpressioFromTo(self, fromm, to):
     plot(self.expression, (self.x,fromm,to) )
开发者ID:Arthyom,项目名称:PythonX-s,代码行数:2,代码来源:wflsNumerics.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python intervalmath.interval函数代码示例发布时间:2022-05-27
下一篇:
Python pi.evalf函数代码示例发布时间: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