小提琴情节形状的堆积条形图

时间:2016-11-08 07:32:38

标签: r plot data-visualization

也许这是一个愚蠢的想法,或者也许这是一个脑波。我有4个不同物种的脂类分类数据集。数据是成比例的,总和是1000.我想想象每个物种中每个类别的比例差异。一般来说,堆叠的条形图就是这里的方法,但有几个类,它变得无法解释,因为只有底层类共享一个基线(见下文)。Traditional stacked bar

这似乎是一个糟糕的一群人的最佳选择,馅饼和甜甜圈图表简直就是嘲笑。 然后我被这个创作Symmetrical, violin plot-like histogram?所启发,创造了一种堆叠的分布小提琴情节(见下文)。 Stacked distribution violin

我想知道这是否可以某种方式转换成叠小提琴,这样每个片段代表一个完整的变量。在我的数据的情况下,物种'A和D在TAG段周围是'胖',在STEROL段是'skinnier'。这样,比例被描绘为水平,并且始终具有共同的基线。想法?

数据:

structure(list(Sample = c("A", "A", "A", "B", "B", "B", "C", 
"C", "C", "D", "D"), WAX = c(83.7179798600773, 317.364310355766, 
20.0147496567679, 93.0194886619568, 78.7886829173726, 79.3445694220837, 
91.0020522660375, 88.1542855137005, 78.3313314713951, 78.4449591023115, 
236.150030864875), TAG = c(67.4640254081232, 313.243238213156, 
451.287867136276, 76.308508343969, 40.127554151831, 91.1910102221636, 
61.658394708941, 104.617259648364, 60.7502685224869, 80.8373642262043, 
485.88633863193), FFA = c(41.0963382465756, 149.264019576272, 
129.672579626868, 51.049208042632, 13.7282635713804, 30.0088572108344, 
47.8878116348504, 47.9564218319094, 30.3836532949481, 34.8474205480686, 
10.9218910757234), `DAG1,2` = c(140.35876401479, 42.4556176551009, 
0, 0, 144.993393432366, 136.722412691012, 0, 140.027443968931, 
137.579074961889, 129.935353616471, 46.6128854387559), STEROL = c(73.0144390122309, 
24.1680929257195, 41.8258704279641, 78.906816661241, 67.5678558060943, 
66.7150537517493, 82.4794113296791, 76.7443442992891, 68.9357008866253, 
64.5444668132533, 29.8342694785768), AMPL = c(251.446564854412, 
57.8713327050339, 306.155806819949, 238.853696442419, 201.783872969561, 
175.935515655693, 234.169038776536, 211.986239116884, 196.931330316831, 
222.658181144794, 73.8944654414811), PE = c(167.99718650752, 
43.3839497916674, 22.1937177530762, 150.315149187176, 153.632530721031, 
141.580725482114, 164.215442147509, 155.113323256627, 143.349000132624, 
128.504657216928, 50.6281347160092), PC = c(174.904702096271, 
52.2494387772846, 28.8494085790995, 191.038328534942, 190.183655117756, 
175.33290326259, 199.2632149392, 175.400682364295, 176.64926273487, 
163.075864395099, 66.071984352649), LPC = c(0, 0, 0, 120.508804125665, 
109.194191312608, 103.16895230176, 119.324634197247, 0, 107.09037767833, 
97.151732936871, 0)), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -11L), .Names = c("Sample", "WAX", "TAG", 
"FFA", "DAG1,2", "STEROL", "AMPL", "PE", "PC", "LPC"))

1 个答案:

答案 0 :(得分:2)

这实际上是一个水平条形图:

git push --force origin origin/master:master

resulting plot