# 安装并加载所需的包
library(ggplot2)
# 创建示例数据
data <- data.frame(
x = 1:10,
y = 11:20,
z = 101:110,
color = paste0("R", 1:10)
)
# 绘制气泡图
ggplot(data, aes(x, y, z = z, color = color)) +
geom_point(size = 5) +
theme_minimal()
library(ggplot2)
data <- data.frame(
x = c(1, 2, 3, 4, 5),
y = c(5, 4, 3, 2, 1),
z = c(10, 20, 30, 40, 50)
)
ggplot(data, aes(x = x, y = y, size = z)) +
geom_point(alpha = 0.7) +
scale_size(range = c(1,10)) +
theme_minimal() +
labs(title = "气泡图示例", x = "横坐标", y = "纵坐标", size = "气泡大小")
开发语言:RStudio 2023.06.1 Build 524
微信Alt+A截屏工具