❝本节来介绍一款使用自然语言来调整R代码进行图形绘制的R包「ggx」,其主要作用是通过自然语言来调整代码此外还可以作为代码提示器使用。感觉挺有趣的,更多详细内容请参考作者官方文档。 ❞
❝https://github.com/brandmaier/ggx ❞
install.packages("ggx")
library(ggx)
library(tidyverse)
ggplot(data=iris,
mapping=aes(x=Sepal.Length,
y=Petal.Length, color=Species))+
geom_point()
ggplot(data=iris,
mapping=aes(x=Sepal.Length,
y=Petal.Length, color=Species))+
geom_point()+
gg_("hide legend")
ggplot(data=iris,
mapping=aes(x=Sepal.Length,
y=Petal.Length, color=Species))+
geom_point()+
gg_("rotate x-axis labels by 90°")+
gg_("set x-axis label to 'Length of Sepal'")
ggplot(data=iris,
mapping=aes(x=Sepal.Length,
y=Petal.Length, color=Species))+
geom_point()+
gg_("double the font size on the x-axis label")
ggplot(data=iris,
mapping=aes(x=Sepal.Length,
y=Petal.Length, color=Species))+
geom_point()+
gg_("add 'Hello World' as plot title")+
gg_("paint the plot title in a beautiful orange")+
gg_("set the color of the x-axis label to blue")
❝可以看到ggx可以用自然语言的写法来调整代码,除此之外ggx还可以作为提示工具来提供对应的帮助代码,如下所示。 ❞
gghelp("I want to remove my plot legend")
#> theme(legend.position = "none")
gghelp("Please hide the legend")
#> theme(legend.position = "none")
gghelp("Get rid of that stupid legend")
#> theme(legend.position = "none")