0

I am trying to change the point size for NA values.

        ggplot(dataframe, aes(col1, col2)) + 
geom_text(aes(label=col4),size=0.5, hjust=0, vjust=0) +
geom_point(aes(color = col3), size=1)

This is what I get:

I need the grey colors (NA) to display smaller and in white color.

jl-blancopastor
  • 754
  • 5
  • 14
  • 1
    Please include a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) in your question. Note you will need to map a variable to `size` in order to use `scale_size_manual`. That means moving `size` inside `aes`. Once you do that, take a look at the documentation for `scale_size_manual` for examples on how to use it. – aosmith Sep 14 '16 at 15:29
  • I am trying to subsample my dataframe to give an appropriate reproducible example. But while I can run a plot with the full data I cannot with the subset. – jl-blancopastor Sep 15 '16 at 09:53

1 Answers1

0

A few ways to do this, the simplest might be to call geom_point twice, subsetting based on that column value.

library(ggplot2)
set.seed(12341234)
dataframe <- data.frame(col1 = rnorm(10, mean = 2, sd = 3),
                        col2 = rnorm(10, mean = 4, sd = 2),
                        col3 = c(rep("A", 4), rep("B", 4), NA, NA))

ggplot(dataframe[!is.na(dataframe$col3),], 
       aes(x = col1, 
           y = col2)) +  
  geom_point(aes(color = col3), 
             size = 4) + 
  geom_point(data = dataframe[is.na(dataframe$col3),], 
             color = "blue", 
             size = 8) + 
  scale_color_manual(breaks = c("A", "B"), 
                     values = c("black", "red"))

enter image description here

Note this will mess up the legend (if you need one).

Another option is to replace NA values with something like "NA".

Community
  • 1
  • 1
Eric Watt
  • 3,180
  • 9
  • 21