ユーザ用ツール

サイト用ツール


ggplot2で論文用の白黒折れ線グラフ

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン
前のリビジョン
ggplot2で論文用の白黒折れ線グラフ [2020/08/12] – [2.白黒の折れ線グラフの作成] adash333ggplot2で論文用の白黒折れ線グラフ [2020/08/12] (現在) – [ggplot2で論文用の白黒折れ線グラフ] adash333
行 1: 行 1:
 ====== ggplot2で論文用の白黒折れ線グラフ ====== ====== ggplot2で論文用の白黒折れ線グラフ ======
 +
 +[[初めての医療統計:index.html|初めての医療統計 目次]]
  
 ggplot2(tidyverse)では、カラーのきれいなグラフを出力してくれるのはありがたいのですが、論文用には白黒のグラフを作成したい場合が多いです。 ggplot2(tidyverse)では、カラーのきれいなグラフを出力してくれるのはありがたいのですが、論文用には白黒のグラフを作成したい場合が多いです。
行 76: 行 78:
  
 ===== 2.白黒の折れ線グラフの作成 ===== ===== 2.白黒の折れ線グラフの作成 =====
 +
 +上記で作成した表dを用いて、ggplot()関数でグラフを描きます。
  
 <code> <code>
 +pd <- position_dodge(0.1) # move them .05 to the left and right
  
 +ggplot(d, aes(x=dose, y=mean_len, shape=supp)) +
 +  theme_set(theme_classic()) +
 +  geom_point(size=4, position=pd) +
 +  geom_errorbar(aes(ymin=mean_len-sd_len, ymax=mean_len+sd_len), width=.1, position=pd) +
 +  geom_line(aes(linetype = supp), position=pd) +
 +  # グラフにタイトルをつける
 +  ggtitle("ToothGrowth") +
 +  theme(plot.title = element_text(hjust=0.5)) +
 +  theme(plot.title = element_text(size = 20),
 +    axis.title.x = element_text(size= 20),
 +    axis.title.y = element_text(size= 20),
 +    axis.text.x = element_text(size= 20),
 +    axis.text.y = element_text(size= 20)
 +  ) +
 +  # y軸のラベルの書き換え
 +  labs(y="Length")
 </code> </code>
  
 以下のようなグラフが出力されます。 以下のようなグラフが出力されます。
  
-{{:pasted:20180811-054428.png}}+{{ :ダウンロード.png |}} 
  
 ===== 3.グラフをpngファイルで出力 ===== ===== 3.グラフをpngファイルで出力 =====

ggplot2で論文用の白黒折れ線グラフ.txt · 最終更新: 2020/08/12 by adash333

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki