フィルターのクリア

Is there a way to remove the ticks on the right and upper side when the box is on ?

137 ビュー (過去 30 日間)
Leo
Leo 2017 年 1 月 28 日
コメント済み: Dyuman Joshi 2023 年 12 月 26 日
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 件のコメント
Leo
Leo 2017 年 1 月 31 日
The problem is that the window is rescaled when the figure is saved as pdf. If you try to change the size of the window you will see that the axis do not meet at the edges.
My solution is to open the window with the same size as the exported plot.
set(gcf, 'Position', [0 0 width height])
Tiago Dias
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
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
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
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.

Hari Prasanth
Hari Prasanth 2018 年 6 月 27 日
Your solution worked for me as well. Thanks

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by