How to plot a subset of x,y with group g according to fourth column

조회 수: 3 (최근 30일)
Clara Woodie
Clara Woodie 2019년 3월 21일
댓글: Clara Woodie 2019년 3월 22일
I have four columns in "data": day, bottle, species, finalC. I am trying to plot finalC as a function of day by group species, but I ONLY want to plot the bottles that are named "BETC". I cannot find anything to help me. I have tried this which doesn't work:
x = data.day
y = data.finalC
g = {data.bottle=="BETC", data.species}
gscatter(x,y,g)

답변 (1개)

KSSV
KSSV 2019년 3월 22일
Let day, bottle, species, finalC be your data. I assume them to be columns and bottle is a cell array of strings.
% GEt indices of BETC
idx = contains(bottle,'BETC') ; % if constains not available, use strcmp.
scatter(day(idx),species(idx),10,finalC(idx),'filled')
  댓글 수: 1
Clara Woodie
Clara Woodie 2019년 3월 22일
Thank you for your reply. It did not work however. Bottle is a column in the data file and each row corresponds to an ID such as: BETC, BET, ETC, etc... I want to plot the data only when the rows of this column bottle say BETC. Do you have any more advice? Thanks.

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

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by