在R的点阵封装中微调点图 [英] Fine tuning a dotplot in R's lattice package
问题描述
我正在尝试为不同的数据集和不同的算法绘制一堆ROC区域. 我有三个变量:"Scheme",它指定使用的算法;"Dataset",是要在其上测试算法的数据;以及"Area_under_ROC".
I am trying to plot a bunch of ROC areas for different datasets and different algorithms. I have three variables: "Scheme" which specifies the algorithm used, "Dataset" is the dataseet that the algorithm is being tested on, and "Area_under_ROC".
我正在R中使用晶格库,并使用以下命令:
I am using the lattice library in R, with the following command:
dotplot(方案〜Area_under_ROC |数据集,数据=模拟摘要,布局= c(4,6))
dotplot(Scheme ~ Area_under_ROC | Dataset, data = simulationSummary, layout = c(4,6))
这就是我得到的:
我想知道的是
- 如何使y轴上的标签可读?现在,他们都被挤在一起了.
- 如何重新排列面板,使标记为"100"的数据集形成最后一列,而其他列保持不变?
非常感谢您提出任何意见或建议. 非常感谢!
I'd very much appreciate any comments or pointers. Many Thanks!
推荐答案
一些想法:
- 为y轴标签使用较小的字体,例如
scale=list(y=list(cex=.6))
.一种替代方法是保留统一的字体大小,但将输出分成几页(可以用layout=
进行控制),或者更好的方法是显示同一数据集中的所有数据(从A到F,因此4点表示).每种算法)或样本大小(10到100,因此每个算法6点),并带有group=
选项.为此,我将亲自创建两个因素,分别为sample.size
和dataset.type
. -
重新设置因子
Dataset
,以便您感兴趣的数据集出现在layout
放置它们的位置,或者(更好!)使用index.cond
为24个面板指定特定排列.例如
- Use a smaller font size for y-axis labels, e.g.
scale=list(y=list(cex=.6))
. An alternative would be to preserve uniform font size, but separate your output on several pages (this can be controlled withlayout=
), or, probably better, to show all data from the same dataset (A to F, hence 4 points for each algorithm) or by sample size (10 to 100, hence 6 points for each algorithm) with agroup=
option. I would personally create two factors,sample.size
anddataset.type
for that. Relevel your factor
Dataset
, so that the dataset you are interested appear wherelayout
will put them, or (better!) useindex.cond
to specify a particular arrangement for your 24 panels. E.g.,
dfrm <- data.frame(algo=gl(11, 1, 11*24, labels=paste("algo", 1:11, sep="")),
type=gl(24, 11, 11*24, labels=paste("type", 1:24, sep="")),
roc=runif(11*24))
p <- dotplot(algo ~ roc | type, dfrm, layout=c(4,6), scale=list(y=list(cex=.4)))
将按从左下到右上的顺序排列面板(左下面板中的type1
,右上面板中的type24
),而
will arrange panels in sequential order, from bottom left to top right (type1
in bottom left panel, type24
in top right panel), while
update(p, index.cond=list(24:1))
将以相反的顺序排列面板.只需指定具有预期面板位置的list
.
will arrange panels in the reverse order. Just specify a list
with expected panel locations.
这里是一个例子,说明了我对要点1的想法,并使用了两个因素而不是一个.让我们生成另一个人工数据集:
Here is an example of what I have in mind with Point 1 and the use of two factors instead of one. Let us generate another artificial dataset:
dfrm <- data.frame(algo=gl(11, 1, 11*24, labels=paste("algo", 1:11, sep="")),
dataset=gl(6, 11, 11*24, labels=LETTERS[1:6]),
ssize=gl(4, 11*6, 11*24, labels=c(10,25,50,100)),
roc=runif(11*24))
xtabs(~ dataset + ssize, dfrm) # to check allocation of factor levels
dotplot(algo ~ roc | dataset, data=dfrm, group=ssize, type="l",
auto.key=list(space="top", column=4, cex=.8, title="Sample size",
cex.title=1, lines=TRUE, points=FALSE))
这篇关于在R的点阵封装中微调点图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!