예제 #1
0
def plotgrid_and_save(name):
    tmp_file = TmpFileManager.tmp_file

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

    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()
예제 #2
0
파일: test_plot.py 프로젝트: bjodah/sympy
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()
예제 #3
0
def ball():
    # x^2+y^2+z^2=a^2
    # plot3d(x**2+y**2+z**2,(x,-2,2),(y,-2,2),(z,-2,z))
    plot3d_parametric_surface(cos(u + v), sin(u - v), u - v, (u, -5, 5),
                              (v, -5, 5))
    plot3d_parametric_line((cos(u), sin(u), u, (u, -5, 5)),
                           (sin(u), u**2, u, (u, -5, 5)))
    # 圆
    plot_parametric((cos(u), sin(u), (u, -5, 5)), (cos(u), u, (u, -5, 5)))
예제 #4
0
def plot_circle(L_func, L_value):
    ''''''
    # Cartesian coordinates
    # Plots a function of a single variable as a curve
    # plot(L_func)
    # plot3d(L_func)
    # 直角坐标与极坐标互化
    # The transformation of Cartesian coordinates and polar coordinates
    # x=ρcosθ,y=ρsinθ,x²+y²=ρ²
    if str(L_func) == 'x**2 + y**2':
        print('polar coordinates')
    new_x = sqrt(L_value) * cos(theta)
    new_y = sqrt(L_value) * sin(theta)
    # 不可以用pi,要用实数
    plot_parametric(new_x, new_y, (theta, 0, 7))
예제 #5
0
파일: main.py 프로젝트: jaywreddy/spiderpig
def plot_geom(items):
    plots = []
    #create plots from implicit equations
    for item in items:
        if isinstance(item,Circle):
            cc = Circle(item.center.evalf(), item.radius)
            pl = plot_implicit(cc.equation(),show=False)
            plots.append(pl)
        elif isinstance(item,Segment):
            limits = item.plot_interval()
            var, a0,a1 = limits
            xeq,yeq = item.arbitrary_point().args

            #introduce numerical precision
            xeq = xeq.evalf()
            yeq = yeq.evalf()
            new_limits = (xeq.free_symbols.pop(),a0,a1)
            pl = plot_parametric(xeq,yeq,new_limits, show=False, line_color='r')
            plots.append(pl)
        elif isinstance(item,Line):
            pl = plot_implicit(item.equation().evalf(),show=False)
            plots.append(pl)
        elif isinstance(item,Point):
            pc = Circle(item.evalf(), .2)
            plots.append(plot_geom([pc]))
        else:
            raise TypeError("item does not have recognized geometry type")
    #combine plots
    p = plots.pop()
    for e in plots:
        p.extend(e)
    return p
예제 #6
0
def plot_stuff():
    #evalf
    xf, yf = F.args
    t = xf.free_symbols.pop()
    state = {t: 3.3}
    #funcified = funcify_all(items, t)
    evaluated = eval_all(items, state)
    total_plot = plot_geom(evaluated)

    #evaluate mechanism at multiple points
    mechanism = [b1, b2, b3, b4]
    #func_mech = funcify_all(mechanism, t)
    steps = 7
    t_plot = total_plot
    for p in frange(0.0, 2 * np.pi, 2 * np.pi / steps):
        p_state = {t: p}
        evaluated = eval_all(mechanism, p_state)
        p_plot = plot_geom(evaluated)
        t_plot.extend(p_plot)

    #trace out foot path
    path_plot = plot_parametric(xf.evalf(),
                                yf.evalf(),
                                (xf.free_symbols.pop(), 0.0, 2 * np.pi),
                                show=False)
    t_plot.extend(path_plot)

    t_plot.show()
    total_plot.show()
    t_plot.save("klann2.png")
예제 #7
0
파일: main.py 프로젝트: jaywreddy/spiderpig
def plot_stuff():
    #evalf
    xf, yf = F.args
    t = xf.free_symbols.pop()
    state = {t:3.3}
    #funcified = funcify_all(items, t)
    evaluated = eval_all(items, state)
    total_plot = plot_geom(evaluated)

    #evaluate mechanism at multiple points
    mechanism = [b1,b2,b3,b4]
    #func_mech = funcify_all(mechanism, t)
    steps = 7
    t_plot = total_plot
    for p in frange(0.0, 2*np.pi, 2*np.pi/steps):
        p_state = {t:p}
        evaluated = eval_all(mechanism,p_state)
        p_plot = plot_geom(evaluated)
        t_plot.extend(p_plot)

    #trace out foot path
    path_plot = plot_parametric(xf.evalf(),yf.evalf(), (xf.free_symbols.pop(),0.0,2*np.pi),show=False)
    t_plot.extend(path_plot)

    t_plot.show()
    total_plot.show()
    t_plot.save("klann2.png")
