How to visualize all the data in x axis

I use code and successfully complete the figure. But the problem is that in X-axis, all the year is missing, showing only 3 of them just like the image.
My code was :slight_smile

plot(d1$Year, d1$POC, type ="l",xlab="Year", ylab = bquote("POC (" ~ mgm^-3 ~ ")"), col="blue")
par(new = TRUE)
plot(d2$Year, d2$Chl_a, type ="l", xaxt = "n", yaxt = "n",
ylab = "", xlab = "", col = "red", lty = 2)
axis(side = 4)
mtext(expression(paste(Chl-a (mgm^-3))), side = 4, line = 3)
legend("topright", c("POC", "Chl-a"),
col = c("blue", "red"), lty = c(1, 2))

Is there any correcetion needed for visualizing all the year remain in the data

You can customize the breaks and labels and such for dates and times in ggplot2 using the scale_x_date or scale_x_datetime argument, depending on the class of your x variable. See here for the documentation.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.