以下是代码和图形。
这个图形有三个面。在the_plot
中的哪里可以找到它有三个面?是的,我可以从mtcars
数据框或the_plot$data
中获得,但我不想重新创建数据分析。相反,我想检查the_plot
的图形元素,这样我就不必在多个位置复制应用逻辑。the_plot$facet
没有显示任何我认识的东西,其他绘图变量也是如此。
我正在使用tidyverse 1.3.0。
library(tidyverse)
data(mtcars)
the_plot<-ggplot(mtcars, aes(mpg, disp, group=cyl)) + facet_wrap(~cyl) + geom_point()
the_plot
ggplot_build(the_plot)$layout$layout
。 - MrFlickthe_plot
不是你在图中看到的内容,而是你想要绘制的描述(数据、映射、主题等)。当你在控制台中写入the_plot
时,实际上你正在调用print(the_plot)
,这将启动一个过程,实现各种比例尺、分面的数量和位置等,并输出框、线和文本到一个图形设备。 - MrGumble