简体   繁体   English

如何根据R中的堆积条形图产生更好的数据可视化?

[英]How to produce a better visualization of data in terms of stacked bar plot in R?

I ran a program with different threads in two configurations a and b . 我在两个配置ab运行了一个具有不同线程的程序。 I breakdown its timings into btime , stime , and vtime . 我把它的时间分解为btimestimevtime Please see below for the data. 请参阅下面的数据。 I need to draw stacked plot as you can see below. 我需要绘制堆积图,如下所示。 However, I face difficulty in representing both the number of threads and configs as x-axis labels in R. Could some one help to produce a better representation of this data in terms of stacked plots in R please. 但是,我很难将线程和配置的数量表示为R中的x轴标签。有些人可以帮助在R请求的堆积图中更好地表示这些数据。 Please see the figure and the R code I am using below. 请参阅下面的图和我正在使用的R代码。

Data: 数据:

config threads  btime   stime   vtime
a   2   0.08    0.32   0.09
b   2   0.32    0.19   0.16
a   4   3.72 2841.13   0.22
b   4   18.21 2865.79   5.12
a   8   5.45 2824.46   4.77
b   8   23.27 2790.14  11.89
a   16  57.63 3302.55  94.25
b   16  62.41 4041.19  82.56
a   32  119.08 3705.62 210.14
b   32  183.01 4411.14 234.17
a   64  211.51 2823.69 270.38
b   64  364.38 4091.97 387.83

R code R代码

> barplot(t(data1[c(3:5)]), ylab="Time(seconds)", sp=c(0.1, 0.2, 1.0, 0.2, 1.0, 0.2, 1.0, 0.2, 1.0, 0.2, 1.0, 0.2),col=c("white","gray20","gray60"))
> legend("topleft",legend=c("btime","stime","vtime"), bty="n",cex=1.5 , horiz=T, adj=0.2, fill=c("white","gray20","gray60"))

在此输入图像描述

ggplot and lattice are very helpful here, however it is useful to think of the data in a different manner: you will want to represent it as something like ggplot和lattice在这里非常有用,但是以不同的方式考虑数据是有用的:你会想要将它表示为类似的东西

config threads time_type time_value
[...]  [...]    vtime     0.03

melt from reshape accomplishes this (see tutorial http://www.statmethods.net/management/reshape.html ) 来自重塑的融化实现了这一点(参见教程http://www.statmethods.net/management/reshape.html

Then, you can do a plot of something like... qplot(config, time_value, data=data, group=time_type, fill=time_type, geom="barplot", facets= .~threads) 然后,你可以做一些类似的事情... qplot(config, time_value, data=data, group=time_type, fill=time_type, geom="barplot", facets= .~threads)

(tutorial @ http://www.r-bloggers.com/basic-introduction-to-ggplot2/ ) (教程@ http://www.r-bloggers.com/basic-introduction-to-ggplot2/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM