Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 line partially hidden
#1
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);
Quote
#2
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.
Quote
#3
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 Cool

Thanks for the help

Paul
Quote

Top Page

Forum Jump:


Users browsing this thread: 1 Guest(s)