简体   繁体   English

在R中绘制条件推理树时更改标签大小

[英]Changing labels size while plotting conditional inference trees in R

I need to insert conditional inference trees (plotted in party library of R) into a text of PhD thesis, that's why I have to tune all the graphical parameters. 我需要将条件推理树(在R的方库中绘制)插入到博士论文中,这就是我必须调整所有图形参数的原因。

I know that the optimal width is 700 (just because it fits the format of thesis to the best). 我知道最佳宽度是700(只是因为它最适合论文的格式)。 The problem is that in this case one can't see the list of factors which leads to one or both nodes in a lower level of the tree. 问题在于,在这种情况下,人们无法看到导致树的较低级别中的一个或两个节点的因素列表。

I tried to specify cex parameter while plotting, but it gave me no effect. 我试图在绘图时指定cex参数,但它没有给我带来任何影响。 I need to lower the labels size at the plot. 我需要降低图中的标签尺寸。 I'll appreciate any help. 我会感激任何帮助。

The code looks like follows: 代码如下所示:

blgrcit <- ctree(Suffix ~ cluster + quality + declination, blgr)
jpeg("bulgarian_tree.jpeg", width = 700)
plot(blgrcit, cex = 0.4)
dev.off()

The graphics in party (and the more recent reimplementation in partykit ) are implemented in grid and hence many standard base graphics parameters are not supported. party的图形(以及partykit最近的重新实现)在grid中实现,因此不支持许多标准基本graphics参数。

If you want to change the font size for all elements of a ctree plot, then the easiest thing to do is to use the partykit implementation and set the gp graphical parameters. 如果要更改ctree图的所有元素的字体大小,那么最简单的方法是使用partykit实现并设置gp图形参数。 For example: 例如:

library("partykit")
ct <- ctree(Species ~ ., data = iris)
plot(ct)
plot(ct, gp = gpar(fontsize = 8))

ctree1 ctree2

Instead (or additionally) you might also consider to use a vector PDF graphic instead of a raster JPG graphic for your thesis. 相反(或另外)您可能还会考虑使用矢量PDF图形而不是光栅JPG图形作为论文。 Then I usually recommend to make height / width of the pdf() large enough so that all elements of the plot look "good". 然后我通常建议使pdf() height / width足够大,以使绘图的所有元素看起来都“好”。 And then this can be scaled to the text width when including it in the document because scaling is not an issue for vector graphics. 然后,当将其包含在文档中时,可以将其缩放到文本宽度,因为缩放不是矢量图形的问题。

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

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