当我需要整数时,R ggplot图例给出小数

时间:2015-07-23 18:15:10

标签: r ggplot2 legend

我正在创建一个气泡图,我的所有值都是整数。但是,当代码运行时,图例比例给出了小数(即2.5,5,7.5,10)。我希望它是像2,5,8,11这样的整数。

这是我的代码:

x, y = 'a#','a#'
id(x) == id(y)
True

我已经制作了这个情节的多个版本,并且它们都默认为整数。出于某种原因,此特定版本的数据不会这样做。帮助

1 个答案:

答案 0 :(得分:6)

谢谢!那很有效。以下是我最终的代码:

ggplot() +
geom_path(data = usa, aes(x = long, y = lat, group = group)) + theme_general +
geom_point(data = CombinedStudentsUSA1, aes(x = Long, y = Lat, size = Number),     
color = "blue", shape=19, alpha=.5)+ scale_size_continuous(range = c(2, 4),  
breaks= c(2,4,6,8), name="Number of \nResponses")

http://i57.tinypic.com/291jfcl.jpg

enter image description here