Custom Icon Scatter

Authors

[Editor] Hu Zheng;

[Contributors]

A scatter plot with customizable icons.

Setup

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

  • Programming language: R

  • Dependent packages: echarts4r; echarts4r.assets

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

# Load packages
library(echarts4r)
library(echarts4r.assets)

Data Preparation

# Load data
data <- read.delim("files/Hiplot/035-custom-icon-scatter-data.txt", header = T)

# convert data structure
draw_data <- data.frame(
  x = data[["mpg"]],
  y = data[["wt"]],
  size = data[["qsec"]]
  )
rm(data)

# View data
head(draw_data)
     x     y  size
1 21.0 2.620 16.46
2 21.0 2.875 17.02
3 22.8 2.320 18.61
4 21.4 3.215 19.44
5 18.7 3.440 17.02
6 18.1 3.460 20.22

Visualization

# Custom Icon Scatter
p <- draw_data |>
  e_charts(x) |>
  e_scatter(
    y,
    size,
    symbol = ea_icons("warning"),
    name = "warning"
    )

p
FigureΒ 1: Custom Icon Scatter