When I run the following code, it produces this graph:
plot <- ggplot(dat, aes(x = HeightUnderDebris, y = GrassHeight)) +
geom_point() +
stat_smooth(method = 'lm', se = FALSE,color = 'darkgreen') +
stat_smooth(aes(x = HeightUnderDebris, y = 5, linetype = "Linear Fit"),
method = "lm", formula = y ~ x, se = F, size = 1, color = 'lightgreen') +
labs(x = "Height under CWD (cm)", y = "Grass Height (cm)")+
scale_fill_manual(name = 'My Lines', values = c("darkgreen", "lightgreen")) +
theme(axis.title.x = element_text(color = "black", vjust = -1),
axis.title.y = element_text(vjust = 0.5))
ggplotly(plot)
For some reason, I cannot increase the spaces between the axis labels and graph, even though I have tried to many different ways using vjust
. And I can see some semblance of a legend in the right hand corner. But I cant see the entire thing nor can I zoom out. Is there any issue with my above code?
This is a subset of my data:
GrassHeight HeightUnderCWD
0 0
0 0
0 0
8 16
0 0
0 0
0 0
2 2
6 6
0 0
0 0
1 1
0 0
0 0
0 0
8 15
0 0
7 7
15 15