# Install packages
if (!requireNamespace("data.table", quietly = TRUE)) {
install.packages("data.table")
}
if (!requireNamespace("jsonlite", quietly = TRUE)) {
install.packages("jsonlite")
}
if (!requireNamespace("echarts4r", quietly = TRUE)) {
install.packages("echarts4r")
}
if (!requireNamespace("echarts4r.assets", quietly = TRUE)) {
remotes::install_github("JohnCoene/echarts4r.assets")
}
# Load packages
library(data.table)
library(jsonlite)
library(echarts4r)
library(echarts4r.assets)Custom Icon Scatter
Note
Hiplot website
This page is the tutorial for source code version of the Hiplot Custom Icon Scatter plugin. You can also use the Hiplot website to achieve no code ploting. For more information please see the following link:
A scatter plot with customizable icons.
Setup
System Requirements: Cross-platform (Linux/MacOS/Windows)
Programming language: R
Dependent packages:
data.table;jsonlite;echarts4r;echarts4r.assets
sessioninfo::session_info("attached")β Session info βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
setting value
version R version 4.5.2 (2025-10-31)
os Ubuntu 24.04.3 LTS
system x86_64, linux-gnu
ui X11
language (EN)
collate C.UTF-8
ctype C.UTF-8
tz UTC
date 2026-01-17
pandoc 3.1.3 @ /usr/bin/ (via rmarkdown)
quarto 1.8.27 @ /usr/local/bin/quarto
β Packages βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
package * version date (UTC) lib source
data.table * 1.18.0 2025-12-24 [1] RSPM
echarts4r * 0.4.6 2025-09-11 [1] RSPM
echarts4r.assets * 0.0.1 2025-11-02 [1] Github (JohnCoene/echarts4r.assets@77b1fe0)
jsonlite * 2.0.0 2025-03-27 [1] RSPM
[1] /home/runner/work/_temp/Library
[2] /opt/R/4.5.2/lib/R/site-library
[3] /opt/R/4.5.2/lib/R/library
* ββ Packages attached to the search path.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Data Preparation
# Load data
data <- data.table::fread(jsonlite::read_json("https://hiplot.cn/ui/basic/custom-icon-scatter/data.json")$exampleData$textarea[[1]])
data <- as.data.frame(data)
# 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