r - Get rid of anomaly appearing in the colour legend (ggplot2) -
i have following plot:
you can notice in colour scale, first item (lte only: red-dashed line), there anomaly in dashed line. somehow line gets thinner before actual whitespace.
this anomaly disappears when don't plot data of blue color:
note dashed line looks ok now.
i use following code plot data:
ggplot() + stat_summary( data = cellblocksutilizationul_lteonly, aes(x=roundedrealnumvehicles/2, y=(value), colour=as.factor(1), lty=as.factor(1) ) , fun.y=mean, geom="line", size=1 ) + stat_summary( data = cellblocksutilizationul_clust, aes(x=roundedrealnumvehicles/2, y=(value), colour=as.factor(2), size=as.factor(clusteringdistance), lty=as.factor(2) ) , fun.y=mean, geom="line", alpha=0.80 ) + scale_linetype_manual(values = c(2,1) , name ="protocol\ntype" , labels=c("lte only", "lte4v2x")) + scale_color_manual(values = mycolors , name ="protocol\ntype" , labels=c("lte only", "lte4v2x")) + scale_size_manual(values = c(0.4, 0.7, 1.2, 2, 3, 4, 5) , name = "clustering\ndistance (m)" , labels=c("100", "200", "300", "400", "500", "550", "600"), guide = guide_legend(override.aes = list(colour = mycolors[2])) )
i can't explain cause of problem (it seems in legend 2 types of sizes plotted) can remove effect override.aes=
, setting size=
inside color scale.
+ scale_color_manual(values = c("red","blue") , name ="protocol\ntype" , labels=c("lte only", "lte4v2x"), guide = guide_legend(override.aes = list(size = 1))) +
Comments
Post a Comment