matlab - Scatter plot color thresholding -
i trying write script plot florescence intensity microscopy data scatter plot , threshold data based on cells respond greater amount in cfpmax
, plot these in green , cells not in red. when try plot this, unable assign proper colors points , end being blue , red. need each cell in image assigned 4 values, (3 values for each florescence channel , 1 value determine whether or not responded (green or red). wondering if possible assign proper color 4th column of matrix, or if going wrong way together. have attached code below.
mchr=csvread('data1.csv'); myfp=csvread('data2.csv'); mcfp=csvread('data3.csv'); cfpmax=(max(mcfp))'; mchmax=(max(mchr))'; yfpmax=(max(myfp))'; c=zeros(length(cfpmax)); i=1:length(c) if cfpmax(i)>40 c(i)='g'; %// green responders else c(i)='r'; %// red non-responders end end mm=horzcat(mchmax,yfpmax,cfpmax,c); scatter(mm(:,1),mm(:,2),100,mm(:,4),'filled','markeredgecolor',[0 0 0]) title('responders vs non-responders ') xlabel('[tf1]') %// x-axis label ylabel('[tf2]') %// y-axis label
as far can tell the documentation, input parameter c
(assuming scatter(x,y,a,c,...)
) can 1 of:
- a single character specifying colour e.g.
'g'
or'r'
. 1 single scalar colouring of points. - a single rgb triple colouring of points
[1,0,0]
red or[0,1,0]
green. - a 3 column matrix of rgb triples. want. demonstrate you.
- a 1 column matrix of numbers colour points according
colormap
. 1 work less explicitly. incidentally, guess option matlab though vector of characters was.
so in order create matrix of rgb triples can modify code be
c=zeros(length(cfpmax),3); = 1:length(cfpmax) if cfpmax(i)>40 c(i,:)=[0,1,0]; %// green responders else c(i,:)=[1,0,0]; %// red non-responders end end
however, away for
-loop in matlab , construct c
in vectorized approach using logical indexing:
c=zeros(length(cfpmax),3); c(cfpmax > 40, 2) = 1; %// green responders c(cfpmax <= 40, 1) = 1; %// red responders
this more idiomatic way in matlab.
Comments
Post a Comment