小编use*_*455的帖子

使用ggplot2的气泡图

我需要创建一个类似于此的气泡图:

我曾经 ggplot2使用这篇文章中的代码创建一个单面气泡图。

这在右侧创建了 y 轴和 x 轴,但我需要在两侧都有 x 轴。有什么建议?

这是我的代码:

grid <- read.csv("data.csv", sep=",")

grid$Variability <- as.character(grid$Variability)
grid$Variability <- factor(grid$Variability, levels=unique(grid$Variability))

grid$Research <- as.character(grid$Research)
grid$Research <- factor(grid$Research, levels=unique(grid$Research))

grid$Contribution <- as.character(grid$Contribution)
grid$Contribution <- factor(grid$Contribution, levels=unique(grid$Contribution))

library(ggplot2)
ggplot(grid, aes(Research, Variability))+
    geom_point(aes(size=sqrt(grid$CountResearch*2 /pi)*7.5), shape=21, fill="white")+
    geom_text(aes(label=CountResearch),size=4,hjust=0.5,vjust=0.5)+
    scale_size_identity()+
    theme(panel.grid.major=element_line(linetype=2, color="black"),
          axis.title.x=element_text(vjust=-0.35,hjust=1),
          axis.title.y=element_text(vjust=0.35), 
          axis.text.x=element_text(angle=0,hjust=0.5,vjust=0.5) )    
Run Code Online (Sandbox Code Playgroud)

数据样本:

structure(list(Variability = structure(c(1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 
2L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L), .Label = …
Run Code Online (Sandbox Code Playgroud)

plot r ggplot2

3
推荐指数
1
解决办法
2051
查看次数

标签 统计

ggplot2 ×1

plot ×1

r ×1