How to make only x-axis invisible (y-axis stays visible)?
1,211 ビュー (過去 30 日間)
回答 (11 件)
Muhammad Shah 2018 年 12 月 17 日
This Question is posted in 2013, but still last week got more than a thousand views, and I also needed this info, and I got very helpful information in this post, but surprizingly later I got an other solution in Matlab documentation and that was not yet here, and it is probably the smalest code, and I tested it and it worked nice, so I decided to addd it, here it is:
axis off ;
And thats it your axes are gone.
Johann Riemensberger 2016 年 10 月 27 日
works for me Bests Johann
Wayne King 2013 年 5 月 23 日
without seeing your code, a simple way is just to set the 'xtick' property to 
John Barber 2013 年 5 月 24 日
This solution might be overkill, but you can get that effect with my File Exchange program 'oaxes', available here: http://www.mathworks.com/matlabcentral/fileexchange/30018. The following will show only a y axis at the left edge of the plot:
oa = oaxes;
oa.XAxisLine = 'off';
oa.XLabel = '';
oa.YLabel = '';
oa.Arrow = 'off';
oa.Origin = [-Inf -Inf 0];
% If you want the normal y label to be visible:
ylabel('my y axis...')
This should get you close to what you are looking for. The oaxes documentation will give you more information about the properties used in the example above, including an explanation of the difference between the oaxes 'YLabel' property which is set to empty above, and the parent axes' 'YLabel' text object. The main difference in appearance I am getting is that the oaxes ticks are bidirectional (they extend out on both sides from the axes line), while a normal axes has ticks that only extend to one side. Currently, there is no way to change this in oaxes, but I might add it in a future release.
Martin 2016 年 3 月 24 日
I solved something similar that way:
Steven Lord 2023 年 11 月 27 日 14:19
This wasn't an option when the question was originally asked, but now you can change the Visible property of the appropriate ruler object that is part of the axes. Compare the axes without the ruler being changed:
ax = axes;
with one that does have the ruler turned off.
ax2 = axes;
% Get the ruler for the X axis
x = ax2.XAxis;
% Make it invisible
x.Visible = 'off';