how to display only bottom and left axis lines, but not right and top axis lines?

119 次查看(过去 30 天)
Matlab plots by default draw 4 lines with tick marks on left, bottom, right and top. I wanted to create 2D plots similar to those in excel, in which only the bottom and left have axis and tick mark, while the line and ticks on right and top are not displaying. I tried set 'Box' to be 'off', but does not seem to work. Any suggestions on how to do this? thank you.

采纳的回答

Jessica Lam
Jessica Lam 2012-1-31
  1 个评论
Jun
Jun 2012-1-31
It worked for me. Thank you so much.
Below is my code, which I hope will be helpful for some in the community.
figure,hist(random('Normal',0,1,1,1000),30)
set(gca,'Visible','off')
axes('Position',get(gca,'Position'),...
'XAxisLocation','bottom',...
'YAxisLocation','left',...
'Color','none',...
'XTickLabel',get(gca,'XTickLabel'),...
'YTickLabel',get(gca,'YTickLabel'),...
'XColor','k','YColor','k',...
'LineWidth',2,...
'TickDir','out');

请先登录,再进行评论。

更多回答(2 个)

Andrew Hook
Andrew Hook 2018-10-31
set(gca,'box','off') works. Note the lower case 'box'.

Jewel Jubic
Jewel Jubic 2012-1-31
编辑:John Kelly 2014-6-12
Any more examples can you give...

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by