R中的什么图形类型可以通过填充圆圈来显示排名
What graph type in R can be used to show rankings by filling in circles
我正在尝试制作 'infographic' 简历,我想使用 R。
我创建了一个甘特图,现在想对我的技能进行排名。
我无法弄清楚哪种类型的图表会根据数字排名生成圆圈。这是我想要的示例。下面是示例数据。任何帮助表示赞赏
谢谢
dput(datAnal_skills)
structure(list(Type = c("Programming", "Programming", "Programming",
"Programming", "Analytics", "Analytics", "Analytics", "Analytics",
"Personal", "Personal", "Personal", "Personal"), Skill = c("R",
"Perl", "Python", "SQL", "Visualization", "Statistics", "Databases",
"Research Design", "Problem-solver", "Motivated", "Team player",
"Multi-tasker"), Of.5 = c(4.7, 4.5, 4, 4, 4.7, 4.5, 4.5, 4.5,
4.5, 4.5, 4.5, 4.5), Of.10 = c(9L, 8L, 8L, 8L, 9L, 9L, 8L, 8L,
9L, 9L, 8L, 8L)), class = "data.frame", row.names = c(NA, -12L
))
像这样:
library(ggplot)
ggplot(df, aes(x=Skill, y=Type))+
geom_point(aes(size=Of.10))+
coord_flip()
您可以先创建一个点网格,然后根据网格位置是否低于分数来为点着色。以下示例适用于 10 分制,因为 5 分制不是整数,不能很好地转换为项目符号。
library(ggplot2)
# df <- structure(...) # omitted for brevity
# For every skill, place 10 bullets
grid <- expand.grid(skill_id = seq_along(df$Skill), bullets = 1:10)
# Match skill name and score from original data
grid$score <- df$Of.10[grid$skill_id]
grid$skill <- df$Skill[grid$skill_id]
ggplot(grid, aes(factor(bullets), skill)) +
geom_point(aes(colour = bullets <= score), size = 3) +
scale_colour_manual(values = c("grey70", "grey30"),
guide = "none")
好主意。
这是我想出的。
datAnal_skills$Type<-factor(datAnal_skills$Type,levels=c("Programming","Analytics","Personal"))
#
ggplot(datAnal_skills, aes(x = Of.10, y = reorder(Skill,Of.10))) +
geom_point(size = 3) + # Use a larger dot
facet_wrap(~Type,scales = "free_y")+
xlim(c(0,10))+
ylab("")+
xlab("")+
theme_bw() +
theme(
axis.text.x=element_blank(),
panel.grid.major.x = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.major.y = element_line(colour = "grey60", linetype = "dashed")
)
这是清理主题选项的尝试。
df = df%>%
mutate(
score = round(Of.5)
) %>%
select(Type, Skill, score)
df = df %>%
expand(nesting(Type, Skill), score = 1:5) %>%
left_join(mutate(df, achieved = TRUE)) %>%
group_by(Type, Skill) %>%
mutate(achieved = lag(cumsum(coalesce(achieved, FALSE)) < 1, default = TRUE))
ggplot(df, aes(x = score, y = Skill, color = achieved)) +
geom_point(size = 2) +
facet_grid(rows = vars(Type), scales = "free") +
labs(x = "", y = "") +
scale_x_continuous(expand = expansion(add = 0.5)) +
scale_color_manual(values = c("gray90", "gray20"), guide = "none") +
ggthemes::theme_tufte(base_family = "Arial Black") +
theme(
axis.text.x = element_blank(),
axis.ticks = element_blank(),
strip.background = element_rect(fill = "gray90", color = NA)
)
我要补充说明,原作之所以吸引人,很大程度上是因为它的简单性。坚持整数分数。不要过度添加太多类别。而且您当前的数据方差太低,令人厌烦——如果您只给自己 4 和 5,那里的信息就不多了。
我正在尝试制作 'infographic' 简历,我想使用 R。 我创建了一个甘特图,现在想对我的技能进行排名。 我无法弄清楚哪种类型的图表会根据数字排名生成圆圈。这是我想要的示例。下面是示例数据。任何帮助表示赞赏 谢谢
dput(datAnal_skills)
structure(list(Type = c("Programming", "Programming", "Programming",
"Programming", "Analytics", "Analytics", "Analytics", "Analytics",
"Personal", "Personal", "Personal", "Personal"), Skill = c("R",
"Perl", "Python", "SQL", "Visualization", "Statistics", "Databases",
"Research Design", "Problem-solver", "Motivated", "Team player",
"Multi-tasker"), Of.5 = c(4.7, 4.5, 4, 4, 4.7, 4.5, 4.5, 4.5,
4.5, 4.5, 4.5, 4.5), Of.10 = c(9L, 8L, 8L, 8L, 9L, 9L, 8L, 8L,
9L, 9L, 8L, 8L)), class = "data.frame", row.names = c(NA, -12L
))
像这样:
library(ggplot)
ggplot(df, aes(x=Skill, y=Type))+
geom_point(aes(size=Of.10))+
coord_flip()
您可以先创建一个点网格,然后根据网格位置是否低于分数来为点着色。以下示例适用于 10 分制,因为 5 分制不是整数,不能很好地转换为项目符号。
library(ggplot2)
# df <- structure(...) # omitted for brevity
# For every skill, place 10 bullets
grid <- expand.grid(skill_id = seq_along(df$Skill), bullets = 1:10)
# Match skill name and score from original data
grid$score <- df$Of.10[grid$skill_id]
grid$skill <- df$Skill[grid$skill_id]
ggplot(grid, aes(factor(bullets), skill)) +
geom_point(aes(colour = bullets <= score), size = 3) +
scale_colour_manual(values = c("grey70", "grey30"),
guide = "none")
好主意。 这是我想出的。
datAnal_skills$Type<-factor(datAnal_skills$Type,levels=c("Programming","Analytics","Personal"))
#
ggplot(datAnal_skills, aes(x = Of.10, y = reorder(Skill,Of.10))) +
geom_point(size = 3) + # Use a larger dot
facet_wrap(~Type,scales = "free_y")+
xlim(c(0,10))+
ylab("")+
xlab("")+
theme_bw() +
theme(
axis.text.x=element_blank(),
panel.grid.major.x = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.major.y = element_line(colour = "grey60", linetype = "dashed")
)
这是清理主题选项的尝试。
df = df%>%
mutate(
score = round(Of.5)
) %>%
select(Type, Skill, score)
df = df %>%
expand(nesting(Type, Skill), score = 1:5) %>%
left_join(mutate(df, achieved = TRUE)) %>%
group_by(Type, Skill) %>%
mutate(achieved = lag(cumsum(coalesce(achieved, FALSE)) < 1, default = TRUE))
ggplot(df, aes(x = score, y = Skill, color = achieved)) +
geom_point(size = 2) +
facet_grid(rows = vars(Type), scales = "free") +
labs(x = "", y = "") +
scale_x_continuous(expand = expansion(add = 0.5)) +
scale_color_manual(values = c("gray90", "gray20"), guide = "none") +
ggthemes::theme_tufte(base_family = "Arial Black") +
theme(
axis.text.x = element_blank(),
axis.ticks = element_blank(),
strip.background = element_rect(fill = "gray90", color = NA)
)
我要补充说明,原作之所以吸引人,很大程度上是因为它的简单性。坚持整数分数。不要过度添加太多类别。而且您当前的数据方差太低,令人厌烦——如果您只给自己 4 和 5,那里的信息就不多了。