[英]How to plot all the points in ggplot2?
I have a dataframe df
and would like to make a point plot. 我有一个数据框
df
,想做点图。 I could not plot ( or show ) all the values as point ,; 我无法绘制(或显示)所有值作为point; only 8 point are shown out of 20. I think, its because of overlapping Lat and Lon?
只有20分显示8分。我认为,是因为Lat和Lon重叠? Is there a way that i can show all the values plotted ie 20 point and not just 8 ?.
有没有一种方法可以显示所有绘制的值,即20点而不仅仅是8点? Thank you.
谢谢。
dput(df)
structure(list(Lat = c(55.5, 49.5, 49.5, 60, 58.5, 55.5, 54,
49.5, 55.5, 52.5, 58.5, 55.5, 55.5, 55.5, 55.5, 52.5, 55.5, 49.5,
49.5, 48, 58.5), Lon = c(-132, -126, -124.5, -139.5, -136.5,
-132, -129, -126, -132, -127.5, -136.5, -132, -132, -132, -132,
-127.5, -132, -126, -126, -123, -136.5), Value = c(169, 308,
178, 110, 224, 280, 212, 365, 224, 276, 121, 159, 166, 342, 96,
283, 51, 375, 198, 284, 201)), .Names = c("Lat", "Lon", "Value"
), row.names = c(168969L, 169011L, 169123L, 169285L, 169570L,
169611L, 169858L, 169905L, 170237L, 170263L, 170483L, 170496L,
170666L, 170684L, 170815L, 170834L, 170893L, 170916L, 171073L,
171093L, 171201L), class = "data.frame")
p <- ggplot() +
geom_point(data = df,aes(x = Lon, y = Lat, colour = Value))
p
They are indeed overlapping. 它们确实是重叠的。 Try using
position_jitter
. 尝试使用
position_jitter
。 Fiddle around with width
and height
for finer control. 摆弄
width
和height
以获得更好的控制。
library(ggplot2)
ggplot() + geom_point(data = df,aes(x = Lon, y = Lat, colour = Value),
position=position_jitter(width=1,height=.1))
library(ggplot2)
ggplot(data = df,aes(x = Lon, y = Lat, colour = Value)) +
geom_jitter()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.