I also tried uistack(axisHandle,'top') , but it seems to be for other things and not applicable to this.
How to prevent plotted contents to spill outside of the axes lines
조회 수: 38 (최근 30일)
이전 댓글 표시
Using
set(gca, 'Layer', 'top')
I end up with this:
Is there a way to completely hide plotted contents that appear beyond the axes?
댓글 수: 4
Yazan
2021년 8월 8일
The property SizeData of a scatter plot is related to the area of the marker. So assuming you specify a circular marker, Matlab will plot circles centered at the data with a radius that can be computed from SizeData. So, for each data point, find the radius of the circular marker, compute the edge points locations (horizontal and vertical extensions of the marker), see if they exceeded the axis limits and discard the data point if so. This is unnecessarily complex in my opinion given that you just need to resize the axes to solve the issue.
답변 (2개)
DGM
2021년 8월 8일
편집: DGM
2021년 8월 8일
One would think that the 'clipping' property of the axes object would take care of that, but I guess not.
Oof:
I don't know if that's a very practical approach, especially for as many markers as you have. It might be better to just adjust your axes limits a bit instead.
댓글 수: 0
Alexandra Molcanova
2024년 5월 4일
this worked for me:
set(gca,'ClippingStyle','rectangle');
hope it helps :)
댓글 수: 1
DGM
2024년 5월 4일
Interesting.
% some fake data
x = rand(100,1);
y = rand(100,1);
% it doesn't seem to work with scatter() objects
scatter(x,y,500,'filled')
set(gca,'ClippingStyle','rectangle');
grid on
% but it does work when using plot()
figure
plot(x,y,'.','markersize',80)
set(gca,'ClippingStyle','rectangle');
grid on
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!