stormhz 发表于 2016-9-27 22:22 
你先把图画成自己满意的样子,最后对应图去调整图例。
现在出现两个问题。一个是我加入你给我的代码到中间位置,产生线的后面。如果我运行“g <- g + scale_linetype_discrete( guide = FALSE )
g <- g + scale_shape_discrete( guide = FALSE )”
代码如下:
g <- ggplot()
g <- g + geom_line ( data = df, aes( x, y, color = type, linetype = type, stat = 'identity') )
g <- g + geom_point( data = df, aes( x, y, color = type, shape = type ) ,size = 3 )
g <- g + scale_linetype_manual(values = c( 6,6,6,6,6,6))
g <- g + scale_shape_manual(values = c( 6,6,6,6,6,6))
g
g <- g + geom_point( data = df2, aes( x, y, color = hh ), size = 3 )
g <- g1 + scale_color_manual(values = c( "red", "red", "red", "blue", "blue", "blue","red", "blue"))
g <- g + scale_linetype_discrete( guide = FALSE )
g <- g + scale_shape_discrete( guide = FALSE )
g <- g + guides( colour = guide_legend( override.aes =
list(linetype=c(6,6,6,6,6,6,0,0), shape=c(6,6,6,6,6,6,1,16))) )
g
如图,只有图例发生变化。
g <- g + scale_linetype_discrete( guide = FALSE )
g <- g + scale_shape_discrete( guide = FALSE )
如果我将上两句去掉。报错,并且有两个图例。
还有个问题是,我想区分,两个点,空心点,实心点。如何在图中也区分。
谢谢啦。。。。。