如何為 facet_grid 中的每個構面單獨更改每個圖形的 x 軸中斷數?我想為每個方面分別修改 x 軸。我試過 scale_x_continuos(breaks =..., n.breaks = ...) 但我不能。我還用 theme_replace 洗掉了 theme_set(theme_paleo(8)) 并嘗試了 theme(axis.x.text =, axis.ticks =, etc etc) 但沒有積極的結果,請任何可以幫助我的人。
這是此鏈接中地層圖的示例:https ://cran.r-project.org/web/packages/tidypaleo/vignettes/strat_diagrams.html
代碼:
library(tidyverse)
library(tidypaleo)
theme_set(theme_paleo(8))
data("alta_lake_geochem")
alta_lake_geochem
alta_plot <- ggplot(alta_lake_geochem, aes(x = value, y = depth))
geom_lineh()
geom_point()
scale_y_reverse()
facet_geochem_gridh(vars(param))
labs(x = NULL, y = "Depth (cm)")
alta_plot
alta_plot
uj5u.com熱心網友回復:
一個選項是允許為每個方面單獨設定比例的ggh4x
包。facetted_pos_scales
在下面的代碼中,我使用facetted_pos_scales
設定第一個和第三個方面的中斷,而對于所有其他方面,使用默認值 ( NULL
)。
注 1:facetted_pos_scales
需要通過 釋放 x 刻度scales="free_x"
。
注2:為了和我一起facetted_pos_scales
作業,scale_y_reverse
我也不得不搬進scale_y_reverse
去facetted_pos_scales
。
library(tidyverse)
library(tidypaleo)
library(ggh4x)
theme_set(theme_paleo(8))
data("alta_lake_geochem")
ggplot(alta_lake_geochem, aes(x = value, y = depth))
geom_lineh()
geom_point()
facet_geochem_gridh(vars(param), scales = "free_x")
labs(x = NULL, y = "Depth (cm)")
facetted_pos_scales(
x = list(
scale_x_continuous(breaks = 1:8),
NULL,
scale_x_continuous(n.breaks = 10),
NULL
),
y = list(
scale_y_reverse()
)
)
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/485867.html
上一篇:在一個繪圖中可視化多個資料框列