필터 지우기
필터 지우기

Changing colors for findpeaks function

조회 수: 12 (최근 30일)
Pushti Shah
Pushti Shah 2022년 9월 8일
댓글: dpb 2022년 9월 10일
I wanted to graph male and female find peaks graphs together and have the graphs be blue and pink. Is there any way for me to change the colors in the code itself?
[numRows,~] = size(male_data);
x = numRows;
[pk,loc] = findpeaks(male_data,x);
plot(x, y, '-', pk, loc, 'Color', [0.9414, 0.5664, 0.6055]); % is there any way to control color?
That was as close as I got but it is giving me an error. Male_data is an array.

답변 (1개)

dpb
dpb 2022년 9월 8일
Sure, but not with the triplet form of plot to use anything except the named colors...
hL=plot(x,y,'-', pk,loc,'*'); % plot the two, default color first, save line handles
set(hL,'Color',[0.9414, 0.5664, 0.6055]) % now set the color triplet
  댓글 수: 2
Pushti Shah
Pushti Shah 2022년 9월 10일
편집: Pushti Shah 2022년 9월 10일
[numRows,~] = size(male_trans);
x = numRows;
y = (mean(male_trans(x)));
[pk,loc] = findpeaks(y,x);
hL = plot(x, y, '-', pk, loc);
set(hL,'Color',[0.4688, 0.6563, 0.9375])
^ I have this written but for some reason there's an error at the [pk,loc]
saying:
Error using findpeaks>parse_inputs (line 206)
Data set must contain at least 3 samples.
Error in findpeaks (line 136)
= parse_inputs(isInMATLAB,Yin,varargin{:});
dpb
dpb 2022년 9월 10일
Well, yes,..when you wrote
[numRows,~] = size(male_trans);
x = numRows;
y = (mean(male_trans(x)));
numRows is a single value and so, then, will be male_trans(x)) and even if you wrote male_trans(x,:)) to take the whole row, then mean(male_trans(x)) would turn it back into a single value anyway. Can't find a peak with only one point...

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by