How to plot a subset of x,y with group g according to fourth column
3 views (last 30 days)
Show older comments
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 Comments
Answers (1)
KSSV
on 22 Mar 2019
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')
See Also
Categories
Find more on Data Distribution Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!