我有一个 ggplot 元素,称为“p”:
p <- qplot(hp, mpg, data=mtcars, shape=am, color=am,
facets=gear~cyl, main="Scatterplots of MPG vs. Horsepower",
xlab="Horsepower", ylab="Miles per Gallon")
然后我调用“p”并得到一个图。
如何调用 p 以便查看变量的赋值:
>somefunction(p)
qplot(hp, mpg, data=mtcars, shape=am, color=am,
facets=gear~cyl, main="Scatterplots of MPG vs. Horsepower",
xlab="Horsepower", ylab="Miles per Gallon")
最佳答案
您可以尝试使用函数 summary()
来显示数据(数据框中所有变量的名称)、值的映射以及使用哪种分面以及使用哪种几何.
summary(p)
data: mpg, cyl, disp, hp, drat, wt, qsec, vs, am, gear, carb [32x11]
mapping: colour = am, shape = am, x = hp, y = mpg
faceting: facet_grid(gear ~ cyl)
-----------------------------------
geom_point:
stat_identity:
position_identity: (width = NULL, height = NULL)
关于r - 查看 ggplot2::qplot 中绘图对象的调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19772194/