# Install packages
if (!requireNamespace("echarts4r", quietly = TRUE)) {
install.packages("echarts4r")
}if (!requireNamespace("echarts4r.assets", quietly = TRUE)) {
install_github("JohnCoene/echarts4r.assets")
}
# Load packages
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:
echarts4r
;echarts4r.assets
Data Preparation
# Load data
<- read.delim("files/Hiplot/035-custom-icon-scatter-data.txt", header = T)
data
# convert data structure
<- data.frame(
draw_data 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
<- draw_data |>
p e_charts(x) |>
e_scatter(
y,
size,symbol = ea_icons("warning"),
name = "warning"
)
p