Question: High light specific dot in scatterplot
0
gravatar for Nitin
5.6 years ago by
Nitin150
Germany
Nitin150 wrote:

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 dot 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)

 

Data<-read.csv("table.csv",header=TRUE,sep=",")

 

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 • 4.8k views
ADD COMMENTlink modified 5.5 years ago by Biostar ♦♦ 20 • written 5.6 years ago by Nitin150

Possible cross-post: http://stackoverflow.com/questions/27087558/highlight-specific-dot-in-ggplot2

ADD REPLYlink written 5.6 years ago by Alex Reynolds30k

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

ADD REPLYlink written 5.6 years ago by Devon Ryan95k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1181 users visited in the last hour