High light specific dot in scatterplot
0
0
Entering edit mode
8.2 years ago
Nitin ▴ 170

Hello,

I am trying to plot a scatterplot using ggplot2 in R. I have data as follows in csv format

      A                B
-4.051587034     -2.388276692
-4.389339837     -3.742321425
-4.047207557     -3.460923901
-4.458420756     -2.462180905
-2.12090412      -2.251811973


I want to high light specific two dots with corresponds -2.462180905 and -3.742321425 and to in plot with different colors. Which should to different than default colors in the plot. I tried following code

library(ggplot2)
library(reshape2)
library(methods)
library(RSvgDevice)

data1<-Data[,-4]

plot2<-ggplot(data1,aes(x = A, y = B)) + geom_point(aes(size=2,color=ifelse(y=-2.462180905,'red')))
graph<-plot2 + theme_bw()+opts(axis.line = theme_segment(colour = "black"),panel.grid.major=theme_blank(),panel.grid.minor=theme_blank(),panel.border = theme_blank())
ggsave(graph,file="figure.svg",height=6,width=7)


It is not working the way I want. It gives all dots in same color. Can any body please help

Thanks
Sai

R • 6.5k views
0
Entering edit mode
0
Entering edit mode

ifelse has no clue what y is. Try B and see if that fixes things.