How to remove some xticklabels (but still keeping all the xticks)?
조회 수: 2 (최근 30일)
이전 댓글 표시
How can I remove some xticklabels, but still keeping all the xticks?
Let's consider the following example:
x = 1:100;
y = exp(-0.1*x);
plot(x,y)

I want to remove the xticklabels corresponding to "0", "10", "20", "30", getting the following plot:

How can I do it?
I tried the following, without success:
ax = gca;
ax.XTickLabel(1:4) = '';
댓글 수: 0
채택된 답변
Voss
2024년 10월 29일
x = 1:100;
y = exp(-0.1*x);
plot(x,y)
ax = gca;
ax.XTick = 0:10:100;
ax.XTickLabels(1:4) = {''};
댓글 수: 0
추가 답변 (1개)
Steven Lord
2024년 10월 29일
x = 1:100;
y = exp(-0.1*x);
plot(x,y)
xticks(0:10:100)
xl = xticklabels;
xl(1:2:end) = {''}; % Replace every other label
xticklabels(xl)
참고 항목
카테고리
Help Center 및 File Exchange에서 Labels and Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
