简体   繁体   中英

How to plot all the points in ggplot2?

I have a dataframe df and would like to make a point plot. I could not plot ( or show ) all the values as point ,; only 8 point are shown out of 20. I think, its because of overlapping Lat and Lon? Is there a way that i can show all the values plotted ie 20 point and not just 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 . Fiddle around with width and height for finer control.

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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM