ggplot2でタイトルとx軸y軸の設定

差分

この文書の現在のバージョンと選択したバージョンの差分を表示します。

この比較画面にリンクする

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
ggplot2でタイトルとx軸y軸の設定 [2018/08/12]
adash333 [グラフタイトルをグラフ上部中央に記載する]
ggplot2でタイトルとx軸y軸の設定 [2018/10/07] (現在)
ライン 9: ライン 9:
 ===== 開発環境 ===== ===== 開発環境 =====
  
-RStudio Cloudのconsole画面(画面左下)で、install.package("​tidyverse"​)を入力して、tidyverseパッケージをインストールした状態とします。+RStudio Cloudのconsole画面(画面左下)で、install.packages("​tidyverse"​)を入力して、tidyverseパッケージをインストールした状態とします。
  
 参考:http://​twosquirrel.mints.ne.jp/?​p=26918 参考:http://​twosquirrel.mints.ne.jp/?​p=26918
ライン 28: ライン 28:
 例) 例)
 <​code>​ <​code>​
-b <- b + scale_x_discrete(Time, labels = c(“BW_00pre” ​“Day0”“BW_01POD” ​“1POD”“BW_07POD” ​“7POD”“BW_14POD” ​“14POD”))+b <- b +  
 +  ​scale_x_discrete("Time", labels = c("​Course1" ​"​preop"​"​Course2" ​"one week""​Course3" ​"one month""​Course4" ​"three months"​)) + 
 +  theme(plot.title = element_text(hjust = 0.5), text = element_text(size=20))
 </​code>​ </​code>​
  
 +https://​stackoverflow.com/​questions/​13297995/​changing-font-size-and-direction-of-axes-text-in-ggplot2
 ==== x軸の値が連続値の場合 ==== ==== x軸の値が連続値の場合 ====
  
  
 <​code>​ <​code>​
-coord_cartesian(ylim = c(0,25)) + scale_x_continuous(breaks = seq(0,​25,​by=5),​labels=c(0,​5,​10,​15,​20,​25))+coord_cartesian(ylim = c(0,25)) +  
 +scale_x_continuous(breaks = seq(0,​25,​by=5),​labels=c(0,​5,​10,​15,​20,​25))
 </​code>​ </​code>​
 のような感じで用いる。 のような感じで用いる。
ライン 42: ライン 45:
 例) 例)
 <​code>​ <​code>​
-b <- b + coord_cartesian(ylim = c(0,25)) + scale_x_continuous(breaks = seq(0,​25,​by=5),​labels=c(0,​5,​10,​15,​20,​25))+b <- b + coord_cartesian(ylim = c(0,25)) +  
 +scale_x_continuous(breaks = seq(0,​25,​by=5),​labels=c(0,​5,​10,​15,​20,​25))
 </​code>​ </​code>​
  
ライン 59: ライン 63:
  
  
-==== グループによって少しだけx軸方向にずらす ====+===== グループによって少しだけx軸方向にずらす ​=====
  
  
ライン 71: ライン 75:
  
 http://​www.cookbook-r.com/​Graphs/​Plotting_means_and_error_bars_(ggplot2)/​ http://​www.cookbook-r.com/​Graphs/​Plotting_means_and_error_bars_(ggplot2)/​
 +
 +===== リンク =====
 +
 +https://​heavywatal.github.io/​rstats/​ggplot2.html
 +
 ===== Rでグラフを描くための初心者向けのおすすめの本 ===== ===== Rでグラフを描くための初心者向けのおすすめの本 =====
 初めての方には、以下の本が非常にお勧めです。 初めての方には、以下の本が非常にお勧めです。

ggplot2でタイトルとx軸y軸の設定.1534068952.txt.gz · 最終更新: 2018/10/07 (外部編集)