sunburstR:每种类别均使用相同的颜色

时间:2019-06-03 14:26:04

标签: r d3.js sunburst-diagram

structure(list(Marketer = c("TASLOP YWORFYC", "YREVOCSID", "AKSLOP AJZIWELET", 
"AKSLOP AJZIWELET", "TASLOP YWORFYC", "SLUP AJZIWELET", "SGNIDLOH ITI", 
"DNALOP SKROWTEN AIDEM LANOITANRETNI MOCAIV", "YREVOCSID", "AKVATS", 
"YREVOCSID", "NOISIVELET SERUTCIP YNOS", "SLUP AJZIWELET", "AKSLOP AJZIWELET", 
"TASLOP YWORFYC", "DNALOP SLENNAHC LANOITANRETNI XOF", "YREVOCSID", 
"DNALOP SKROWTEN AIDEM LANOITANRETNI MOCAIV", "YREVOCSID", "TASLOP YWORFYC", 
"APURG MTA", "YREVOCSID", "AKSLOP AJZIWELET", "DNALOP SKROWTEN AIDEM LANOITANRETNI MOCAIV", 
"TASLOP YWORFYC", "DNALOP SKROWTEN AIDEM LANOITANRETNI MOCAIV", 
"YREVOCSID", "TASLOP YWORFYC", "AKSLOP AJZIWELET", "SGNIDLOH ITI", 
"SGNIDLOH ITI", "TASLOP YWORFYC", "SGNIDLOH ITI", "AKSLOP AJZIWELET", 
"SGNIDLOH ITI", "rehtO"), Advertiser = c("TASLOP", "NVT", "1 PVT", 
"2 PVT", "4 VT", "SLUP VT", "NVT", "NOEDOLEKCIN", "7 NVT", "VTT", 
"42 NVT", "NXA", "2 SLUP", "ELAIRES PVT", "2TASLOP", "LENNAHC CIHPARGOEG LANOITAN", 
"LENNAHC YREVOCSID", "LARTNEC YDEMOC", "ELYTS NVT", "VT OLOP", 
"AKWYRZOR MTA", "OBRUT NVT", "OFNI PVT", "VTM", "SWEN TASLOP", 
"cisuM VTM", "EFIL YREVOCSID", "EFAC TASLOP", "TROPS PVT", "42 NVT", 
"7 NVT", "TROPS TASLOP", "ELYTS NVT", "AINOLOP PVT", "OBRUT NVT", 
NA), size = c(634216983, 452207905, 219079142, 182359926, 78740169, 
64784549, 59142749, 57366881, 57262455, 56392788, 55692126, 53269413, 
50882084, 45753162, 39886956, 36180773, 35500223, 32739743, 30409799, 
27271797, 25305937, 20603791, 19771236, 16215889, 14897822, 14750001, 
13240967, 12872753, 12651485, 11188024, 11102314, 9553311, 5592035, 
4348638, 3638990, 53460983)), row.names = c(NA, -36L), vars = "Marketer", drop = TRUE, indices = list(
    20L, c(0L, 4L, 14L, 19L, 24L, 27L, 31L), c(1L, 8L, 10L, 16L, 
    18L, 21L, 26L), 15L, c(6L, 29L, 30L, 32L, 34L), 35L, 11L, 
    9L, c(2L, 3L, 13L, 22L, 28L, 33L), c(5L, 12L), c(7L, 17L, 
    23L, 25L)), group_sizes = c(1L, 7L, 7L, 1L, 5L, 1L, 1L, 1L, 
6L, 2L, 4L), biggest_group_size = 7L, labels = structure(list(
    Marketer = c("ATM GRUPA", "CYFROWY POLSAT", "DISCOVERY", 
    "FOX INTERNATIONAL CHANNELS POLAND", "ITI HOLDINGS", "Other", 
    "SONY PICTURES TELEVISION", "STAVKA", "TELEWIZJA POLSKA", 
    "TELEWIZJA PULS", "VIACOM INTERNATIONAL MEDIA NETWORKS POLAND"
    )), class = "data.frame", row.names = c(NA, -11L), vars = "Marketer", drop = TRUE), class = c("grouped_df", 
"tbl_df", "tbl", "data.frame"))


library(d3r)
library(sunburstR)

color_palette <- list('#ff3e47','#d70f14','#7d0b0e','#969696','#6c6c6c','#434343','#a0cb0e','#64a505','#325005','#ffa441','#dc7300','#a03c00','#2cd5e6','#0a7db4','#05415a','#f00b69','#c30050','#640028')


sund2b(
    d3_nest(fr, value_cols = "size", root = "Marketer"),
    width="100%", colors = list(range = color_palette)
)

我有以下数据集,无法使用sunburstR软件包中的Sunburst图表进行可视化。它已经可以正常工作,但是不同的颜色使其难以解释。

我想要的是,对于级别2的每个类别,我希望级别3的相似颜色在视觉上区分每个类别的颜色。到目前为止,如果需要的话,这些颜色只会重复出现,这看起来非常糟糕。

有人知道怎么做吗?

它应该像这样:

http://bl.ocks.org/sathomas/4a3b74228d9cb11eb486

0 个答案:

没有答案