3D graph plot using python mpl_toolkits

 

 3D graph  plot using python  mpl_toolkits 


we are going to learn 3D graph  plotting using python package mpl_toolkits   using  mpl_toolkits    package we plot different type of 3D graph 


let's start...

Today we can solve 4 types of Q. 

1. Plot 3D  graph of f(x)=sin(x^2 +y^2) in -6<x,y<6

2. Plot 3D  graph of  f(x)=x*e^(-x^2 -y^2) in -6<x,y<6

3. Plot 3D  parabola graph of f(x)=x^2 +y^2 in -10<x,y<10

4. Plot 3D  surface  graph of  f(x)=x^2 +y^2 in -10<x,y<10


Q1. Plot 3D  graph of f(x)=sin(x^2 +y^2) in -6<x,y<6


In this program, we are polt a  3D graph using python

The Program is divide into 5 step


Step1:-- import  python package  using 

from mpl_toolkits import mplot3d

import numpy as np

from pylab import *


Step2:-  assign the value of  x ,y and  create function

def f(x, y):
    return np.sin(np.sqrt(x**2+y**2))


Step3:-  assign the value of  x ,y, z  using given reange point

= linspace(-6630)
= linspace(-6630)

X, Y = np.meshgrid(x, y)
= f(X, Y)


Step4:- create a graph  

ax = axes(projection='3d')
ax.contour3D(X, Y, Z, 50)


Step5 :-  Show your graph using ,show() function 


xlabel("x")
ylabel("Y")
title("3D graph")
legend(loc=0)
show()



Complete program


# plot graph of f(x)=sin(x^2 +y^2) in -6<x,y<6


from mpl_toolkits import mplot3d

import numpy as np

from pylab import *


def f(x, y):
    return np.sin(np.sqrt(x**2+y**2))


= linspace(-6630)
= linspace(-6630)

X, Y = np.meshgrid(x, y)
= f(X, Y)

ax = axes(projection='3d')
ax.contour3D(X, Y, Z, 50)

xlabel("x")
ylabel("Y")
title("3D graph")
legend(loc=0)
show()



Output

                                             



                                                                                                                                                                   




 

Q2. Plot 3D  graph of  f(x)=x*e^(-x^2 -y^2) in -6<x,y<6


In this program, we are polt a  3D graph using python

The Program is divide into 5 step


Step1:-- import  python package  using 

from mpl_toolkits import mplot3d

import numpy as np

from pylab import *


Step2:-  assign the value of  x ,y and  create function

def f(x, y):
    return x*np.exp(-x**2-y**2)


Step3:-  assign the value of  x ,y, z  using given reange point

= linspace(-6630)
= linspace(-6630)

X, Y = np.meshgrid(x, y)
= f(X, Y)


Step4:- create a graph  


ax = axes(projection='3d')
ax.plot_wireframe(X, Y, Z, rstride=2, cstride=2)


Step5 :-  Show your graph using ,show() function 


xlabel("x")
ylabel("Y")
title("3D graph wireframe")
legend(loc=0)
show()



Complete program



# plot graph of f(x)=x*e^(-x^2 -y^2) in -6<x,y<6


from mpl_toolkits import mplot3d

import numpy as np

from pylab import *


def f(x, y):
    return x*np.exp(-x**2-y**2)


= linspace(-6630)
= linspace(-6630)

X, Y = np.meshgrid(x, y)
= f(X, Y)

ax = axes(projection='3d')
ax.plot_wireframe(X, Y, Z, rstride=2, cstride=2)

xlabel("x")
ylabel("Y")
title("3D graph wireframe")
legend(loc=0)
show()



Output

                                                       






                                                                                                                                                            




 

Q3. Plot 3D parabola  graph of f(x)=x^2 +y^2 in -10<x,y<10


In this program, we are polt a  3D graph using python

The Program is divide into 5 step


Step1:-- import  python package  using 

from mpl_toolkits import mplot3d

import numpy as np

from pylab import *


Step2:-  assign the value of  x ,y and  create function

def f(x, y):
    return x**2+y**2


Step3:-  assign the value of  x ,y, z  using given reange point

= linspace(-6630)
= linspace(-6630)

X, Y = np.meshgrid(x, y)
= f(X, Y)


Step4:- create a graph  


ax = axes(projection='3d')
ax.contour3D(X, Y, Z, 50)


Step5 :-  Show your graph using ,show() function 



xlabel("x")
ylabel("Y")
title("3D parabola  graph")
legend(loc=0)
show()


Complete program


# plot graph of f(x)=x^2 +y^2 in -10<x,y<10


from mpl_toolkits import mplot3d

import numpy as np

from pylab import *


def f(x, y):
    return x**2+y**2


= linspace(-101050)
= linspace(-101050)

X, Y = np.meshgrid(x, y)
= f(X, Y)

ax = axes(projection='3d')
ax.contour3D(X, Y, Z, 50)

xlabel("x")
ylabel("Y")
title("3D parabola  graph")
legend(loc=0)
show()




Output

                                             










                                                                                                                                                             




 

Q4. Plot 3D  surface  graph of  f(x)=x^2 +y^2 in -10<x,y<10


In this program, we are polt a  3D graph using python

The Program is divide into 5 step


Step1:-- import  python package  using 

from mpl_toolkits import mplot3d

import numpy as np

from pylab import *


Step2:-  assign the value of  x ,y and  create function

def f(x, y):
    return x**2+y**2


Step3:-  assign the value of  x ,y, z  using given reange point

= linspace(-6630)
= linspace(-6630)

X, Y = np.meshgrid(x, y)
= f(X, Y)


Step4:- create a graph  


ax = axes(projection='3d')
ax.plot_surface(X, Y, Z)


Step5 :-  Show your graph using ,show() function 



xlabel("x")
ylabel("Y")
title("3D surface  graph")
legend(loc=0)
show()



Complete program


# plot graph of f(x)=x^2 +y^2 in -10<x,y<10


from mpl_toolkits import mplot3d
import numpy as np

from pylab import *


def f(x, y):
    return x**2+y**2


= linspace(-101050)
= linspace(-101050)

X, Y = np.meshgrid(x, y)
= f(X, Y)

ax = axes(projection='3d')
ax.plot_surface(X, Y, Z)

xlabel("x")
ylabel("Y")
title("3D surface  graph")
legend(loc=0)
show()





Output

                                             














Post a Comment

0 Comments