用连续和离散刻度填充两次使用的美学效果

时间:2019-04-20 14:29:01

标签: r ggplot2 ggforce

我有如下数据:

structure(list(bucket = structure(1:23, .Label = c("(1.23,6.1]", 
"(6.1,10.9]", "(10.9,15.6]", "(15.6,20.4]", "(20.4,25.1]", "(25.1,29.9]", 
"(29.9,34.6]", "(34.6,39.4]", "(39.4,44.2]", "(44.2,48.9]", "(48.9,53.7]", 
"(53.7,58.4]", "(58.4,63.2]", "(63.2,68]", "(68,72.7]", "(72.7,77.5]", 
"(77.5,82.2]", "(82.2,87]", "(87,91.7]", "(91.7,96.5]", "(96.5,101]", 
"(101,106]", "(106,111]"), class = "factor"), value = c(0.996156321090158, 0.968144290236367, 0.882793110384066, 0.719390676388129, 0.497759597498133, 
0.311721580067415, 0.181244079443301, 0.0988516758834657, 0.0527504526341006, 
0.0278716018561911, 0.0145107725175315, 0.00785033086321829, 
0.00405759957072942, 0.00213190168252939, 0.00109610249274952, 
0.000578154695264754, 0.000301095727545301, 0.000155696457494707, 
8.2897211122996e-05, 4.09225082176349e-05, 2.33782236798641e-05, 
1.21665352966827e-05, 6.87373003802479e-06), bucket_id = 1:23), class = c("tbl_df", 
"tbl", "data.frame"), row.names = c(NA, -23L))

我想将其可视化为圆形堆叠的条形图:

cutoff_values <- seq(0, 115, by = 5)


library(tidyverse)
ex %>% 
  mutate(r0 = cutoff_values[-length(cutoff_values)],
         r = cutoff_values[-1]) %>% 
  mutate(x0 = 100, 
         y0 = 50) %>% 
  ggplot(aes(x0 = x0, y0 = y0, r0 = r0, r = r)) +
  ggforce::geom_arc_bar(aes(start = 0, end = 2 * pi, fill = value),
                        colour = NA) +
  theme_void() +
  labs(fill = 'colour')

enter image description here

但是我还需要能够最多以不同的填充来标记一些特定的桶。因此,我需要能够使用value保持连续的比例填充,还需要用另一种颜色填充一个特定的层次(例如bucket == 15),而其他层次(存储桶)保持原样。可能吗?标记第15个存储桶的替代方法有哪些?

1 个答案:

答案 0 :(得分:1)

我相信可以使用Dict_1 = {'cat':'Cats are the greatest animals in the world','dog':'Dogs are boring'} query = 0 while (not query=='quit'): query = input().split() ans = None for i in query: if i in Dict_1: ans = Dict_1[i] break if ans is None: print('Curious, tell me more') else: print(ans) 程序包来完成此操作,该程序包仍处于试验阶段。您可以将数据的子集复制到单独的几何区域中,并赋予其另一种填充美感。然后可以将这个单独的几何图形传送到relayer中,并且必须为重命名的美学设置rename_geom_aes()。您可能会收到有关该几何图形正在忽略未知美学的警告,但我不知道这是否可以帮助您。

下面是将15号桶变红的示例。

scale_fill_*()