3D plot: draw xy grid line on the middle of the plot box
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a 3D plot. The grid lines typically render at limiting planes of the plot box. I'd like them to render on a plane inside those limits. For example, I have a box that is +/-2 units in x, y, and z. I turn off the z grid. I'd like the xy grid to render in the xy plane at z=0. Is there a way to do this with out explicitly drawing lines manually?
2 Kommentare
William Rose
am 16 Apr. 2025
You can move the axes in a 2D plot, as shown below. If you could move the axes in a 3D plot, maybe the gridlines would move too. But XAxisLocation and YAxis location seem ineffecual in a 3D plot.
x=-2:.05:2; y=2*sin(x*pi);
figure
plot(x,y); grid on
ax=gca; ax.XAxisLocation='origin'; ax.YAxisLocation='origin';
Here's the 3D version. The axis locations do not move to the origin, despite the command to do so.
x=-2:0.2:2; y=-2:0.2:2;
[X,Y]=meshgrid(x,y);
Z=-2+4*exp(-(X.^2+Y.^2)/4);
surf(X,Y,Z); grid on;
ax=gca; ax.XAxisLocation='origin'; ax.YAxisLocation='origin';
Maybe someone else knows the way to make it happen.
Antworten (2)
William Rose
am 16 Apr. 2025
x=-2:0.2:2; y=-2:0.2:2;
[X,Y]=meshgrid(x,y);
Z=-2+4*exp(-(X.^2+Y.^2)/4);
surf(X,Y,Z);
grid3(x,y,0)
You could edit the function to get black or gray grid points, if you prefer.
Siehe auch
Kategorien
Mehr zu Axes Appearance finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


