我是Rstudio的新手,正在努力制作如下图:polar diagram
我的数据集看起来像这样
我已经下载了ggplot2软件包,并且尝试键入一些我在互联网上看到的代码,但是,我无法使其正常工作。
非常感谢您!!
mtcars
作为示例数据,可以像这样实现所需的绘图:library(ggplot2)
library(dplyr)
library(tidyr)
## Replace the following three lines with your data
df <- mtcars %>%
count(gear, cyl, name = "value") %>%
unite(type, gear, cyl)
ggplot(df, aes(x = type, y = value, fill = factor(type))) +
geom_col(color = "white") +
coord_polar(start = 0) +
labs(title = "Title", subtitle = "Subtitle", caption = "Your caption", x = NULL, y = NULL) +
theme_minimal() +
theme(legend.position = "none") +
theme(axis.text.y = element_blank())
由reprex package(v0.3.0)在2020-03-15创建