9

I want to make some symbols in a figure bigger than the others. I found one solution, scale_size_manual, but it doesn't seem to have any impact.

Perhaps related, I also want to change the order of items in the legend. Again, the solution I found, guides(fill = guide_legend(reverse=TRUE), doesn't do anything.

#Fake data for this example
names <- c(rep("Other",8),rep("Porcupines",4),rep("Vipers",4), rep ("Pigs", 4))
rates <- runif(20, min=0, max=2)
sizes <- runif (20, min=0.1, max=5)
data <- data.frame (names, rates,sizes)

ggplot(data, aes(x=rates, y=sizes, group=names))+
    theme_classic(base_size = 14, base_family = "") +
    geom_point (aes(colour = names))+
    scale_colour_manual("Animal",values=c("blue","red", "green", "#0099FF"))+ 
    xlab ("Size")+
    ylab ("Rate")+
    scale_size_manual (values= c(1,2,2,2))+
    guides(fill = guide_legend(reverse=TRUE))

As mentioned above, the last two lines don't seem to be doing anything. Why not? Is there another way to change the symbol size of just some of the data (to make those points stand out)?

joran
  • 169,992
  • 32
  • 429
  • 468
David kirchman
  • 91
  • 1
  • 1
  • 2

1 Answers1

23

I think you need to add size as an aethetic. Try aes(x=rates, y=sizes, group=names, size=names) and you'll see scale_size_manual() kick in.

Andrew
  • 9,090
  • 8
  • 46
  • 59
  • 1
    A belated "thanks". Adding size did the trick (it made some of the symbols bigger, which is what I wanted), but it created another problem. There are two legends, my original one (titled "Animal") with the right colors, although not the right symbol size (which is okay) and another (titled "names") with the same black symbols but with the right size. I need to think about how to solve the new problem – David kirchman Feb 23 '15 at 16:40