【问题标题】:How to set the color palette in the .Rprofile如何在 .Rprofile 中设置调色板
【发布时间】:2014-01-09 13:41:42
【问题描述】:

我想在 R 启动时更改调色板。因此我将以下源代码复制到我的 .Rprofile

palette(c(
  "#2e3436"   # (Aluminium 6)
  , "#ef2929" # (Scarlet Red 1)
  , "#73d216" # (Chameleon 2)
  , "#3465a4" # (Sky Blue 2)
  , "#fcaf3e" # (Orange 1)
  , "#ad7fa8" # (Plum 1)
  , "#babdb6" # (Butter 1)
  , "#babdb6" # (Aluminium 3)
))

在 R 启动时显示以下消息:

错误:无法微调功能“调色板”

启动时不能更改调色板吗?

【问题讨论】:

  • 可以在前面加上library(grDevices)
  • 这会在启动时打开一个烦人的窗口。 .Rprofile 之后加载了哪些包,它在哪里定义? (在调用palette() 之前,我从来不需要加载grDevices

标签: r colors palette color-palette rprofile


【解决方案1】:

来自?Startup

请注意,当站点和用户配置文件仅作为来源时 “基础”包已加载,因此其他包中的对象需要 被称为例如'utils::dump.frames' 或明确之后 加载相关包。

因此,请致电 grDevices::palette(),而不是 palette()。 (需要调用dev.off() 来消除启动后出现的空图形窗口。)

grDevices::palette(c(
  "#2e3436"   # (Aluminium 6)
  , "#ef2929" # (Scarlet Red 1)
  , "#73d216" # (Chameleon 2)
  , "#3465a4" # (Sky Blue 2)
  , "#fcaf3e" # (Orange 1)
  , "#ad7fa8" # (Plum 1)
  , "#babdb6" # (Butter 1)
  , "#babdb6" # (Aluminium 3)
))

grDevices::dev.off()

【讨论】:

    猜你喜欢
    • 2012-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-13
    相关资源
    最近更新 更多