[Python] Extrusion of line in Matplotlib

Discussão em 'Python' iniciado por Stack, Maio 7, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to "trivially" extend this line in a third dimension, such that the blue line in this Wavy blue line between two end points

    Becomes the boundary of a sheet, and the endpoints of the boundary are $x_1$, $x_2$:

    import numpy as np
    import matplotlib.pyplot as plt


    t = np.linspace(0, 1, 500)
    x = t

    # Central blue path
    y_central = 0.7 * np.sin(4 * np.pi * t) + t**1.5

    # Start and end points
    start_y = y_central[0]
    end_y = y_central[-1]


    # Plot the main blue path
    plt.plot(x, y_central, color='blue', linewidth=2.5)

    #end points
    plt.scatter([x[0]], [y_central[0]], color='red', zorder=5)
    plt.text(x[0]-0.05, y_central[0], r'$x_2$', fontsize=14, color='red', verticalalignment='top')

    plt.scatter([x[-1]], [y_central[-1]], color='green', zorder=5)
    plt.text(x[-1]+0.01, y_central[-1], r'$x_1$', fontsize=14, color='green', verticalalignment='bottom')

    #Middle label
    midpoint = len(t) // 2
    plt.text(x[midpoint], y_central[midpoint] + 0.4, r'$x$', fontsize=16, color='blue', ha='center')

    # Axis formatting
    plt.xlabel(r'$x\, (100 \rightarrow 0)$', fontsize=12)
    plt.xticks([])
    plt.yticks([])
    plt.box(False)

    plt.tight_layout()
    plt.show()


    Crucially I would like it to appear as if you just tilted the wavy line slightly to reveal that it is actually a sheet rather than a line.

    Continue reading...

Compartilhe esta Página