3D plot: draw xy grid line on the middle of the plot box
3 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
William Rose
2025 年 4 月 16 日
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.
回答 (2 件)
William Rose
2025 年 4 月 16 日
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.
参考
カテゴリ
Help Center および File Exchange で Axes Appearance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


