看来,每当我使用包在 R 中创建图形时plotly
,轴标题总是覆盖轴标签。我现在有 2 个发生这种情况的图表。我应该使用什么代码来增加使用plot_ly()
and的轴标题和标签之间的空间ggplot()
?以及如何确保图例在 Plot 1 中可见并且不会被截断?
以前的 StackOverflow 问题给出了构建代码的不同方法,但它们似乎不适用于我的代码。
情节1:
plot <- ggplot(dat, aes(x=HeightUnderCWD, y=GrassHeight))+ geom_point()+
labs(x = "Height under CWD (cm)", y = "Grass Height (cm)")+
theme(text=element_text(size=20, family="Arial"))+
stat_smooth(method = "lm",formula = y ~ x,se = FALSE, color='Darkgreen')+
stat_smooth(aes(x = HeightUnderCWD, y = 7, linetype = "Linear Fit"), method = "lm", formula = y ~ x, se = FALSE,size = 1,color='lightgreen')
ggplotly(plot)
情节2:
p<-plot_ly(y = GrassHeight+1, color = CWDPosition,type = "box",colors = "Set1")%>%
layout(xaxis = x, yaxis = y, font = f)