r main.font不与CDPLOT()一起使用 - 是否有人知道在CDPLOT图标题中从粗体变成平原的解决方法?

发布于 2025-01-24 14:18:36 字数 838 浏览 0 评论 0原文

在基础r中,图的主要标题的默认字体面是粗体:

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

我可以将字体的面更改为普通的,

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

但是,将大胆更改为平原的相同方法不适用于CDPLOT()

## 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)

标题仍然大胆,我得到了错误消息“额外的参数'font.main'将被忽略” 。我还尝试了expression(plain(“ foo”)),但问题在于我有一个前面生成很多图,标题来自main = paste(“某些文本) “,i)表达式(plain ...无法处理峰要将标题字体面更改为简单吗?

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()

## 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如果没有你 2025-01-31 14:18:36

看来cdplot()没有将更多的图形参数传递给par。因此,您需要使用其他低级图形功能(例如title())来自定义图。

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

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文