Bottom Page

• 0 Vote(s) - 0 Average
• 1
• 2
• 3
• 4
• 5
 line partially hidden paul18fr Not Blown Up Yet Posts: 66 Threads: 16 Joined: Apr 2019 Reputation: 2 Likes received: 2 #1 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 ```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); ``` scidam Posts: 541 Threads: 1 Joined: Mar 2018 Reputation: 71 Likes received: 76 #2 Jul-10-2019, 12:06 PM This issue is specificity of Matplotlib. It was developed to be focused on producing publication-ready 2D plots. Read about this issue here and here. You can set, e.g. `zorder=10` (for the line plot) to emulate desired result. paul18fr Not Blown Up Yet Posts: 66 Threads: 16 Joined: Apr 2019 Reputation: 2 Likes received: 2 #3 Jul-10-2019, 12:23 PM Ah yes; I had a look to the "zorder" doc and in my case I had to put zorder to 4 to get the desired result (I guess this is due to markers); of course zorder=10 does the job but I figure out why now Thanks for the help Paul « Next Oldest | Next Newest »

Top Page

Forum Jump:

Users browsing this thread: 1 Guest(s)