I was building a scatterplot to correlate the abundance of certain organisms with Temperature. While building the graph I realized that the x axis values do not appear.
This is an example of how my dataset looks like:
> dput(head(abundance))
structure(list(OGA_ID = c(20L, 22L, 66L, 75L, 91L), sample_ID = structure(c(5L,
1L, 2L, 3L, 4L), .Label = c("TARA_N010000218", "TARA_N010000238",
"TARA_N010000911", "TARA_N010000955", "TARA_N010000980"), class = "factor"),
vlookup = c(2.6820250147109e-06, 4.2504952889635e-07, 3.098736273373e-07,
4.7282955865616e-07, 6.4437058525603e-07), relative.abundance = c(2.6820250147109e-06,
4.2504952889635e-07, 3.098736273373e-07, 4.7282955865616e-07,
6.4437058525603e-07), log = c(-5.57153717588776, -6.37156046083652,
-6.50881538403584, -6.32529538161919, -6.19086429282228),
station = structure(c(3L, 2L, 2L, 1L, 3L), .Label = c("TARA_188",
"TARA_205", "TARA_210"), class = "factor"), depth = structure(c(2L,
3L, 2L, 1L, 2L), .Label = c("DCM", "MES", "SRF"), class = "factor"),
size.fraction = structure(c(2L, 2L, 2L, 2L, 1L), .Label = c("[>0.8µm]",
"[0.8-20µm]"), class = "factor"), temperature = c(61.5754,
72.4693, 72.4456, 78.3555, 61.5754)), row.names = c(NA, 5L
), class = "data.frame")
This is my code:
{r, fig.width=10, fig.height=5}
library(ggplot2)
abundance_environment <- read.table('/home/agalvez/data/environmental_data/vanellid/environmental_parameters.csv', sep="\t", header=TRUE)
lineplot <- ggplot(abundance_environment, aes( x = abundance_environment$temperature...C., y = abundance_environment$log, group = abundance_environment$Depth_Nominal , colour = abundance_environment$Depth_Nominal)) +
geom_point( size =2, shape =16) +
xlab("Temperature(ºC)") + ylab("Relative abundance") + ggtitle("Abundance-Temperature") +
theme_minimal() +
labs(colour = "Depth")
lineplot
I do not see why the axis are hidden. Could someone help me with that?
Thanks in advance!
The issue with my code was that I was specifying the dimensions of the plot and this was hiding the x-axis.
So I solved it by changing {r, fig.width=10, fig.height=5}
by simply {r}
.