ndphillips / FFTrees

An R package to create and visualise fast-and-frugal decision trees (FFTs)
https://journal.sjdm.org/17/17217/jdm17217.pdf
135 stars 23 forks source link

Allow grayscale option for plot.FFTrees() #210

Closed ndphillips closed 7 months ago

ndphillips commented 7 months ago

A user Guido Williams guido.l.williams@gmail.com emailed me asking for a grayscale option for plot.FFTrees().

Dear Nathaniel,

I have a question regarding the plot functions in the FFT package. Is there a simple way to print all plots/output in black and white/greyscale? For instance: plot(heart.fft, color = FALSE) or is there another way? This would be very convenient for publication purposes.

This PR includes the new grayscale argument to plot.FFTrees() that enables this

See example below:

heart_fft <- FFTrees(formula = diagnosis ~.,
                     data = heart.train,
                     data.test = heart.test, 
                     decision.labels = c("Healthy", "Disease"))

plot(heart_fft, grayscale = TRUE)
image

Setting grayscale = FALSE (the default), gives us the color back

plot(heart_fft, grayscale = FALSE)
image
ndphillips commented 7 months ago

Guido emailed me to confirm it works as desired:

It works like a charm! Thanks!

hneth commented 7 months ago

This seems to be a nice enhancement and useful option — thanks for suggesting and implementing it!

An alternative approach to colors in FFT plots could collect all used ones in a vector and pass that as an argument. This would provide users with complete control over the colors, but the combination of a good default and a grayscale option probably covers 95% of all cases?

ndphillips commented 7 months ago

Thanks for the feedback @hneth ! I agree adding additional arguments to control the individual colors directly could be useful, but I'd prefer to save that for a future PR if needed.

In this PR I have also made a few modifications to DESCRIPTION and NEWS.md to conform to the conventions in the tidyverse (namely https://github.com/tidyverse/dplyr/blob/main/NEWS.md)

Happy to discuss reversing these changes if desired