예제 #8
0
def test_issue_11764():
    matplotlib = import_module('matplotlib', min_module_version='1.1.0', catch=(RuntimeError,))
    if not matplotlib:
        skip("Matplotlib not the default backend")
    x = Symbol('x')
    p = plot_parametric(cos(x), sin(x), (x, 0, 2 * pi), aspect_ratio=(1,1), show=False)
    p.aspect_ratio == (1, 1)
    # Random number of segments, probably more than 100, but we want to see
    # that there are segments generated, as opposed to when the bug was present
    assert len(p[0].get_segments()) >= 30
예제 #9
0
def plot_geom(items):
    plots = []
    fig = plt.figure()
    ax = fig.add_subplot(111)
    #create plots from implicit equations
    for item in items:
        if isinstance(item, Circle):
            cc = Circle(item.center.evalf(), item.radius)
            pl = plot_implicit(cc.equation(), show=False)
            plots.append(pl)
        elif isinstance(item, Segment):
            limits = item.plot_interval()
            var, a0, a1 = limits
            xeq, yeq = item.arbitrary_point().args
            #introduce numerical precision
            xeq = xeq.evalf()
            yeq = yeq.evalf()
            new_limits = (xeq.free_symbols.pop(), a0, a1)
            pl = plot_parametric(xeq,
                                 yeq,
                                 new_limits,
                                 show=False,
                                 line_color='r')
            plots.append(pl)
        elif isinstance(item, Line):
            pl = plot_implicit(item.equation().evalf(), show=False)
            plots.append(pl)
        elif isinstance(item, Point):
            pc = Circle(item.evalf(), .2)
            plots.append(plot_geom([pc]))
        elif isinstance(item, list):
            print("item")
            print(item)
            mat_pts = [(p.x.evalf(), p.y.evalf()) for p in item]
            print("mat_pts")
            print(mat_pts)
            mat_pts += [mat_pts[0]]  #line has to end where it starts
            codes = [Path.MOVETO]
            for i in range(len(mat_pts) - 2):
                codes += [Path.LINETO]
            codes += [Path.CLOSEPOLY]

            path = Path(mat_pts, codes)
            patch = patches.PathPatch(path, facecolor='red', alpha=.5, lw=2)
            ax.add_patch(patch)
            ax.set_xlim(-200, 200)
            ax.set_ylim(-200, 200)
        else:
            raise TypeError("item does not have recognized geometry type")
    #combine plots
    plt.show()
    p = plots.pop()
    for e in plots:
        p.extend(e)
    return p
예제 #10
0
 def __init__(self):
     self.plotters = {
         "plot":
         lambda args, params: plot(*args, **params),
         "plot_parametric":
         lambda args, params: plot_parametric(*args, **params),
         "plot3d":
         lambda args, params: plot3d(*args, **params),
         "plot3d_parametric_line":
         lambda args, params: plot3d_parametric_line(*args, **params),
         "plot3d_parametric_surface":
         lambda args, params: plot3d_parametric_surface(*args, **params),
     }
예제 #11
0
def plot_geom(items):
    plots = []
    fig = plt.figure()
    ax = fig.add_subplot(111)
    #create plots from implicit equations
    for item in items:
        if isinstance(item,Circle):
            cc = Circle(item.center.evalf(), item.radius)
            pl = plot_implicit(cc.equation(),show=False)
            plots.append(pl)
        elif isinstance(item,Segment):
            limits = item.plot_interval()
            var, a0,a1 = limits
            xeq,yeq = item.arbitrary_point().args
            #introduce numerical precision
            xeq = xeq.evalf()
            yeq = yeq.evalf()
            new_limits = (xeq.free_symbols.pop(),a0,a1)
            pl = plot_parametric(xeq,yeq,new_limits, show=False, line_color='r')
            plots.append(pl)
        elif isinstance(item,Line):
            pl = plot_implicit(item.equation().evalf(),show=False)
            plots.append(pl)
        elif isinstance(item,Point):
            pc = Circle(item.evalf(), .2)
            plots.append(plot_geom([pc]))
        elif isinstance(item, list):
            print("item")
            print(item)
            mat_pts = [(p.x.evalf(),p.y.evalf()) for p in item]
            print("mat_pts")
            print(mat_pts)
            mat_pts += [mat_pts[0]] #line has to end where it starts
            codes = [Path.MOVETO]
            for i in range(len(mat_pts)-2):
                codes += [Path.LINETO]
            codes += [Path.CLOSEPOLY]

            path = Path(mat_pts, codes)
            patch = patches.PathPatch(path, facecolor = 'red', alpha= .5,lw=2)
            ax.add_patch(patch)
            ax.set_xlim(-200,200)
            ax.set_ylim(-200,200)
        else:
            raise TypeError("item does not have recognized geometry type")
    #combine plots
    plt.show()
    p = plots.pop()
    for e in plots:
        p.extend(e)
    return p
