Two colour scatter plot in R or in python
python, r, scatter-plot
Solution
You already have a logical test that works to your satisfaction. Just use it in the color spec to text:
text(outliers[,2], outliers[,3],labels=outliers[,1],cex=0.50,
col=c("blue", "green")[
which(2^(data[,2]-data[,3]) >= 4 , 2^(data[,2]-data[,3]) <=0.25)] )
It's untested of course because you offered no test case, but my reasoning is that the `which()` function should return 1 for the differences >= 4, and 2 for the ones <= 0.25, and integer(0) for all the others and that this should give you the proper alignment of color choices with the 'outliers' vector.
Problem
I have a dataset of three columns and n number of rows. column 1 contains name, column 2 value1, and column 3 value2 (rank2). I want to plot a scatter plot with the outlier values displaying names. The `R` commands I am using in are: ``` tiff('scatterplot.tiff') data<-read.table("scatterplot_data", header=T) attach(data) reg1<-lm(A~B) plot(A,B,col="red") abline(reg1) outliers<-data[which(2^(data[,2]-data[,3]) >= 4 | 2^(data[,2]-data[,3]) <=0.25),] text(outliers[,2], outliers[,3],labels=outliers[,1],cex=0.50) dev.off() ``` and I get a figure like this: What I want is the labels on the lower half should be of one colour and the labels in upper half should be of another colour say green and red respectively. Any suggestions, or adjustment in the commands?