Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

R main.font does not work with cdplot() – does anyone know a workaround to change from bold to plain in a cdplot plot title?

In base R the default font face for the main title of a plot is bold:

plot(1:10, main = "Foo")

I can change the font face to plain using

plot(1:10, main = "Foo", font.main = 1)

However, the same method for changing bold to plain does not work with cdplot()

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

## NASA space shuttle o-ring failures
fail <- factor(c(2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1,
                 1, 2, 1, 1, 1, 1, 1),
               levels = 1:2, labels = c("no", "yes"))
temperature <- c(53, 57, 58, 63, 66, 67, 67, 67, 68, 69, 70, 70,
                 70, 70, 72, 73, 75, 75, 76, 76, 78, 79, 81)

## CD plot
cdplot(fail ~ temperature, main="bw = default", font.main = 1)

The title remains bold and I get the error message "extra argument ‘font.main’ will be disregarded". I have also tried expression(plain("Foo")) but the problem is that I have a for-loop generating lots of plots, the title comes from main = paste("some text", i) and expression(plain... can’t handle the iterable, so the title of each plot will then be "some text i". Does anyone know some other workaround to change the title font face to plain, please?

>Solution :

It seems that cdplot() doesn’t pass further graphical parameters to par. Hence, you need to use other low-level graphical functions (e.g. title()) to customize your plot.

cdplot(fail ~ temperature)
title("bw = default", font.main = 1)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading