为什么我不能用ggplot2改变点的形状?

时间:2014-08-23 06:27:03

标签: r ggplot2

我想使用ggplot2来确定我的情节中三种点的形状。但是,无论我如何更改形状编号,它都不起作用,点的形状会不断自动设置。

这是我的代码(形状编号在第一行):

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

1 个答案:

答案 0 :(得分:2)

要更改点的形状,您需要使用scale_shape_manual()并为参数values=提供所需的形状。

+ scale_shape_manual(values=c("min"=1,"max"=2,"mean"=3))