Reputation:
Got a ctree with four labels, but the categories are long text therefore just the first is shown.
category;presence;ratio;tested;located
palindromic_recursion;1;0;0;0
conceptual_comprehension;0;1;0;0
infoxication_syndrome;0;0;1;0
foreign_words_abuse;0;0;0;1
palindromic_recursion;1;0;0;0
conceptual_comprehension;0;1;0;0
infoxication_syndrome;0;0;1;0
foreign_words_abuse;0;0;0;1
concepts.ctree <- ctree(category ~., data)
plot(concepts.ctree)
is there any way or parameter for manipultating (rotate) text, edge label names and this way force them to be all shown in plot?
My real data is much bigger but this sample is ok to test it if you do not use zoom tool.
Regards
Upvotes: 0
Views: 272
Reputation: 17203
There wasn't an option for this up to now. But I just tweaked the development version of partykit
on R-Forge to support this feature. Currently, the package is re-building but hopefully you can soon say install.packages("partykit", repos = "http://R-Forge.R-project.org")
- or if you don't want to wait that long, simply check out the SVN and re-build yourself.
In the new version, you can pass the rot
and just
arguments to grid.text()
to control rotation and justification of the x-axis labels.
Read the data:
data <- read.csv2(textConnection(
"category;presence;ratio;tested;located
palindromic_recursion;1;0;0;0
conceptual_comprehension;0;1;0;0
infoxication_syndrome;0;0;1;0
foreign_words_abuse;0;0;0;1
palindromic_recursion;1;0;0;0
conceptual_comprehension;0;1;0;0
infoxication_syndrome;0;0;1;0
foreign_words_abuse;0;0;0;1"
))
Fit the tree (using the partykit
implementation of ctree()
):
library("partykit")
concepts.ctree <- ctree(category ~ ., data = data)
For visualization create a viewport with sufficiently large margins on the x-axis first. Then, add the tree to the existing viewport page and set the rotation/justification arguments for the barplot.
pushViewport(plotViewport(margins = c(6, 0, 0, 0)))
plot(concepts.ctree, tp_args = list(rot = 45, just = c("right", "top")),
newpage = FALSE)
Upvotes: 2