Help us understand the problem. What is going on with this article?

ggplot2で論文用の図を作るときに使いたいオプション(点のshape、色、軸の文字の大きさ、色、エラーバー、背景)

More than 3 years have passed since last update.

この記事の目的

さっき論文用の図を作っていて、「これどうやるんだっけ?」となったオプションのメモです。
順次追記する予定です。
間違いなどありましたら、コメント欄でご指摘ください。

背景を消す

g + theme(panel.grid.major = element_blank(),
          panel.grid.minor = element_blank(),
          panel.background = element_blank()
    )

軸の色を変える

g + theme(axis.line=element_line(colour = "black"),
          axis.ticks=element_line(colour = "black")
    )

軸のタイトルとラベルの文字サイズを変える

出典: r - Change size of axes title and labels in ggplot2 - Stack Overflow

g+theme(axis.text=element_text(size=12),
        axis.title=element_text(size=14,face="bold"))

エラーバーつきのプロットの作成

出典: Cookbook for R » Plotting means and error bars (ggplot2)

dfcであらかじめseの値を持っておいた上で)

ggplot(dfc, aes(x=dose, y=len, colour=supp)) + 
    geom_errorbar(aes(ymin=len-se, ymax=len+se), width=.1) +
    geom_line() +
    geom_point()

エラーバーのtick(?)の幅はwidthで設定できる。

点の形(shape)を手動で設定する

ggplot(dat, aes(x=xvar, y=yvar, shape=cond)) + geom_point() +
    scale_shape_manual(values=c(1,2)) 

出典: Cookbook for R » Scatterplots (ggplot2)

点の色を設定する

g + geom_point(colour="white")
g + geom_point(fill="white")

ただし、colourfillで色を設定できるshapeが違う。fillで色を設定しようと思ったら、21, 22, 23, 24, 25だけ。
出典: geom_point - 浅井拓也 研究室用ページ

y軸の範囲

scale_y_continuous(expand = c(0,0), limits=c(0,1.1* max(dt2[,sec] + dt2[,sd]) ))
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away