Show tick marks above plot
109 views (last 30 days)
Show older comments
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 Comment
itamar luzon
on 25 Dec 2018
I know it's been a long time, but
use this after ploting
set(gca,'Layer','top')
Answers (4)
Azzi Abdelmalek
on 4 Feb 2013
Edited: Azzi Abdelmalek
on 4 Feb 2013
Use
a=xlim;
set(gca,'xlabel',linspace(a(1),a(2),8))
%do the same for ylabel and zlabel
3 Comments
Maciej Dabrowski
on 1 Dec 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.
Sean de Wolski
on 4 Feb 2013
hAx = axes;
plot(1:10);
set(hAx,'XAxisLocation','Top');
3 Comments
Sean de Wolski
on 4 Feb 2013
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.
Amelie
on 8 Apr 2024 at 19:22
Unfortunaltely, I have a similar problem.
I have a 2D plot and the plot is above the y axis so that the y axis line and the y ticks are not visible. I used different variations of "...'YAxisLocation','Top');" that were recommended in the forum, but all of them result in the Error message
"Error setting property 'YAxisLocation' of class 'Axes':
'top' is not a valid value. Use one of these values: 'left' | 'right' | 'origin'."
or I don't see a difference at all. The command set(gca, 'Layer', 'top') works fine. Now the problem is that I need the grids in the background of the plot, which is why I'm using grid on. But with this command, I don't get the y-axis/yticks in the foreground without getting automatically also the grids in the foreground.
Can someone tell me, how I can get the y-axis/yticks in the foreground but grids in the background?
Thank you very much for your help!
0 Comments
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!