1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > R语言ggplot2可视化自动换行适配长文本图例(legend)实战:Multiple Lines for Text per Legend Label

R语言ggplot2可视化自动换行适配长文本图例(legend)实战:Multiple Lines for Text per Legend Label

时间:2024-05-27 08:44:47

相关推荐

R语言ggplot2可视化自动换行适配长文本图例(legend)实战:Multiple Lines for Text per Legend Label

R语言ggplot2可视化自动换行适配长文本图例(legend)实战:Multiple Lines for Text per Legend Label

#导入包及数据处理

library(stringr)library(tidyverse)# Create long labels to be wrappediris$Species = paste(iris$Species, "random text to make the labels much much longer than the original labels")

#自动换行适配长文本图例(legend)

library(stringr)library(tidyverse)# Create long labels to be wrappediris$Species = paste(iris$Species, "random text to make the labels much much longer than the original labels")ggplot(iris, aes(Sepal.Length, Sepal.Width, colour=str_wrap(Species,20))) +geom_point() +labs(colour="Long title shortened\nwith wrapping") +theme(legend.key.height=unit(2, "cm"))

参考:R

参考:Multiple Lines for Text per Legend Label in ggplot2

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。