0

I'd like to put legend and more values in x limits.

test <- data.frame(x = runif(10), y = runif(10), mean_y = 0.1) 
ggplot(test, aes(x = x, y = y)) + geom_point(color = 'red') +
  geom_line(aes(x, mean_y))
Wagner Jorge
  • 430
  • 3
  • 15
  • Could you include a dataset, and other elements of a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example?rq=1)? Otherwise, checkout the [ggplot reference](http://ggplot2.tidyverse.org/reference/) and Winston Chang's [cookbook](http://www.cookbook-r.com/Graphs/). – wibeasley Jun 19 '18 at 14:40
  • I insert a MWE. – Wagner Jorge Jun 19 '18 at 15:21
  • What do you mean by "more values"? Like you want to change the limits on what's shown along the x axis, or you want more axis breaks? You don't have a legend because nothing is being mapped to any aesthetics that would show legends, such as fill, color, or linetype. You can use a dummy value to do that; there should be lots of other SO posts to show this – camille Jun 19 '18 at 15:32
  • I'd like to show seq(0, 1, 0.1) in x limits. – Wagner Jorge Jun 19 '18 at 15:42
  • 1
    So that would be the breaks in your `scale_x_continuous`. What would be in the legend? Like I said, there's nothing assigned to an aesthetic that creates a legend – camille Jun 19 '18 at 16:33

1 Answers1

0

Your question needs a bit more explanation and a reproducible example, but to get "more values in x limits" you can try adding

+ expand_limits(x = c(1, 1000))

Just replace the values in the vector by the ones that actually fit your needs.

EvenStar69
  • 243
  • 3
  • 15