Plotting, how can I stop fill hiding the tickmarks?

조회 수: 3 (최근 30일)
dormant
dormant 2025년 5월 12일
댓글: dormant 2025년 5월 15일
I'm making a complex plot, and using the fill command to create a patchy background for the plot.
But I don''t seem to be able to do it in a way that retains the tick marks. They always get covered by the filled area.
Here is an example:
figure;
X = 0:20;
Y = sin( X/10 );
plot( X, Y, 'ko' );
hold on;
Xfill = [ 10 20 20 10 10];
Yfill = [-1 -1 1 1 -1];
axf = fill( Xfill, Yfill, 'w' );
uistack(axf,'bottom');
Which produces this plot.
How can I keep my tick marks (without moving them to the outside)?

채택된 답변

Matt J
Matt J 2025년 5월 12일
편집: Matt J 2025년 5월 12일
X = 0:20;
Y = sin(X/10);
plot(X, Y, 'ko'); hold on;
% Draw white patch (e.g., to "highlight" a region)
Xfill = [10 20 20 10 10];
Yfill = [-1 -1 1 1 -1];
h = fill(Xfill, Yfill, 'w'); % Opaque white patch
% Send patch to bottom so axes ticks/labels are on top
uistack(h, 'bottom');
set(gca, 'Layer', 'top'); % Ensures ticks are drawn on top
xticks(0:2:20)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Polygons에 대해 자세히 알아보기

태그

제품


릴리스

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by