1

It seems like I have a very simple problem:

I created a plot like this with ggplot2:

Negative Values

Using this code:

library(ggplot2)
df <- read.table(header=T, text='  x y
              1   -1
              2   -1.5
              3  -1.6
              4  -1.7
              5  -1')

ggplot(df, aes(x,y)) +
geom_area(size=1,colour="red")

As you can see, the graph values are negative.

I want to fill the area under the graph line.

It should look like this

The duplicate path doesn't help me with that.

Thanks for your help!

schmitzi89
  • 47
  • 7
  • 1
    it would be easier to help you if you provided a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input data. – MrFlick Jun 20 '17 at 14:54
  • Also, please add the code you used to produce the plot. – G5W Jun 20 '17 at 14:56
  • I have to agree that the duplicate doesn't answer the question. And the duplicate is actually much more contrived than this simple question. So please vote to reopen. – ziggystar Jun 21 '17 at 07:18
  • Here is an answer in a gist: https://gist.github.com/ziggystar/4e8648e8f668050bee57027af6093185 . It applies a shifting transform to the y-axis. You have to figure out the correct shift value yourself, though. I'll turn this into an answer once the question is reopened. – ziggystar Jun 21 '17 at 07:25

0 Answers0