0

I'm using this code in R to graph the following variables:

> ggplot(NDVI, aes(x = Mision, y= MEAN))+
+     geom_point(stat = "summary")

which produces the following plot:

a scatter plot evaluating a crop's NDVI value

As you can see, the x-axis shows a point in time where NDVI for the crop was evaluated. However, it does not display the full set of numbers (1 - 8). It's displaying only the even numbers. How do I tell ggplot that I want the x axis to show the lables for all of the missions?.

The x axis corresponds to a discrete set of numbers. We performed multiple missions where we collected data and each mission was labeled 1 - 8; missions 2 and 5 do not have data because on those sorties there was not data collected.

This is my data: https://github.com/escalante-cr/NDVI_calculation

Sergio Escalante
  • 219
  • 1
  • 2
  • 6
  • 2
    What's "full set of numbers"? Please post example of your data. – pogibas Aug 21 '17 at 19:01
  • 2
    I don't understand what your question is. See how to create a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input data so we can run the code. More clearly describe the desired output. Right now you says this is "exactly what you're looking for" so i'm not sure what you want. – MrFlick Aug 21 '17 at 19:04
  • 2
    I take your question to mean, how to add tick marks for every integer in the range of x. If this is correct, try adding `+scale_x_discrete(breaks=seq(1,8,1))`, or whatever tick marks you want. – Yannis Vassiliadis Aug 21 '17 at 19:04
  • 2
    One idea is to do add a `+scale_x_continuous(breaks = unique(NDVI$Mision))` similar to what Yannis suggested. However, without a reproducible example, we can only guess what you actually want. It's also unclear what `type` your `x` variable is so we don't know if `scale_x_continuous` or `scale_x_discrete` would be more appropriate – Mike H. Aug 21 '17 at 19:14
  • Thank you everyone, I've edited the original text with your comments taken into consideration. – Sergio Escalante Aug 22 '17 at 14:35

1 Answers1

1

Adding this to the end of your code will do the trick:

+ scale_x_continuous(breaks = c(seq(8)))
Jordan
  • 365
  • 1
  • 10