【R】ggdark

1. はじめに

ggdarkは、ggplot用のダークなテーマです。

2. インストール

CRANからインストールできます。

install.packages("ggdark")

3. 使ってみる

例をそのまま見てみます。

まずは、通常のモード。

library(ggplot2)
library(ggdark)
p <- ggplot(diamonds) +
geom_point(aes(carat, price, color = cut)) +
scale_y_continuous(label = scales::dollar) +
guides(color = guide_legend(reverse = TRUE)) +
labs(title = "Prices of 50,000 round cut diamonds by carat and cut",
x = "Weight (carats)",
y = "Price in US dollars",
color = "Quality of the cut")
p + theme_gray() # ggplot default
library(ggplot2) library(ggdark) p <- ggplot(diamonds) + geom_point(aes(carat, price, color = cut)) + scale_y_continuous(label = scales::dollar) + guides(color = guide_legend(reverse = TRUE)) + labs(title = "Prices of 50,000 round cut diamonds by carat and cut", x = "Weight (carats)", y = "Price in US dollars", color = "Quality of the cut") p + theme_gray() # ggplot default
library(ggplot2)
library(ggdark)

p <- ggplot(diamonds) + 
  geom_point(aes(carat, price, color = cut)) + 
  scale_y_continuous(label = scales::dollar) +
  guides(color = guide_legend(reverse = TRUE)) +
  labs(title = "Prices of 50,000 round cut diamonds by carat and cut",
       x = "Weight (carats)",
       y = "Price in US dollars",
       color = "Quality of the cut")

p + theme_gray()  # ggplot default

ダークモードにしてみます。

p + dark_theme_gray()
p + dark_theme_gray()
p + dark_theme_gray()

4. さいごに

ダークモードで目が疲れにくくくなりますね。自分でテーマを作ることもできるようです。

Add a Comment

メールアドレスが公開されることはありません。