예제 #12
0
def shoot():

	g = 9.81
	series =  []
	cpt = 1

	for i in range(3): 
		print	
		print"*****************"	
		print"Shoot number", cpt
		v=int(raw_input("Choose the velocity of your shoot: ")) # velocity
		alpha_deg=int(raw_input("Choose the angle of your shoot: ")) # angle
		print
		r=(2*v*math.cos(math.radians(alpha_deg))*v*math.sin(math.radians(alpha_deg)))/g # range of the shoot 
		h=(v*v*(math.sin(math.radians(alpha_deg))*math.sin(math.radians(alpha_deg))))/(2*g) # height of the shoot
		print"Range =", math.ceil(r), "meters"
		print"Height =", math.ceil(h), "meters"
		cpt+=1
		print

		t = symbols("t")
		alpha_rad = S(alpha_deg) * pi / 180
		z = v * sin(alpha_rad)*t - 1/2*g*t**2
 
		impact = solve(z,t)
		tMax = max(impact)
		x = v*cos(alpha_rad)* t
		serie = (x,z, (t,0,tMax))
		series.append(serie)

	p = plot_parametric(*series,  show=False)

	p[0].line_color = "red"
	p[1].line_color = "purple"
	p[2].line_color = "black"
	#p[3].line_color = "green"
	#p[4].line_color = "yellow"
	p.show()

	r=math.ceil(r)
	h=math.ceil(h)



	return r
예제 #13
0
def func_gui():
    fun_x = funx.get()
    fun_y = funy.get()
    l = l_x.get()
    u = u_x.get()
    '''if Diff.get():
		p1 = plot(diff(fun_y,fun_x),('t',l,u),show=false)
		p1[0].line_color=result[1]
		p1.show()
        print diff(fun_x,t)
        print diff(fun_y,t)
    elif Diff2.get():
    	p2 = plot(diff(fun_x,fun_y),('t',l,u),show=false)
    	p2[0].line_color=result[1]
    	p2.show()
    else :'''
    p3 = plot_parametric(fun_x,fun_y,('t',l,u),show=false,title=tit.get(),xlabel=x_lab.get(),ylabel=y_lab.get()) 
    p3[0].line_color=result[1]
    p3.show()
예제 #14
0
def decision_boundary(dataset,a_priori_prob,title):

	mean=[np.mean(dataset[0],axis=0),np.mean(dataset[1],axis=0)]
	cov=[np.cov(dataset[0],rowvar=False),np.cov(dataset[1],rowvar=False)]

	x1,x2=symbols('x1 x2')
	M=Matrix([x1,x2])
	g=gi(M,mean[0].reshape(2,1),cov[0],a_priori_prob[0])-gi(M,mean[1].reshape(2,1),cov[1],a_priori_prob[1])
	soln=solve(g,(x1,x2))

	p1=plot_parametric(soln[0],label="decision boundary",line_color='black',show=False)
	fig,ax=plt.subplots(figsize=(14,8))
	ax.set_title(title)
	move_sympyplot_to_axes(p1,ax)

	plt.scatter(x=dataset[0][:,0],y=dataset[0][:,1],label="class 1")
	plt.scatter(x=dataset[1][:,0],y=dataset[1][:,1],label="class 2")
	plt.legend(loc='best')

	return fig
예제 #15
0
def plot_geom(items):
    plots = []
    #create plots from implicit equations
    for item in items:
        if isinstance(item, Circle):
            cc = Circle(item.center.evalf(), item.radius)
            pl = plot_implicit(cc.equation(), show=False)
            plots.append(pl)
        elif isinstance(item, Segment):
            limits = item.plot_interval()
            var, a0, a1 = limits
            xeq, yeq = item.arbitrary_point().args

            #introduce numerical precision
            xeq = xeq.evalf()
            yeq = yeq.evalf()
            new_limits = (xeq.free_symbols.pop(), a0, a1)
            pl = plot_parametric(xeq,
                                 yeq,
                                 new_limits,
                                 show=False,
                                 line_color='r')
            plots.append(pl)
        elif isinstance(item, Line):
            pl = plot_implicit(item.equation().evalf(), show=False)
            plots.append(pl)
        elif isinstance(item, Point):
            pc = Circle(item.evalf(), .2)
            plots.append(plot_geom([pc]))
        else:
            raise TypeError("item does not have recognized geometry type")
    #combine plots
    p = plots.pop()
    for e in plots:
        p.extend(e)
    return p
