在
library(ggplot2)
library(reshape)
df <- as.data.frame(matrix(runif(9),3,3))
df$factor <- letters[1:3]
df.m <- melt(df)
ggplot(df.m, aes(variable, value)) +
geom_boxplot() +
facet_wrap(~factor)
Run Code Online (Sandbox Code Playgroud)
我想改变方面名称.根据ggplot2教程,这是有效的:
new.lab <- as_labeller(c(a="A",b="B",c="C"))
ggplot(df.m, aes(variable, value)) +
geom_boxplot() +
facet_wrap(~factor, labeller=new.lab)
Run Code Online (Sandbox Code Playgroud)
但是,这不是:
new.lab <- as_labeller(c(a="A",b="B",c=expression(italic("C"))))
ggplot(df.m, aes(variable, value)) +
geom_boxplot() +
facet_wrap(~factor, labeller=new.lab)
Run Code Online (Sandbox Code Playgroud)
我如何在ggplot2 2.0方面获得斜体(或任何其他特殊符号)?
library(tidyverse)
ggplot(mpg, aes(displ, cty)) +
geom_point() +
facet_grid(rows = vars(drv), scales = "free")
Run Code Online (Sandbox Code Playgroud)

上面的代码ggplot包括三个板4,f和r。我希望每个面板的y轴限制如下:
Panel y-min y-max breaks
----- ----- ----- ------
4 5 25 5
f 0 40 10
r 10 20 2
Run Code Online (Sandbox Code Playgroud)
如何修改我的代码来完成此任务?不知道是否scale_y_continuous更有意义,或coord_cartesian,或两者的某种组合。