(f, var1, var2, show=True)
Plot a 3d function using matplotlib/Tk.
Plot a 3d function using matplotlib/Tk.
Plot a 3d function using matplotlib / Tk .
def mplot3d(f, var1, var2, show=True):
    """
    Plot a 3d function using matplotlib/Tk.
    """

    import warnings
    warnings.filterwarnings("ignore", "Could not match \S")

    p = import_module('pylab')
    # Try newer version first
    p3 = import_module('mpl_toolkits.mplot3d',
        __import__kwargs={'fromlist': ['something']}) or import_module('matplotlib.axes3d')
    if not p or not p3:
        sys.exit("Matplotlib is required to use mplot3d.")

    x, y, z = sample(f, var1, var2)

    fig = p.figure()
    ax = p3.Axes3D(fig)

    # ax.plot_surface(x,y,z) #seems to be a bug in matplotlib
    ax.plot_wireframe(x, y, z)

    ax.set_xlabel('X')
    ax.set_ylabel('Y')
    ax.set_zlabel('Z')

    if show:
        p.show()
def mplot3d ( f , var1 , var2 , show = True ) : import warnings warnings . filterwarnings ( "ignore" , "Could not match \S" ) p = import_module ( 'pylab' ) # Try newer version first p3 = import_module ( 'mpl_toolkits.mplot3d' , __import__kwargs = { 'fromlist' : [ 'something' ] } ) or import_module ( 'matplotlib.axes3d' ) if not p or not p3 : sys . exit ( "Matplotlib is required to use mplot3d." ) x , y , z = sample ( f , var1 , var2 ) fig = p . figure ( ) ax = p3 . Axes3D ( fig ) # ax.plot_surface(x,y,z) #seems to be a bug in matplotlib ax . plot_wireframe ( x , y , z ) ax . set_xlabel ( 'X' ) ax . set_ylabel ( 'Y' ) ax . set_zlabel ( 'Z' ) if show : p . show ( )