📜  R编程中创建点图——dotchart()函数

📅  最后修改于: 2022-05-13 01:55:17.207000             🧑  作者: Mango

R编程中创建点图——dotchart()函数

R语言中的dotchart()函数用于创建指定数据的点图。点图定义为用于绘制克利夫兰点图的图。

示例 1:

# Dot chart of a single numeric vector
dotchart(mtcars$mpg, labels = row.names(mtcars),
         cex = 0.9, xlab = "mpg")

输出:

示例 2:

# Plot and color by groups cyl
grps <- as.factor(mtcars$cyl)
my_cols <- c("blue", "darkgreen", "orange")
dotchart(mtcars$mpg, labels = row.names(mtcars),
         groups = grps, gcolor = my_cols,
         color = my_cols[grps],
         cex = 0.9,  pch = 22, xlab = "mpg")

输出: