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

1 次查看(过去 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)

回答(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 中查找有关 Line Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by