ggplot2自动将文本居中放置在geom_text图层中.例如:
library(ggplot2)
library(tidyverse)
df <- data_frame(text = c("A short sentence.",
"A slightly longer sentence.",
"This sentence is the longest of the sentences."),
y = row_number(text) - 1,
x = 1)
ggplot(df, aes(x = x, y = y)) +
geom_text(aes(label = text), nudge_x = nchar(text)/2)
Run Code Online (Sandbox Code Playgroud)
生产:
ggplot:

但是,我想在一个整齐的专栏中左对齐文本.我基本上是问如何提供xmin给text.我是否需要对相应x比例的变量执行数学运算x?还是有诀窍theme?
我有这个圈子:
library(sf)
p <- st_sfc(st_point(c(0, 1)))
circle <- st_buffer(p, dist = 1)
plot(circle)
Run Code Online (Sandbox Code Playgroud)
如何将这个圆分成 4 个相等的“切片”?6等份?8等份?等等。我需要返回的对象是一个 MULTIPOLYGON。