I have a 3D plot that I am viewing from the top, so that it looks like a 2D plot. How can I display the tick marks above the plot? I tried using
set(gca, 'Layer', 'top')
but that only brought the major tick marks to the top and left the minor tick marks hidden. Worse, it also brought the dotted gridlines, which I do not want to see, to the top.

1 Kommentar

I know it's been a long time, but
use this after ploting
set(gca,'Layer','top')

Melden Sie sich an, um zu kommentieren.

Antworten (3)

junlong
junlong am 17 Mär. 2016
Bearbeitet: KSSV am 2 Aug. 2024

4 Stimmen

I was looking for the same thing, and I think you almost got the answer. Just turn the grid off.
set(gca, 'Layer', 'top');
grid off
Azzi Abdelmalek
Azzi Abdelmalek am 4 Feb. 2013
Bearbeitet: Azzi Abdelmalek am 4 Feb. 2013

0 Stimmen

Use
a=xlim;
set(gca,'xlabel',linspace(a(1),a(2),8))
%do the same for ylabel and zlabel

3 Kommentare

Bernoulli Lizard
Bernoulli Lizard am 4 Feb. 2013
This did not work. I get the 'invalid object handle' error.
Azzi Abdelmalek
Azzi Abdelmalek am 4 Feb. 2013
You must insert the above code after your plot
Maciej Dabrowski
Maciej Dabrowski am 1 Dez. 2020
I didn't work for me as well. I'm getting Error using matlab.graphics.axis.Axes/set
Error setting property 'XLabel' of class 'Axes':
Value must be a handle.

Melden Sie sich an, um zu kommentieren.

Sean de Wolski
Sean de Wolski am 4 Feb. 2013

0 Stimmen

hAx = axes;
plot(1:10);
set(hAx,'XAxisLocation','Top');

3 Kommentare

Bernoulli Lizard
Bernoulli Lizard am 4 Feb. 2013
This doesn't do what I want. It just moves the x axis to the top end of the y axis.
Bernoulli Lizard
Bernoulli Lizard am 4 Feb. 2013
Is there a way to move it to the top of the z-axis instead?
Hi Bernoulli,
I guess I don't see why this wouldn't work:
hAx = axes;
surf(hAx,peaks)
set(hAx,'XAxisLocation','Top');
view(2)
xlabel('Hello World')
Please post a picture of what you expect, and where.

Melden Sie sich an, um zu kommentieren.

Gefragt:

am 4 Feb. 2013

Bearbeitet:

am 2 Aug. 2024

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by