r - 使用 24 小时制数据创建圆形图的方法是什么?
问题描述
我正在尝试使用围绕中心点绘制的一组数据来创建一个圆形图。我在网上找到的代码可以做到,但是 Y 轴太大以至于图形没有用。我想将 Y 轴限制为 95-120,但是当我使用Y_scale_continuous(limit=c(95,120))
它时,它会掉线。
数据:
"","Hour","me"
"1",0,98.9192
"2",1,100.756333333333
"3",2,101.6815
"4",3,98.6551666666667
"5",4,102.668666666667
"6",5,104.024571428571
"7",6,106.137
"8",7,103.6535
"9",8,107.868333333333
"10",9,112.261428571429
"11",10,114.99
"12",11,113.452714285714
"13",12,110.534285714286
"14",13,112.974285714286
"15",14,112.731428571429
"16",15,104.658571428571
"17",16,112.271
"18",17,108.386666666667
"19",18,113.968857142857
"20",19,107.287142857143
"21",20,110.583
"22",21,102.811714285714
"23",22,105.983571428571
"24",23,100.98625
代码:
p<-ggplot(c, aes(x = Hour, y=me)) +
geom_bar(breaks = seq(0,24), width = 2, colour="grey",stat = "identity") +
theme_minimal() +
scale_fill_brewer()+coord_polar(start=0)+
scale_x_continuous("", limits = c(0, 24), breaks = seq(0, 24), labels = seq(0,24))
解决方案
也许这里的解决方案只是更改您的数据?从数学上讲,这与将轴从零移开一样。
ggplot(df, aes(x = Hour, y=me - 95)) +
geom_bar(width = 2, colour="grey",stat = "identity") +
theme_minimal() +
scale_fill_brewer() +
coord_polar(start=0) +
scale_x_continuous("", limits = c(0, 24), breaks = seq(0, 24), labels = seq(0,24))
这可能会使图表更难解释,因此您需要解释任何这样的操作。如果相对值显着,这可以帮助解释,如果绝对值显着,这种调整的范围从令人困惑到相当误导。
推荐阅读
- apache-kafka - Flink 和非键控窗口状态
- java - 在映射超类中处理 Hibernate 持久性
- javascript - Eclipse IDE v2020-12 (4.18.0) 坚持我的 javascript 文件之一是 HTML 文件,并将每次使用 && 标记为无效字符
- python - Visual Studio Code 中的 Python Quandl 输出
- python - 使用正则表达式从 url 中提取日期
- c# - MVVM:如何从我在检查项目的列表视图中手动输入的文本框中检索值?
- asp.net-core - 在购物车中添加商品
- java - IntelliJ Java 类型渲染器用于带有原语的 Eclipse 集合
- google-sheets - 使用 google 查询作为数组公式,根据另一列中的信息对列中的值求和
- ios - 在展开可选值时意外发现 nil,即使它已分配了值