How to plot a subset of x,y with group g according to fourth column
조회 수: 3 (최근 30일)
이전 댓글 표시
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)
댓글 수: 0
답변 (1개)
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')
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!