小编Dav*_*lin的帖子

使用ggplot2左对齐geom_text图层

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:

链接到ggplot(我不允许发布图片)

但是,我想在一个整齐的专栏中左对齐文本.我基本上是问如何提供xmintext.我是否需要对相应x比例的变量执行数学运算x?还是有诀窍theme

r ggplot2 geom-text

3
推荐指数
1
解决办法
3471
查看次数

如何使用 sf 和 R 将圆分成相等的 MULTIPOLYGON“切片”?

我有这个圈子:

library(sf)
p <- st_sfc(st_point(c(0, 1))) 
circle <- st_buffer(p, dist = 1)  
plot(circle)
Run Code Online (Sandbox Code Playgroud)

sf_circle

如何将这个圆分成 4 个相等的“切片”?6等份?8等份?等等。我需要返回的对象是一个 MULTIPOLYGON。

r r-sf

0
推荐指数
1
解决办法
74
查看次数

标签 统计

r ×2

geom-text ×1

ggplot2 ×1

r-sf ×1