How can I generate 3D plots in Mechanical?

Ayush Kumar
Ayush Kumar Member, Moderator, Employee Posts: 467
100 Answers 250 Likes 100 Comments Second Anniversary
✭✭✭✭
edited June 2023 in Structures

How can I generate 3D plots in Mechanical ?

Tagged:

Answers

  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 467
    100 Answers 250 Likes 100 Comments Second Anniversary
    ✭✭✭✭
    Answer ✓

    By activating CPython in Mechanical and if you have tcl error, the following workaround should help: Tcl Error matplotlib

    3D chart examples

    A simple example:

    from mpl_toolkits import mplot3d
    import numpy as np
    import matplotlib.pyplot as plt
    
    my_fig = plt.figure()
    axes = plt.axes(projection='3d')
    z = np.linspace(0, 1, 100)
    x = z * np.sin(30 * z)
    y = z * np.cos(30 * z)
    
    axes.plot3D(x, y, z, 'maroon')
    axes.set_title('3D line plot')
    plt.show()