필터 지우기
필터 지우기

How can I normalize one input for Patch across a subplot?

조회 수: 2 (최근 30일)
Kip Risch-Andrews
Kip Risch-Andrews 2022년 8월 1일
댓글: Kip Risch-Andrews 2022년 8월 3일
Hi there, I'm trying to use Patch to show areas of a graph where a certain event is occuring. What I want to do is have these bars show up on every figure in my subplot (which share the same x-axis), but scale the y-axis coordinates for each graph.
I was trying to use copyobj, but the maximum y-axis values are different for each part of the subplot. Here's the code for generating my patches currently - can I use 'Units','Normalized' or something similar for just the y values? Or do I have to manually put these patches into each figure
freeze_logger = [833 1394 10243 10807 19960 20528 29573 30135 38800 39362 48023 48584 57726 58292];
SEC2HRS = 2.7778e-04;
x_freeze = repelem(freeze_logger,2)*60*SEC2HRS;
y_freeze = repmat([-1e5 1e5 1e5 -1e5], 1,length(freeze_logger)/2);
freeze_patch = patch(x_freeze,y_freeze,'red','FaceAlpha',.3);

채택된 답변

Walter Roberson
Walter Roberson 2022년 8월 2일
Use coordinates -inf and +inf . Then you can copyobj . Then in the copied object you can use
max( min(YCoordinates, YUpperBound), YLowerBound )
to compute the new coordinates without needing any logical indexing or anything like that.
  댓글 수: 3
Walter Roberson
Walter Roberson 2022년 8월 3일
freeze_patch1 = copyobj(freeze_patch,ax1);
freeze_patch1.YData = max( min(freeze_patch1.YData, YUpperBound), YLowerBound );
Kip Risch-Andrews
Kip Risch-Andrews 2022년 8월 3일
Works perfectly, thank you so much for the help!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by