Is there a way to remove the ticks on the right and upper side when the box is on ?
117 次查看(过去 30 天)
显示 更早的评论
Hello,
When the parameter "box on" is activated, I want to get the box around the plot without the ticks on the right and upper axes. I have the ticks in the outer direction and having them on the right and top side look really odd...
I tried creating another empty axis on top that cover the right and upper part but the scaling is really suboptimal when saving the figure:
box off
ax1 = gca;
ax2 = axes('Position', get(ax1, 'Position'), 'FontSize', 10,...
'Color','None','XColor','k','YColor','k', 'LineWidth', 1,...
'XAxisLocation','top', 'XTick', [],...
'YAxisLocation','right', 'YTick', []);
linkaxes([ax1, ax2])
Cheers,
Leo
3 个评论
Tiago Dias
2018-1-12
Hello, i want to my plot have the axes with a width of 2, and the middle lines (grid) to have a width of 0.5 for example is that possible?
because when I do hte code below, it changes both the 4 axis bottom top left right and also the middle lines.
bon on
ax = gca;
set(ax,'linewidth',1.5);
回答(4 个)
Michelle Wu
2017-1-31
Unfortunately, as of R2016b, it is not possible to configure the top and bottom as well as left and right ticks separately. "XTick" and "YTick" are axes properties, which only allow the ticks to be configured together. The workaround that you have in place right now seems to be the best way to get around this issue.
An enhancement request has been submitted to the development team at MathWorks.
SARA OUANES
2020-2-9
Dear Leo,
My answer comes late but I hope it would help others in the future.
To solve such a problem, you can keep Box in 'off' position and create two lines (one horizontal and the other vertical) to outline your plot box at limits.
figure
plot(1:11,1:11)
box off
xlim([0 14])
ylim([0 14])
line([0 14],[14 14],'Color','k')
line([14 14],[0 14],'Color','k')
Amin Rajabi
2018-1-11
Your code works very well, and thanks for that as I had the same problem and your code saved me a lot of time.
0 个评论
另请参阅
类别
在 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!