に私が\n
とggplot2
軸ラベルでexpression
を使って試合このquestionこの他questionを読んでいたが、それはタイトルのために(または複数行の表現のために)動作しないようです。複数行 `表現()` ggplot2タイトル
ggplot(data = fig3, aes(x=crude_beta_time6, y=vidD_beta_time6)) +
geom_point(shape=18, size=5, color="gray60") + xlab("Coefficients of the crude model") +
ylab(bquote("Coefficients of the total 25(OH)D"[3]~"adjusted model")) +
theme_bw(base_size = 17) + theme(
panel.grid.major = element_line(color = "gray20", size = 0.3, linetype = "dashed"),
panel.grid.minor = element_line(color = "gray40", size = 0.3, linetype = "dashed")
) + ggtitle(expression(paste("(B) Coefficients of the crude model vs the total 25(OH)", D[3]," adjusted model (0h vs 6h)", sep="")))
をしかし、タイトルが長すぎるので、私は引用した問題で推奨atop
コマンドを使用して、2つのブレークラインに置くことを試みたです:
私のオリジナルのプロットは、以下の1対間をおよびおよびモデルおよび(0h対6h)の間である。
ggplot(data = fig3, aes(x=crude_beta_time6, y=vidD_beta_time6)) +
geom_point(shape=18, size=5, color="gray60") + xlab("Coefficients of the crude model") +
ylab(bquote("Coefficients of the total 25(OH)D"[3]~"adjusted model")) +
theme_bw(base_size = 17) + theme(
panel.grid.major = element_line(color = "gray20", size = 0.3, linetype = "dashed"),
panel.grid.minor = element_line(color = "gray40", size = 0.3, linetype = "dashed")
) + ggtitle(expression(atop(paste("(B) Coefficients of the crude model vs\nthe total 25(OH)", D[3]," adjusted model\n(0h vs 6h)", sep=""))))
そして私はタイトルのこの奇妙な振る舞いを取得:
は、どのように私は3本のラインと中央にタイトルが式を考え得ることができますか?
UPDATE:
ユーザーシリンGlanderはタイトルのために、より多くのスペースを作るためにプロットのマージンを更新することが示唆されました。
ggplot(data = fig3, aes(x=crude_beta_time6, y=vidD_beta_time6)) +
geom_point(shape=18, size=5, color="gray60") + xlab("Coefficients of the crude model") +
ylab(bquote("Coefficients of the total 25(OH)D"[3]~"adjusted model")) +
theme_bw(base_size = 17) + theme(
panel.grid.major = element_line(color = "gray20", size = 0.3, linetype = "dashed"),
panel.grid.minor = element_line(color = "gray40", size = 0.3, linetype = "dashed")) +
ggtitle(expression(atop(paste("(B) Coefficients of the crude model vs\nthe total 25(OH)", D[3]," adjusted model\n(0h vs 6h)", sep="")))) +
theme(plot.margin=unit(c(4,0,0,0),"cm"))
このコードの結果はタイトルのために多くのスペースが追加されますが、タイトルが示すプロパティではありません:あなたは、上部余白を増やす必要が
あなたの答えをありがとうが、私にとってはうまくいきません。得られた結果の別の画像で質問を更新しました。マージンは多かれ少なかれ正しく設定されていますが、タイトルは正しく表示されません。 – carlesh