[Python] Stacked 2D contour plots along y-axis in python

Discussão em 'Python' iniciado por Stack, Setembro 27, 2024.

  1. Stack

    Stack Membro Participativo

    I would like to plot 2D contour plots stacked along the y-axis

    I wrote the following code in python, which produce the 2D contour plots stacked along the z-axis, however, when I try to stacked them along the y-axis by set the zdir variable to "y" and rearraging the declarations for the limits, ticks and labels accordingly, the resulting plot is empty and only displays the axis. The necessary variables, x, y, x3 and levels, as well as the function FE_ethylene have been previously declared. Does anyone know how to stack the contour plots along the y-axis? Thanks

    #Stack along the z-axis
    fig = plt.figure(figsize=(8, 6))
    ax = fig.add_subplot(111, projection='3d')

    contours3D = []
    for i, s in enumerate(x3):
    print(i,s)
    contours3D.append(ax.contourf(x, y, FE_ethylene(x, y, s), zdir='z', offset=s, levels=levels, cmap='rainbow', alpha = 1.0-i/10))

    ax.set_xlim3d(0.45, 2.45)
    ax.set_ylim3d(0.55, 2.45)
    ax.set_zlim3d(0.07, 0.13)

    ax.set_xticks(np.linspace(0.6, 2.4, 5))
    ax.set_yticks(np.linspace(0.6, 2.4, 5))
    ax.set_zticks(np.linspace(0.08, 0.12, 5))

    ax.set_xlabel("Carbon content (mg/cm2)")
    ax.set_ylabel("PTFE content (mg/cm2)")
    ax.set_zlabel("Sustainion content (mg/cm2)")

    plt.show()

    Continue reading...

Compartilhe esta Página