【发布时间】:2017-11-01 22:39:15
【问题描述】:
我根据 M.Baggott (http://rpubs.com/mattbagg/circular) 提供的代码构建了一个极坐标图,以总结一年中按周发生的事件数量。不是按月填充条形,有没有办法让条形保持灰色并根据月份填充背景(即,灰色频率条后面代表月份的 12 个彩色饼片)?谢谢
这是一小部分数据和我的代码:
Week<- c(30, 21, 20, 26, 24, 22, 26, 26, 30, 25, 23, 23, 22, 24, 23, 22, 26, 20, 20, 23)
Month<- c("July", "May", "May","June", "June", "June", "June", "June", "July", "June", "June", "June", "June", "June", "June", "June", "July", "May", "May", "June")
df<- data.frame(Week=Week,Month=Month)
ggplot(df, aes(x = Week)) +
geom_histogram(breaks = seq(1, 52), colour = "white") +
coord_polar(start = 0) +
theme_minimal() +
scale_colour_gradient(colours=rainbow(12)) +
ylab("Count") +
ggtitle("Count by Week") +
scale_x_continuous("", limits = c(1, 52), breaks =c(1,5,9,13,18,22,26,31,35,39,44,48),labels=c("January","February","March","April","May","June","July","August","September","October","November", "December"))
【问题讨论】:
-
您需要提供最少的数据和代码示例
-
我添加了一个小子集和我的代码
标签: r ggplot2 polar-coordinates