Group Bubble

Authors

[Editor] Hu Zheng;

[Contributors]

Setup

  • System Requirements: Cross-platform (Linux/MacOS/Windows)

  • Programming language: R

  • Dependent packages: ggplot2

# Install packages
if (!requireNamespace("ggplot2", quietly = TRUE)) {
  install.packages("ggplot2")
}

# Load packages
library(ggplot2)

Data Preparation

# Load data
data <- read.delim("files/Hiplot/081-group-bubble-data.txt", header = T)

# View data
head(data)
  Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1          5.1         3.5          1.4         0.2  setosa
2          4.9         3.0          1.4         0.2  setosa
3          4.7         3.2          1.3         0.2  setosa
4          4.6         3.1          1.5         0.2  setosa
5          5.0         3.6          1.4         0.2  setosa
6          5.4         3.9          1.7         0.4  setosa

Visualization

# Group Bubble
p <- ggplot(data = data, aes(x = Sepal.Length, y = Sepal.Width, 
                             size = Petal.Width, color = Species)) +
  geom_point(alpha = 0.7) +
  scale_size(range = c(1, 4)) +
  scale_color_manual(values = c("#e04d39","#5bbad6","#1e9f86")) +
  theme_bw()

p
FigureΒ 1: Group Bubble