1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

シンプルなggplot作図設定

Posted at

私が論文に載せる図を描くときに使っているggplot2の設定。条件は
・ 背景は白
・ 枠線は四方ありでちょっと太め、色は黒
のみ。
ggplot2のデフォルトだと次のようになる。

plotiris.R
library(ggplot2)
ggp <- ggplot(data=iris) +
  geom_point(aes(x=Sepal.Length, y=Petal.Length))
print(ggp)

image.png

背景が灰色だしなんか見にくい。そこで次のようなtheme()を書いてやる。

plotiris.R
ggp <- ggplot(data=iris) +
  geom_point(aes(x=Sepal.Length, y=Petal.Length)) +
  theme(
        axis.text = element_text(size = 20, colour = "black"), #目盛の数字
        axis.title = element_text(size = 20), #軸タイトル
        panel.grid.major = element_blank(),   #グリッドは入れない
        panel.grid.minor = element_blank(),   #グリッドは入れない
        panel.background = element_rect(fill = "white", colour = "black", size = 1.2) 
#fillは枠内の色、colourは枠線の色、sizeは枠線の太さ
        )
print(ggp)

image.png

これで論文に載せる図もバッチリ!

1
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?