-3

hs

The plot is just for visualization. The bars rather than starting at a common zero point, begin at min value for that particular bar and end at max value for particular bar. When I use ggplot geom_bar() it sets the min values at the origin. How can I change it to a range bar plot? Thanks.

So, I would like to have min value as the bottom of the bar and max as the top and the bar will show the difference between max and min.

Here is my data:

Min <- c(0.1, 0.0001, 0.01, 0.12)
Max <- c(100, 4000, 1000, 10, 5)
Difference <- c(99.9, 3999.9, 999, 9.99, 4.88)
Ravi Saroch
  • 934
  • 2
  • 13
  • 28
Jenn
  • 15
  • 7
  • [See here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) on making an R question that folks can help with. That includes a sample of data, all necessary code, and a clear explanation of what you're trying to do and what hasn't worked. – camille Dec 10 '19 at 01:14

1 Answers1

0

The data that you provide has such a wild range of values that it looks terrible. One bar has height 5 and another has height 4000. All of the Min values are near zero. I will illustrate one way to do this using some different data. You can make bars like this by starting with a blank plot and adding rectangles for the bars.

## Generate some data
x = 1:20
set.seed(2019)
High = 5 + sin(x/2) + 0.3*rnorm(20)
Low  = High - runif(20, 0.3, 1.3)

## Blank plot
plot(1, type="n", xlab="", ylab="", xlim=range(x), 
    ylim=c(min(Low), max(High)))

## Add rectangles
rect(x - 0.2, Low, x + 0.2, High, col="blue")

Range Bars

G5W
  • 36,531
  • 10
  • 47
  • 80