Jul-10-2019, 10:21 AM

Dear All

I'm learning how to use matplotlib in order to plot 3D surfaces; in the current example, I do not understand why the redline is partially hidden by the surface (basically if one change the azimut value from 45. to 90., then the line must be at the middle of the surface, higher than it)

Any suggestion on what I'm doing wrong?

Thanks

Paul

I'm learning how to use matplotlib in order to plot 3D surfaces; in the current example, I do not understand why the redline is partially hidden by the surface (basically if one change the azimut value from 45. to 90., then the line must be at the middle of the surface, higher than it)

Any suggestion on what I'm doing wrong?

Thanks

Paul

import matplotlib.pyplot as plt import matplotlib.tri as tri import numpy as np n = 50.; elevation = 30; # vertical #azimut = 90.; # theta azimut = 45.; # theta x = np.arange(-2, 2, 4./n); y = np.arange(-1, 3, 4./n); x, y = np.meshgrid(x, y); z = x**2 - y**2; fig = plt.figure(figsize=(16, 9)); ax = fig.gca(projection='3d'); #ax.set_aspect('auto'); # line: 2 points coordinates xl,yl,zl = [0. , 0.],[4. , -1.],[8. , 8.]; ax.set_title(r"Saddle surface" + "\n",fontsize=20, fontweight='bold'); ax.set_xlabel(r"$X_{axis}$"); ax.set_ylabel(r"$Y_{axis}$"); ax.set_zlabel(r"$Z_{axis}$"); ax.plot_wireframe(x, y, z, color='black'); ax.plot_surface(x, y, z, rstride=1, cstride=1, linewidth=0.3, antialiased=True, edgecolor='black'); # surface plot ax.plot(xl, yl, zl, marker='o', color = 'r', linewidth=1.5, markersize=2); # line plot ax.view_init(elevation, azimut) plt.savefig('saddle.png',dpi=200);