[R] disturbed legend in ggplot2

Troels Ring tring at gvdnet.dk
Wed Sep 27 09:38:43 CEST 2017


Hi Ulrik - thanks a lot for pointing out this blunder - now it is fine!

Best wishes

Troels


Den 27-09-2017 kl. 09:31 skrev Ulrik Stervbo:
> Hi Troels,
>
> Try to move the size argument out of the aesthetic.
>
> Best wishes,
> Ulrik
>
> On Mi., 27. Sep. 2017, 08:51 Troels Ring <tring at gvdnet.dk> wrote:
>
>> Dear friends - below is a subset of a much larger material showing two
>> ways of generating two "lines". The intention is to have the colour
>> reflect a variable, pH, but the legend is disturbed. The little part
>> marked "3" above the colour scale is unwelcome. Why did it appear? How
>> could I avoid it?
>>
>> I'm on Windows 7, R version 3.4.1 (2017-06-30) -- "Single Candle"
>>
>> All best wishes
>>
>> Troels Ring
>> Aalborg, Denmark
>>
>> library(ggplot2)
>> DF1 <-
>> structure(list(P = c(0, 0.00222222222222222, 0.00444444444444444,
>> 0.00666666666666667, 0.00888888888888889, 0.0111111111111111,
>> 0.0133333333333333, 0.0155555555555556, 0.0177777777777778, 0.02,
>> 0, 0.00222222222222222, 0.00444444444444444, 0.00666666666666667,
>> 0.00888888888888889, 0.0111111111111111, 0.0133333333333333,
>> 0.0155555555555556, 0.0177777777777778, 0.02), pH = c(12.3979595548431,
>> 12.3129161148613, 12.2070984076445, 12.0669463736967, 11.8586790792785,
>> 11.4437319273717, 7.64497330556925, 6.98905682614207, 6.63520883742788,
>> 6.3229313658492, 12.176061323132, 12.0234712172719, 11.7861230637902,
>> 11.2219147985144, 7.14240749824074, 6.53119941380901, 5.95522932117427,
>> 3.25184520894594, 2.55614400932465, 2.30097494287507), BC =
>> c(0.0576574111386315,
>> 0.047331331067055, 0.037206026657832, 0.0268607893098731,
>> 0.0166183791472022,
>> 0.00639593998967551, 0.00335972794444094, 0.00854377959176608,
>> 0.00987464693654883, 0.00863636089604445, 0.0343718830720469,
>> 0.0242985554593397, 0.0140710602077036, 0.00383913993097999,
>> 0.00439784065436743, 0.00582135949288444, 0.00336240952299985,
>> 0.00129948001017736, 0.00640073762860721, 0.0115158433720248),
>>       SID = c(25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 15, 15, 15,
>>       15, 15, 15, 15, 15, 15, 15)), .Names = c("P", "pH", "BC",
>> "SID"), row.names = c(NA, -20L), class = "data.frame")
>>
>> df1 <- subset(DF1,SID==25)
>> df2 <- subset(DF1,SID==15)
>> v <- ggplot()
>> v <- v + geom_line(data=df1, aes(x=P, y=BC,col=pH,size=3))
>> v1 <- v + geom_line(data=df2, aes(x=P, y=BC,col=pH,size=3))
>>
>> v <- ggplot()
>> v <- v + geom_line(data=DF1, aes(x=P, y=BC,group=SID,col=pH,size=3))
>>
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list