【问题标题】:R - Symbols; scaling bubble plot legend to plot circlesR - 符号;缩放气泡图图例以绘制圆圈
【发布时间】:2017-09-25 20:27:08
【问题描述】:

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

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

【问题讨论】:

标签: r


【解决方案1】:

这是一种方法:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-05-17
    • 2022-07-12
    • 2021-12-13
    • 1970-01-01
    • 2014-08-16
    • 2017-04-09
    • 2022-08-14
    • 2018-05-03
    相关资源
    最近更新 更多