Looking for a 3d plotting software to help me in studies

258 Views Asked by At

Im not quite sure how to formulate my search queries so I will try asking the question in a new thread. Sorry if it already exists in some form.

I basically will benefit greatly from a program which can take different functions of the type f(x,y) and give me a good 3d graph.

I looked up some on Google, but they were pretty basic and couldn't graph most of the functions I wanted. For example

(x2+y2+z2+6)2 <= 25(x2+y2)

is the equation of a thoroid, but I cannot seem to find a software that can plot it. Same with most other similar surfaces of revolution, for example. (even spheres).

I would greatly appreciate any suggestions! Also sorry for bad formatting, I'm new here

3

There are 3 best solutions below

3
On

In Mathematica, a region (defined by your equation) is rendered:

RegionPlot3D[(x^2 + y^2 + z^2 + 6)^2 <= 25 (x^2 + y^2), 
 {x, -3, 3}, 
 {y, -3, 3}, 
 {z, -3, 3}]

enter image description here

A traditional plot:

Plot3D[Cos[x y^2], {x, -2, 2}, {y, -2, 2}]

enter image description here

3
On

Maybe this will help you. You just have to declare the functions you want to plot in the form $f(x,y,z)=0$ and then give it as an argument to plot_implicit. The example you give would be like this:

def f(x,y,z):
    return (x**2+y**2+z**2+6)**2 - 25*(x**2+y**2)

plot_implicit(f)

and the result would be: enter image description here

The plot is interactive by the way.

EDIT: To plot many functions you would need to change the code a little bit. Using the code from the answer referred above, you can do:

from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
import numpy as np

def add_figure(ax,f,A1,A2,B):
    for z in B: # plot contours in the XY plane
        X,Y = A1,A2
        Z = f(X,Y,z)
        cset = ax.contour(X, Y, Z+z, [z], zdir='z')
        # [z] defines the only level to plot for this contour for this value of z
        #
    for y in B: # plot contours in the XZ plane
        X,Z = A1,A2
        Y = f(X,y,Z)
        cset = ax.contour(X, Y+y, Z, [y], zdir='y')
        #
    for x in B: # plot contours in the YZ plane
        Y,Z = A1,A2
        X = f(x,Y,Z)
        cset = ax.contour(X+x, Y, Z, [x], zdir='x')
        #
    # must set plot limits because the contour will likely extend
    # way beyond the displayed level.  Otherwise matplotlib extends the plot limits
    # to encompass all values in the contour.


def plot_implicit(funcs, bbox=(-2.5,2.5)):
    ''' create a plot of an implicit function
    fn  ...implicit function (plot where fn==0)
    bbox ..the x,y,and z limits of plotted interval'''
    xmin, xmax, ymin, ymax, zmin, zmax = bbox*3
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    A = np.linspace(xmin, xmax, 100) # resolution of the contour
    B = np.linspace(xmin, xmax, 15) # number of slices
    A1,A2 = np.meshgrid(A,A) # grid on which the contour is plotted
    #
    for f in funcs:
        add_figure(ax,f,A1,A2,B)
    #
    # must set plot limits because the contour will likely extend
    # way beyond the displayed level.  Otherwise matplotlib extends the plot limits
    # to encompass all values in the contour.
    #
    ax.set_zlim3d(zmin,zmax)
    ax.set_xlim3d(xmin,xmax)
    ax.set_ylim3d(ymin,ymax)
    #
    plt.show()

Note that plot_implicit now receives a list of functions, for example:

def f(x,y,z):
    return (x**2+y**2+z**2+6)**2 - 25*(x**2+y**2)

def g(x,y,z):
    return x**2 + y**2 + z**2 - 5


plot_implicit([f,g])

gives the following plot enter image description here

0
On

You can use Graphing Calculator 3D for that. It does not require scripting, it lets you plot multiple graphs on a same axis, and you can zoom in on the 3d model, rotate the camera, plot new points and lines.

Here is the screenshot of thoroid graph with this software:

Plot of sphere and thoroid