我有ggplot标题定位问题。当我使用hjust参数将标题向右滑动时,两行都会向左和向右滑动。我想要它们一个在另一个下面。drawlabel(),annototations对我的情况没有用,因为它们取决于 x 和 y 轴及其单位(日期、货币、公斤),这意味着每次我必须调整它们时。我想要独特的坐标系,无论我在绘制什么,我都可以轻松地将相同的位置用于不同的绘图。
下面显示了一个不受欢迎的代码示例。
set.seed(10)
df <- data.frame(x=1:10,y=round(rnorm(10)*1:10,2))
ggplot(df,aes(x=x,y=y))+
geom_line(size=0.75)+
labs(title = 'Here comes my title like that some words\nand my second line title')+
theme(
plot.title.position = 'plot',
plot.title = element_text(hjust = 0.075)
)
Run Code Online (Sandbox Code Playgroud)
不受欢迎的情节
合意的情节