This question demonstrates how to put an equation into a ggplot2 qplot.
这个问题演示了如何将方程式放入ggplot2 qplot中。
q <- qplot(cty, hwy, data = mpg, colour = displ)
q + xlab(expression(beta +frac(miles, gallon)))
How could I create an empty ggplot2 plot so that I could add the label to an empty canvas?
我怎么能创建一个空的ggplot2图,以便我可以将标签添加到空画布?
1 个解决方案
#1
30
df <- data.frame()
ggplot(df) + geom_point() + xlim(0, 10) + ylim(0, 100)
and based on @ilya's recommendation, geom_blank
is perfect for when you already have data and can just set the scales based on that rather than define it explicitly.
根据@ ilya的建议,geom_blank非常适用于已有数据的情况,并且可以根据需要设置比例,而不是明确定义。
ggplot(mtcars, aes(x = wt, y = mpg)) + geom_blank()
#1
30
df <- data.frame()
ggplot(df) + geom_point() + xlim(0, 10) + ylim(0, 100)
and based on @ilya's recommendation, geom_blank
is perfect for when you already have data and can just set the scales based on that rather than define it explicitly.
根据@ ilya的建议,geom_blank非常适用于已有数据的情况,并且可以根据需要设置比例,而不是明确定义。
ggplot(mtcars, aes(x = wt, y = mpg)) + geom_blank()