我有一个数据框,我想要转换成一个雷达外观图表。目前我只能有图表上的点,但也想连接它们。
以下是示例数据集:
u_df <- data.frame(a = 8, b = 9, c = 8, d = 5, e = 7)
u_df_transposed <- user_df %>%
gather(key = 'Attributes', value = "Scores", a:e)
ggplot(u_df_transposed, aes(x= Attributes, y = Scores)) + geom_point() + coord_polar()理想情况下,我希望"Attributes“列中每个变量的比例从1到10,类似于雷达图。
做这件事最简单的方法是什么?谢谢!
发布于 2018-10-11 06:23:36
要连接您的观察结果,只需将geom_path()添加到您的ggplot对象。要强制在径向轴上进行一定数量的中断,请添加scale_y_continuous()
plt <- ggplot(u_df_transposed, aes(x= Attributes, y = Scores))
plt <- plt + geom_path() + geom_point()
plt <- plt + scale_y_continuous(breaks=seq(min(u_df_transposed$Scores), max(u_df_transposed$Scores), 10))
# if the breaks do not need to be flexible:
# plt <- plt + scale_y_continuous(breaks=1:10))
plt <- plt + coord_polar()
plthttps://stackoverflow.com/questions/52748527
复制相似问题