예제 #16
0
파일: math.py 프로젝트: Iisting/Miza
def plot_parametric(*args, **kwargs):
    kwargs.pop("show", None)
    return plotter.plot_parametric(*plotArgs(args), show=False, **kwargs)
예제 #17
0
                           show=False)  # 3d parametric line plot
g = plot3d(sin(x) * cos(y), (x, -5, 5), (y, -10, 10),
           show=False)  # 3d surface cartesian plot
h = plot3d_parametric_surface(cos(u) * v,
                              sin(u) * v,
                              u, (u, 0, 10), (v, -2, 2),
                              show=False)  # 3d parametric surface plot

# Some aesthetics
e[0].line_color = lambda x: x / 4
f[0].line_color = lambda x, y, z: z / 10
g[0].surface_color = lambda x, y: sin(x)

# Some more stuff on aesthetics - coloring wrt coordinates or parameters
param_line_2d = plot_parametric(
    (x * cos(x), x * sin(x), (x, 0, 15)),
    (1.1 * x * cos(x), 1.1 * x * sin(x), (x, 0, 15)),
    show=False)
param_line_2d[0].line_color = lambda u: sin(u)  # parametric
param_line_2d[1].line_color = lambda u, v: u**2 + v**2  # coordinates
param_line_2d.title = 'The inner one is colored by parameter and the outher one by coordinates'

param_line_3d = plot3d_parametric_line(
    (x * cos(x), x * sin(x), x, (x, 0, 15)),
    (1.5 * x * cos(x), 1.5 * x * sin(x), x, (x, 0, 15)),
    (2 * x * cos(x), 2 * x * sin(x), x, (x, 0, 15)),
    show=False)
param_line_3d[0].line_color = lambda u: u  # parametric
param_line_3d[
    1].line_color = lambda u, v: u * v  # first and second coordinates
param_line_3d[2].line_color = lambda u, v, w: u * v * w  # all coordinates
예제 #18
0
def plot_and_save(name):
    tmp_file = TmpFileManager.tmp_file

    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' % name))
    p._backend.close()

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

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

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

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

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

    raises(ValueError, lambda: plot(x, y))

    #Piecewise plots
    p = plot(Piecewise((1, x > 0), (0, True)), (x, -1, 1))
    p.save(tmp_file('%s_plot_piecewise' % name))
    p._backend.close()

    p = plot(Piecewise((x, x < 1), (x**2, True)), (x, -3, 3))
    p.save(tmp_file('%s_plot_piecewise_2' % name))
    p._backend.close()

    # test issue 7471
    p1 = plot(x)
    p2 = plot(3)
    p1.extend(p2)
    p.save(tmp_file('%s_horizontal_line' % name))
    p._backend.close()

    # test issue 10925
    f = Piecewise((-1, x < -1), (x, And(-1 <= x, x < 0)), \
        (x**2, And(0 <= x, x < 1)), (x**3, x >= 1))
    p = plot(f, (x, -3, 3))
    p.save(tmp_file('%s_plot_piecewise_3' % name))
    p._backend.close()

    #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' % name))
    p._backend.close()

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

    #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' % name))
    p._backend.close()

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

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

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

    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._backend.close()

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

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

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

    # 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))
    p._backend.close()

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

    # 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' % name))
    p._backend.close()

    ###
    # 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()

    ###
    # 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)

    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()

    ###
    # 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())
"""
Program that plots the function alpha(t)
According to alpha(t) you can uncomment the code of the plotting section
"""

# Libraries
import sympy as sp
import sympy.plotting as spp

# Symbols to be used, do not change these
t = sp.symbols('t', positive=True)

# Constants

# alpha(t) vector
alpha = sp.Matrix([[t, t**2]])


# Plotting section

# Obtainting the components of alpha(t)
x = alpha[0]
y = alpha[1]
# z=alpha[2]

# 2D
spp.plot_parametric(x, y, (t, 0, 1), title=r"Plot of $\alpha(t)$")

# 3D
#spp.plot3d_parametric_line(x,y,z,(t,-3,3),title=r"Plot of $\alpha(t)$")
예제 #20
0
파일: test_plot.py 프로젝트: Lenqth/sympy
def plot_and_save_2(name):
    tmp_file = TmpFileManager.tmp_file

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

    #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' % name))
    p._backend.close()

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

    #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' % name))
    p._backend.close()

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

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

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

    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._backend.close()

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

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

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

    # 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))
    p._backend.close()

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

    # 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' % name))
    p._backend.close()

    # Single Contour plot.
    p = plot_contour(sin(x)*sin(y), (x, -5, 5), (y, -5, 5))
    p.save(tmp_file('%s_contour_plot' % name))
    p._backend.close()

    # Multiple Contour plots with same range.
    p = plot_contour(x**2 + y**2, x**3 + y**3, (x, -5, 5), (y, -5, 5))
    p.save(tmp_file('%s_contour_plot' % name))
    p._backend.close()

    # Multiple Contour plots with different range.
    p = plot_contour((x**2 + y**2, (x, -5, 5), (y, -5, 5)), (x**3 + y**3, (x, -3, 3), (y, -3, 3)))
    p.save(tmp_file('%s_contour_plot' % name))
    p._backend.close()
예제 #21
0
nu_frequency = .1
# /(2*pi);
lambda_e1 = 1.0

# sigma = integrate(K_e1*exp(-lambda_e1*( time - s_time ))*Elect_Amp * sin(2*pi*nu_frequency) ,s_time)

# sigma = integrate(K_e1* exp(-lambda_e1*( s_time )) ,s_time)
# sigma = integrate( s_time  ,s_time)
# sigma = integrate( sin(2*pi*nu_frequency*s_time)  ,s_time)

# sigma= integrate(K_e1*exp(-lambda_e1*( time - s_time )) * Elect_Amp * sin(2*pi*nu_frequency*s_time), s_time)

Elect = sin(2 * pi * nu_frequency * time)
Elect_dot = diff(Elect, time)

sigma = integrate(
    exp(-lambda_e1 * (time - s_time)) * Elect_dot.subs(time, s_time), s_time)

# print sigma;
sigma_t = sigma.subs(s_time, time) - sigma.subs(s_time, 0)

# sigma_t_plot=plot(sigma_t,(time,0,10))

hysteresis_plot = plot_parametric(Elect, sigma_t, (time, 0, 10 / nu_frequency))

# plot([cos, sin], [-4, 4])

print sigma_t

# print sigma
예제 #22
0
from sympy import *

from sympy.plotting import (plot_parametric, plot_implicit, plot3d,
                            plot3d_parametric_line, plot3d_parametric_surface)
x = symbols('x')
plot(sin(x) / x, (x, -5, 5))

# фигура Лиссажу
t = Symbol('t')
plot_parametric(sin(2 * t),
                cos(3 * t), (t, -2 * pi, 2 * pi),
                title='Lissajous',
                xlabel='x',
                ylabel='y')

# тор
u, v = symbols('u v')
a = 0.3
plot3d_parametric_surface((1 + a * cos(u)) * cos(v), (1 + a * cos(u)) * sin(v),
                          a * sin(u), (u, 0, 2 * pi), (v, 0, 2 * pi))
예제 #23
0
                            plot3d_parametric_surface, plot3d_parametric_line,
                            plot3d)
def sympy_plot():0
    x, y, u, v = symbols('x, y, u, v')
    # all graphs are not shown when first created
    a = plot(x*sin(x**2), (x, 2, 4), show=False)  # cartesian plot

    b = plot(cos(x-1)*x**2, (x, -5, 5), show=False)  # cartesian plot

    c = plot3d_parametric_line(sin(x), cos(x), x, (x, 0, 20), show=False)  # 3d parametric line plot

    d = plot3d(sin(x)*cos(y)*sin(x*y), (x, -3, 3), (y, -3, 3), show=False)  # 3d surface cartesian plot3d (multivariable)

    e = plot3d_parametric_surface(cos(u)*v, sin(u)*v, sin(0.3*u*v), (u, 0, 10), (v, -2, 2), show=False)  # 3d parametric surface plot (multivariable)

    param_lines_2d = plot_parametric((x*cos(x), x*sin(x), (x, 0, 15)), 
                                    (1.1*x*cos(x), 1.1*x*sin(x), (x, 0, 15)), show=False)   # 2d parametric multiple lines plot

    param_lines_3d = plot3d_parametric_line((x*cos(x), x*sin(x), x, (x, 0, 15)),
                         (1.5*x*cos(x), 1.5*x*sin(x), x, (x, 0, 15)),
                         (2*x*cos(x), 2*x*sin(x), x, (x, 0, 15)), show=False)   # 3d parametric multiple lines plot

    for i in [a, b, c, d, e, param_lines_2d, param_lines_3d]:
        i.show()

sympy_plot()


# SymPy real Example (Monte Carlo Simulation)

import random
from sympy import *
예제 #24
0
파일: math.py 프로젝트: GabrielRavier/Miza
def plot_parametric(*args, **kwargs):
    if "show" in kwargs:
        kwargs.pop("show")
    return plotter.plot_parametric(*plotArgs(args), show=False, **kwargs)
예제 #25
0
def plot_and_save(name):
    tmp_file = TmpFileManager.tmp_file

    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' % name))
    p._backend.close()

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

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

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

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

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

    raises(ValueError, lambda: plot(x, y))

    p = plot(Piecewise((1, x > 0), (0, True)), (x, -1, 1))
    p.save(tmp_file('%s_plot_piecewise' % name))
    p._backend.close()

    #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' % name))
    p._backend.close()

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

    #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' % name))
    p._backend.close()

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

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

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

    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._backend.close()

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

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

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

    # 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))
    p._backend.close()

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

    # 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' % name))
    p._backend.close()

    ###
    # 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 = lambda a: sin(4 * a)
    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 = lambda a, b, c: sqrt((a - 3 * pi)**2 + b**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 = lambda a, b, c: sqrt(a**2 + b**2 + c**2)
    p.save(tmp_file('%s_colors_param_surf_arity3' % name))
    p._backend.close()

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

    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()

    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()

    ###
    # 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())
예제 #26
0
def plot_and_save_2(name):
    tmp_file = TmpFileManager.tmp_file

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

    #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' % name))
    p._backend.close()

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

    #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' % name))
    p._backend.close()

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

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

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

    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._backend.close()

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

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

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

    # 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))
    p._backend.close()

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

    # 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' % name))
    p._backend.close()

    # Single Contour plot.
    p = plot_contour(sin(x) * sin(y), (x, -5, 5), (y, -5, 5))
    p.save(tmp_file('%s_contour_plot' % name))
    p._backend.close()

    # Multiple Contour plots with same range.
    p = plot_contour(x**2 + y**2, x**3 + y**3, (x, -5, 5), (y, -5, 5))
    p.save(tmp_file('%s_contour_plot' % name))
    p._backend.close()

    # Multiple Contour plots with different range.
    p = plot_contour((x**2 + y**2, (x, -5, 5), (y, -5, 5)),
                     (x**3 + y**3, (x, -3, 3), (y, -3, 3)))
    p.save(tmp_file('%s_contour_plot' % name))
    p._backend.close()
예제 #27
0
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
    p.save(tmp_file('%s_colors_line_arity1.png' % name))

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

    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.png' % name))

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

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

    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 = lambda a : sin(4*a)
    p.save(tmp_file('%s_colors_3d_line_arity1.png' % name))
    p[0].line_color = lambda a, b : b
    p.save(tmp_file('%s_colors_3d_line_arity2.png' % name))
    p[0].line_color = lambda a, b, c : c
    p.save(tmp_file('%s_colors_3d_line_arity3.png' % name))

    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.png' % name))
    p[0].surface_color = lambda a, b : b
    p.save(tmp_file('%s_colors_surface_arity2.png' % name))
    p[0].surface_color = lambda a, b, c : c
    p.save(tmp_file('%s_colors_surface_arity3a.png' % name))
    p[0].surface_color = lambda a, b, c : sqrt((a-3*pi)**2+b**2)
    p.save(tmp_file('%s_colors_surface_arity3b.png' % name))

    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.png' % name))
    p[0].surface_color = lambda a, b : a*b
    p.save(tmp_file('%s_colors_param_surf_arity2.png' % name))
    p[0].surface_color = lambda a, b, c : sqrt(a**2+b**2+c**2)
    p.save(tmp_file('%s_colors_param_surf_arity3.png' % name))

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

    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.png' % name))

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

    p = plot(summation(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.png' % name))


    ###
    # 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())
예제 #28
0
v = Symbol('v')
expr = x**2 - 1

b = plot(expr, (x, 2, 4), show=False)  # cartesian plot
e = plot(exp(-x), (x, 0, 4), show=False)  # cartesian plot (and coloring, see below)
f = plot3d_parametric_line(sin(x), cos(x), x, (x, 0, 10), show=False)  # 3d parametric line plot
g = plot3d(sin(x)*cos(y), (x, -5, 5), (y, -10, 10), show=False)  # 3d surface cartesian plot
h = plot3d_parametric_surface(cos(u)*v, sin(u)*v, u, (u, 0, 10), (v, -2, 2), show=False)  # 3d parametric surface plot

# Some aesthetics
e[0].line_color = lambda x: x / 4
f[0].line_color = lambda x, y, z: z / 10
g[0].surface_color = lambda x, y: sin(x)

# Some more stuff on aesthetics - coloring wrt coordinates or parameters
param_line_2d = plot_parametric((x*cos(x), x*sin(x), (x, 0, 15)), (1.1*x*cos(x), 1.1*x*sin(x), (x, 0, 15)), show=False)
param_line_2d[0].line_color = lambda u: sin(u)  # parametric
param_line_2d[1].line_color = lambda u, v: u**2 + v**2  # coordinates
param_line_2d.title = 'The inner one is colored by parameter and the outher one by coordinates'

param_line_3d = plot3d_parametric_line((x*cos(x), x*sin(x), x, (x, 0, 15)),
                     (1.5*x*cos(x), 1.5*x*sin(x), x, (x, 0, 15)),
                     (2*x*cos(x), 2*x*sin(x), x, (x, 0, 15)), show=False)
param_line_3d[0].line_color = lambda u: u  # parametric
param_line_3d[1].line_color = lambda u, v: u*v  # first and second coordinates
param_line_3d[2].line_color = lambda u, v, w: u*v*w  # all coordinates


if __name__ == '__main__':
    for p in [b, e, f, g, h, param_line_2d, param_line_3d]:
        p.show()
예제 #29
0
        # Save the data in a file:
        # the information is stored as:
        # n, t, Omega(t)

        file_name = 'test' +str(i)+'.txt'
        with open(os.path.join(dir_path, file_name), 'w') as outfile:
            for ind, t in enumerate(tt):
                outfile.write("%s, %s, %s \n" % (ind, t, kappa(l_of_t_func(t))))

        fig, (ax1, ax2) = plt.subplots(2)

        # Convert the functions into numpy functions to be able to plot them with matplotlib
        xx = convert_numpy(x, param=l)
        yy = convert_numpy(y, param=l)
        ax1.plot(xx(ll), yy(ll))

        ax2.plot(tt, kappa(l_of_t_func(tt)))
        kappa_write[i,:] = kappa(l_of_t_func(tt))

        if np.amax(kappa_write[i,:]) > max_val:
            max_val = np.amax(kappa_write[i,:])
        print(max_val)

        # Can also use the sympy plotting option if you want
        plot_parametric(x, y, (l, 0, ll_max))

        # plt.show()



예제 #30
0
def plot_and_save(name):
    tmp_file = TmpFileManager.tmp_file

    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' % name))
    p._backend.close()

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

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

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

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

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

    raises(ValueError, lambda: plot(x, y))

    p = plot(Piecewise((1, x > 0), (0, True)),(x,-1,1))
    p.save(tmp_file('%s_plot_piecewise' % name))
    p._backend.close()

    #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' % name))
    p._backend.close()

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

    #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' % name))
    p._backend.close()

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

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

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

    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._backend.close()

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

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

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

    # 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))
    p._backend.close()

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

    # 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' % name))
    p._backend.close()

    ###
    # 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 = lambda a: sin(4*a)
    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 = lambda a, b, c: sqrt((a - 3*pi)**2 + b**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 = lambda a, b, c: sqrt(a**2 + b**2 + c**2)
    p.save(tmp_file('%s_colors_param_surf_arity3' % name))
    p._backend.close()

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

    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()

    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()

    ###
    # 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())
def main():
    phi, phi_top, phi_middle, phi_bottom, ra, ta, za, df_za, ri, ri_top, ri_bottom = symbols(
        'phi phi_top phi_middle phi_bottom ra ta za df_za ri ri_top ri_bottom')
    zi, zi_top, zi_bottom, fi, h0, h1, zb, rb = symbols(
        'zi zi_top zi_bottom fi h0 h1 zb rb')

    # Flat surface, Table 1.1
    #za = 0
    #
    #s1 = 1
    #n = 1.5
    #t = 10
    #ta = -70
    #tb = 75

    # Spherical surface, Table 1.2
    #za = 100 - sqrt(100**2 - ra**2)
    #
    #s1 = 1
    #n = 1.5
    #t = 8
    #ta = -70
    #tb = 80

    # Parabolic surface, Table 1.3
    #za = ra**2 / 200
    #
    #s1 = 1
    #n = 1.5
    #t = 10
    #ta = -80
    #tb = 100

    # Cosine surface, Table 1.4
    #za = cos(ra/3)
    #
    #s1 = 1
    #n = 1.5
    #t = 8
    #ta = -70
    #tb = 80

    # Bessel surface, Figure 4.d
    za = besselj(0, ra / 2)

    s1 = 1
    n = 1.5
    t = 5
    ta = -30
    tb = 75

    # Parabolic from "Single Lens Telescope"
    #za = -ra**2 / 4

    rmax = 50
    precision = 50

    df_za = diff(za, ra)

    phi_top = (ra + (-ta + za) * df_za)**2
    phi_middle = n**2 * (ra**2 + (ta - za)**2) * (1 + df_za**2)
    phi_bottom = sqrt(1 + df_za**2)
    phi = sqrt(1 - (phi_top / phi_middle)) / phi_bottom
    #phi = sqrt(1 - ((ra + (-ta + za) * df_za)**2 / (n**2 * (ra**2 + (ta - za)**2) * (1 + df_za**2)))) / sqrt(1 + df_za**2)

    ri_top = ra + (-ta + za) * df_za
    ri_bottom = n * sqrt(ra**2 + (ta - df_za)**2) * (1 + df_za**2)
    ri = (ri_top / ri_bottom) - df_za * phi
    #ri = ((ra + (-ta + za) * df_za) / (n * sqrt(ra**2 + (ta - za)**2) * (1 + df_za**2))) - (df_za * phi)

    zi_top = df_za * (ra + (-ta + za) * df_za)
    zi_bottom = n * sqrt(ra**2 + (ta - za)**2) * (1 + df_za**2)
    zi = (zi_top / zi_bottom) + phi
    #zi = ((df_za * (ra + (-ta + za) * df_za)) / ((n * sqrt(ra**2 + (ta - za)**2)) * (1 + df_za**2))) + phi

    fi = ta - tb - sign(ta) * sqrt(ra**2 + (ta - za)**2)
    h0 = ri**2 * za + fi * n * zi - ra * ri * zi + (t + tb) * zi**2 - n**2 * (
        za + t * zi)
    h1 = ra**2 + 2 * ra * ri * t + (
        tb - za)**2 + t**2 * (ri**2 +
                              (-1 + zi)**2) - 2 * t * (tb - za) * (-1 + zi)
    zb = (h0 + s1 * sqrt(zi**2 * (fi**2 - 2 * fi * n *
                                  (ra * ri + ri**2 * t + zi *
                                   (t * (zi - 1) - tb + za)) + h1 * n**2 -
                                  (ra * zi + ri *
                                   (t + tb - za))**2))) / (-n**2 + 1)
    rb = ra + (ri * (-za + zb)) / zi

    p = plot_parametric((ra, za), (rb, zb), (ra, -rmax, rmax),
                        xlim=(-30, 30),
                        ylim=(-30, 30))

    #foo = solveset(Eq(ra/za, rb/zb), ra)
    #print(foo)

    ras = numpy.linspace(0, rmax, precision)
    f_za = lambdify(ra, za, "numpy")
    f_rb = lambdify(ra, rb, "numpy")
    f_zb = lambdify(ra, zb, "numpy")
예제 #32
0
def plot_and_save(name):
    tmp_file = TmpFileManager.tmp_file

    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' % name))
    p._backend.close()

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

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

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

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

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

    raises(ValueError, lambda: plot(x, y))

    #Piecewise plots
    p = plot(Piecewise((1, x > 0), (0, True)), (x, -1, 1))
    p.save(tmp_file('%s_plot_piecewise' % name))
    p._backend.close()

    p = plot(Piecewise((x, x < 1), (x**2, True)), (x, -3, 3))
    p.save(tmp_file('%s_plot_piecewise_2' % name))
    p._backend.close()

    # test issue 7471
    p1 = plot(x)
    p2 = plot(3)
    p1.extend(p2)
    p.save(tmp_file('%s_horizontal_line' % name))
    p._backend.close()

    # test issue 10925
    f = Piecewise((-1, x < -1), (x, And(-1 <= x, x < 0)), \
        (x**2, And(0 <= x, x < 1)), (x**3, x >= 1))
    p = plot(f, (x, -3, 3))
    p.save(tmp_file('%s_plot_piecewise_3' % name))
    p._backend.close()

    #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' % name))
    p._backend.close()

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

    #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' % name))
    p._backend.close()

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

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

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

    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._backend.close()

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

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

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

    # 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))
    p._backend.close()

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

    # 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' % name))
    p._backend.close()

    ###
    # 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()

    ###
    # 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)

    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()

    ###
    # 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())
            - Otherwise, prints 'can not be parametrized'
            """
            # Print the function explicit in 's'
            desp = sp.solve(equa, t)
            print("Parameter f(s):%s\n" % (desp))
            # Reparametrization of alpha(t)
            nalpha = alpha.subs(t, desp[0])
            print("alpha(s): %s" % (nalpha))

        except:
            print("The arc's length function can not be solved")
            print("alpha(s) can not be parametrized by arc's length")

    except:
        # This code is executed if 'lenArc' could not be solved
        print("The integral can not be solved\n")
        print("alpha(t) can not be parametrized by arc's length")


# Plotting section

x = alpha[0]
y = alpha[1]
#z = alpha[2]

# 2d
spp.plot_parametric(x, y, (t, 0, 1), legend=True)

# 3d
#spp.plot3d_parametric_line(x,y,z,(t,-2*sp.pi,2*sp.pi), label=True)