R - 符号;缩放气泡图传奇以绘制圆圈

时间:2017-09-25 20:27:08

标签: r

我创建了一个漂亮的气泡图,显示了使用此代码在特定纬度/经度坐标处的样本大小;

plot(coastlineWorldFine, clatitude=40.438377, clongitude=-71.476331, span=450) + symbols(bubb$start_lon, bubb$start_lat, circles=bubb$samples, inches=.15, bg="red", add=T)

我似乎无法通过适当缩放其圆圈大小来覆盖我的数据集中的范围,特别是在bubb $ samples中

关于我可以尝试的代码的任何想法?

编辑,我的数据看起来像这样

    structure(list(start_lat = c(39.267222, 39.32858708, 39.70921237, 
39.90807768, 39.99021857, 39.97938316), start_lon = c(-72.828056, 
-72.76148717, -72.56777679, -72.10185788, -72.03564072, -72.02490474
), samples = c(48L, 41L, 32L, 32L, 23L, 24L)), .Names = c("start_lat", 
"start_lon", "samples"), row.names = c(NA, -6L), class = c("tbl_df", 
"tbl", "data.frame"))

1 个答案:

答案 0 :(得分:0)

这是一种方法:

library(oce)
library(ocedata)
library(tidyverse)
data("coastlineWorldFine")

bubb <- structure(list(start_lat = c(39.267222, 39.32858708, 39.70921237, 39.90807768, 39.99021857, 39.97938316),
  start_lon = c(-72.828056, -72.76148717, -72.56777679, -72.10185788, -72.03564072, -72.02490474), 
  samples = c(48L, 41L, 32L, 32L, 23L, 24L)), .Names = c("start_lat", "start_lon", "samples"), 
  row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"))

plot(coastlineWorldFine, clatitude=40.438377, clongitude=-71.476331, span=450)
points(bubb$start_lon, bubb$start_lat, cex=bubb$samples/5, pch = 21, col = "black", bg=alpha("red", 0.5))
legend("topright", legend = pretty(bubb$samples/5), pch = 21, pt.cex = 
    pretty(bubb$samples/5), x.intersp = 3, y.intersp = 2, bty = "n", col = "black", pt.bg=alpha("red", 0.5))

enter image description here