0

I want to specific the shape of three kinds of points in my plot using ggplot2. However, no matter how I change the shape numbers, it doesn't work, the shapes of points been constantly set automatically.

Here is my code (the shape numbers are in the first line):

shape <- c("min"="1","max"="2",mean="3")

fill <- c("Rate"="#25c25b")

ggplot (data, aes(x=order))+

   geom_rect(aes(xmin=order-0.1, xmax=order+0.1, ymin = min, ymax=max), alpha=0, color="black")+

   geom_bar(aes(y=rate, fill="Rate"),stat="identity", alpha=0.3, width=0.5)+

   geom_point(aes(y=min, shape="min"), size=5)+ 

   geom_point(aes(y=mean, shape="mean"), size=5)+

   geom_point(aes(y=max, shape="max"), size=5)+

   labs(shape = "F0", fill = "Rate")
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
Ping Tang
  • 415
  • 1
  • 9
  • 20
  • 1
    Can you provide a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)? – Jota Aug 23 '14 at 06:38

1 Answers1

3

To change the shape of points you need to use scale_shape_manual() and provide argument values= with shapes you need.

+ scale_shape_manual(values=c("min"=1,"max"=2,"mean"=3))
Didzis Elferts
  • 95,661
  • 14
  • 264
  • 201
  • Oh! It works! Thank you! But why I can change color using a data collection? e.g. : The first answer of the question below: http://stackoverflow.com/questions/17148679/ggplot2-need-to-construct-a-manual-legend-for-complicated-plot – Ping Tang Aug 23 '14 at 07:00
  • Also in the answer you linked they use `scale_color_manual()` and then provide colors. – Didzis Elferts Aug 23 '14 at 07:54