长句不显示(ggforce + geom_mark_circle)
Long text sentence are not displayed (ggforce + geom_mark_circle)
我正在使用 ggforce
库,但在显示长文本时遇到困难。当要显示的文本稍长时,它会从图中消失(参见示例 #2)。有办法解决这个问题吗?
library(tidyverse)
library(ggforce)
ggplot(iris, aes(Petal.Length, Petal.Width)) +
geom_mark_circle(aes(color = Species, label = "Small sentence"),
expand = unit(0.2, "mm")
) +
geom_point() +
theme(legend.position = "none") +
theme_minimal()
这行不通
ggplot(iris, aes(Petal.Length, Petal.Width)) +
geom_mark_circle(aes(color = Species, label = "This is a very long text to display"),
expand = unit(0.2, "mm")
) +
geom_point() +
theme(legend.position = "none") +
theme_minimal()
由 reprex package (v0.3.0)
于 2019-07-25 创建
您可以在 tidyverse
中使用 stringr::str_wrap()
ggplot(iris, aes(Petal.Length, Petal.Width)) +
geom_mark_circle(
aes(color = Species, label = str_wrap("This is a very long text to display", 20)),
expand = unit(0.2, "mm")
) +
geom_point() +
theme(legend.position = "none") +
theme_minimal()
我正在使用 ggforce
库,但在显示长文本时遇到困难。当要显示的文本稍长时,它会从图中消失(参见示例 #2)。有办法解决这个问题吗?
library(tidyverse)
library(ggforce)
ggplot(iris, aes(Petal.Length, Petal.Width)) +
geom_mark_circle(aes(color = Species, label = "Small sentence"),
expand = unit(0.2, "mm")
) +
geom_point() +
theme(legend.position = "none") +
theme_minimal()
这行不通
ggplot(iris, aes(Petal.Length, Petal.Width)) +
geom_mark_circle(aes(color = Species, label = "This is a very long text to display"),
expand = unit(0.2, "mm")
) +
geom_point() +
theme(legend.position = "none") +
theme_minimal()
由 reprex package (v0.3.0)
于 2019-07-25 创建您可以在 tidyverse
stringr::str_wrap()
ggplot(iris, aes(Petal.Length, Petal.Width)) +
geom_mark_circle(
aes(color = Species, label = str_wrap("This is a very long text to display", 20)),
expand = unit(0.2, "mm")
) +
geom_point() +
theme(legend.position = "none") +
theme_minimal()