r - 有没有办法在 R 中制作气泡图,其中气泡接触并且一个轴代表值?
问题描述
我想创建一个气泡图,其中 x 轴和气泡的大小代表值,但 y 轴无关紧要。我还希望气泡不重叠,而是彼此相邻。本质上,我正在尝试复制此图表(只是气泡,而不是饼图):
有没有办法在 R 中做到这一点,最好使用 ggplot2?geom_jitter 并没有完全做到这一点,因为我无法让气泡可靠地触摸。ggrepel 目前没有积分解决方案:https ://github.com/slowkow/ggrepel/issues/20
还有其他想法吗?
编辑:这是一个示例数据集和我所做的一次尝试。此尝试使用 geom_jitter,但显然气泡没有像上面纽约时报示例中那样相互定位。
library(ggplot2)
seed(1)
bubble_data = data.frame(
variable = paste0("bubble_", 1:10),
x_value=runif(10),
size=runif(10)
)
bubble_data %>%
ggplot(aes(x = x_value, y = 1, size = size)) +
geom_point(position = position_jitter(seed = 1), alpha = 0.5) +
geom_text(aes(label = variable), position = position_jitter(seed = 1)) +
theme_void() +
theme(legend.position = "none")
解决方案
推荐阅读
- javascript - 如何从 JSON 数组中获取特定数据?
- scala - Scala - 超时重试HTTP请求
- amazon-web-services - 执行 Jenkins 文件时,'scp' 未被识别为内部或外部命令
- android - 当我在点击布局问题上设置:isEnabled:false 时,Nativescript 按钮在点击时显示文本背景颜色
- javascript - 在表格中获取图像时在图像标签中设置高度和宽度
- r - 汇总团队成员得分的平均分
- swift - Swift 4.2 - 类型附近的 __shared 属性
- ruby - regex match and split in ruby
- javascript - WooCommerce:在编辑订单上禁用日期
- regex - 我想知道如何在 Google Big 查询中执行 CONNECT BY REGEXP