richarddmorey / BayesFactor

BayesFactor R package for Bayesian data analysis with common statistical models.
https://richarddmorey.github.io/BayesFactor/
131 stars 48 forks source link

Allow control of colors and title of plot.BFBayesFactor. #79

Closed Ax3man closed 7 years ago

Ax3man commented 7 years ago

This PR simply adds control over the title and colors of a BF plot. Defaults remain unchanged.

library(BayesFactor)
bf <- regressionBF(rating ~ ., data = attitude, whichModels = "bottom")
plot(bf,  cols = c("pink", "green"), main = "Test Title")

This now creates this plot.

In response to @fsense.

richarddmorey commented 7 years ago

Looks good, but now it needs a check for valid color input and valid vector length (>=2). Could you add this and resubmit the pull request?

Ax3man commented 7 years ago

I'd be happy to, but is it necessary? Both

plot(bf,  cols = c('green'))
plot(bf,  cols = c('green', 'pink', 'grey'))

give reasonable output. A single color will only color smaller than 1, for vectors of lenght > 2, only the first two elements are used.

Invalid colors already produce an informative error (invalid color name 'x') through barplot.

richarddmorey commented 7 years ago

Sounds good then. I'll merge.