1
我讀這個question這等question回合使用\n
和ggplot2
軸標籤expression
但似乎並不對題(或者多行表達式)工作。多行`表達式()`在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
命令到另一個地方:一個之間VS和的和第二個在模型和(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=""))))
我拿到冠軍的這種奇怪的行爲:
我怎樣才能得到一個三線居中標題思想的表達?
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