How to change the Xtick direction of ONLY one of the two (top or bottom) X-axis lines ?
조회 수: 25 (최근 30일)
이전 댓글 표시
The following example shows two thick X-axis lines, one at the bottom and one at the top.
I would like to set the "TickDirection" as "Out" for the bottom X-axis line, and still keep the "TickDirection" as "In" for the top X-axis line.
How to do it?
% my plot
figure
plot(1:9)
% properties
ax = gca;
xax = ax.XAxis;
set(xax,'TickDirection','out')
set(xax,'TickLength',[0.03, 0.01])
set(xax,'Fontsize',20,'FontWeight','Bold','LineWidth',2);
댓글 수: 0
채택된 답변
dpb
2023년 3월 16일
% my plot
figure
plot(1:9)
% properties
hAx1 = gca;
hAx1.XAxis.TickDirection='out';
hold on
hAx2=axes('Position',hAx1.Position,'Color','none');
hAx2.XAxisLocation='top';
hAx2.YAxis.Visible='off';
hAx2.XAxis.TickDirection='in';
And you see you still have the ticks on the opposite side of each the X- and Y- axes. HG2 (Handle Graphics 2) doesn't have the granularity to control the tick marks individually; either they show if 'Box' is 'on' or they don't if 'off'.
You would have to draw either ticks or the outer box manually to create the effect you're after, unfortunately.
댓글 수: 5
dpb
2023년 3월 17일
The bowels are deeply complicated, indeed...those articles are quite old by now, of course, and most of the glitches have been resolved and TMW has continued to improve performance since the initial release.
The more frustrating part (to me, at least) is the trend towards releasing special-purpose <"Standalone Visualizations"> and making more of the properties in other base function plots hidden so that it takes a lot of "handle-diving" to find the necessary pieces-parts to be able to make oftentimes quite normal customizations of the base figure appearance.
I see no justification for doing this; while it can be nice to have the easy-to-use version that makes all these assumptions about what the user wants, and those may be adequate for the majority of the need, as a general-purpose programming language and research tool, making it difficult to customize these for a particular purpose simply puts roadblocks in the way of the serious user and wastes their time doing trivial customizations instead of real research/productive work.
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Axis Labels에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!