SCM

Forum: help

Monitor Forum | Start New Thread Start New Thread
RE: colored barplots in ctree [ Reply ]
By: Achim Zeileis on 2018-01-04 11:02
[forum:45544]
OK, then I'm relieved ;-)

RE: colored barplots in ctree [ Reply ]
By: Markus Loecher on 2018-01-04 10:55
[forum:45542]
Thanks a lot, this was very helpful. And yes, I had planned to switch to RColorBrewer after getting it to work :)

RE: colored barplots in ctree [ Reply ]
By: Achim Zeileis on 2018-01-04 10:45
[forum:45540]
Instead of setting up a **panel-generating** function like your nb(), you can also simply pass along the **panel** function:

plot(sptree, terminal_panel = node_barplot(sptree, fill = rainbow(10)))

which is probably the easiest solution here. Alternatively, you can pass along the standard panel-generating function node_barplot plus your custom arguments:

plot(sptree, terminal_panel = node_barplot, tp_args = list(fill = rainbow(10)))

And, of course, I would recommend to use a better qualitative palette than rainbow :-) For example, something from RColorBrewer or colorspace.

RE: colored barplots in ctree [ Reply ]
By: Heidi Seibold on 2018-01-04 10:33
[forum:45539]
Not sure if that is the best solution, but it is a solution:

library("partykit")
data("HuntingSpiders", package = "partykit")
sptree <- ctree(arct.lute + pard.lugu + zora.spin + pard.nigr +
pard.pull + aulo.albi + troc.terr + alop.cune + pard.mont + alop.acce +
alop.fabr + arct.peri ~ herbs + reft + moss + sand + twigs + water,
data = HuntingSpiders, teststat = "max", minsplit = 5,
pargs = GenzBretz(abseps = .1, releps = .1))

nb <- function(obj) node_barplot(obj, fill = rainbow(10))
class(nb) <- class(node_barplot)
plot(sptree, terminal_panel = nb)

colored barplots in ctree [ Reply ]
By: Markus Loecher on 2018-01-04 10:05
[forum:45538]
For the hunting spider example in the partykit:ctree vignette:
how would I pass colors to the node_barplot function ?
My first naive attempt
plot(sptree, terminal_panel = node_barplot(fill=rainbow(10)))
clearly was unsuccessful.

Thx!
Markus

Thanks to:
Vienna University of Economics and Business Powered By FusionForge