在 ggplot/ggplotly 中使用 facet_wrap 时,如何防止 y 轴压扁标签?
How to prevent the y-axis from squishing the labels when using facet_wrap in ggplot/ggplotly?
在我的例子中,我试图让 y 轴上的标签不被压在一起。有没有办法使用 ggplot2 或 ggplotly 来做到这一点?这是一个可重现的例子:
mpg2 <- subset(mpg, manufacturer %in% c("audi", "chevrolet",
"dodge","ford","honda","hyundai","jeep","land rover","lincoln","mercury","nissan", "pontiac",
"subaru", "volkswagen"))
base <- ggplot(mpg2, aes(displ, hwy)) +
geom_blank() +
xlab(NULL) +
ylab(NULL)
ggplotly(base + facet_wrap(~manufacturer, ncol = 1))
请注意:我不想让 ncol 超过 1。我想保持这种状态。我试图防止它被压在一起。谢谢!
感谢@eipi10 的评论
mpg2 <- subset(mpg, manufacturer %in% c("audi", "chevrolet",
"dodge","ford","honda","hyundai","jeep","land rover","lincoln","mercury","nissan", "pontiac",
"subaru", "volkswagen"))
base <- ggplot(mpg2, aes(displ, hwy)) +
geom_blank() +
xlab(NULL) +
ylab(NULL)
ggplotly(base + facet_wrap(~manufacturer, ncol = 1) + theme(axis.text.y=element_text(size=rel(0.5)))
在我的例子中,我试图让 y 轴上的标签不被压在一起。有没有办法使用 ggplot2 或 ggplotly 来做到这一点?这是一个可重现的例子:
mpg2 <- subset(mpg, manufacturer %in% c("audi", "chevrolet",
"dodge","ford","honda","hyundai","jeep","land rover","lincoln","mercury","nissan", "pontiac",
"subaru", "volkswagen"))
base <- ggplot(mpg2, aes(displ, hwy)) +
geom_blank() +
xlab(NULL) +
ylab(NULL)
ggplotly(base + facet_wrap(~manufacturer, ncol = 1))
请注意:我不想让 ncol 超过 1。我想保持这种状态。我试图防止它被压在一起。谢谢!
感谢@eipi10 的评论
mpg2 <- subset(mpg, manufacturer %in% c("audi", "chevrolet",
"dodge","ford","honda","hyundai","jeep","land rover","lincoln","mercury","nissan", "pontiac",
"subaru", "volkswagen"))
base <- ggplot(mpg2, aes(displ, hwy)) +
geom_blank() +
xlab(NULL) +
ylab(NULL)
ggplotly(base + facet_wrap(~manufacturer, ncol = 1) + theme(axis.text.y=element_text(size=rel(0.5)))