1

Is there a way to make breaks in my histogram axis if I have values much larger from the rest of my data?

For example using the following dummy data to make a ggplot histogram:

test_data <- c(1,1,1,1,1,1,1,1,1,1,5,5,5,5,5,5,100,100,50,5000)

df = data.frame(test_data)

ggplot(df, aes(test_data))+geom_histogram()

Yields a histogram with a large gapenter image description here

I would love for the x-axis to have bins from 0 to 1000 then a cut then continue from 4000 on. How can I achieve this?

UPDATE

The linked "duplicate" has broken images and even after trying out their suggestions, I did not achieve what I want. I tried geom_histogram(breaks=c(seq(1, 100, by=1),seq(200,1000,by=100), seq(2000,5000, by=1000)) But this gives huge, wide bars and that is not what I want.

Community
  • 1
  • 1
guy
  • 1,021
  • 2
  • 16
  • 40
  • I think you can do this with `plotrix` or `ggplot` is a must? – AK88 Jun 21 '17 at 02:57
  • no i am flexible – guy Jun 21 '17 at 03:02
  • working on it, sir – AK88 Jun 21 '17 at 03:02
  • 1
    I was wrong ... having investigated I couldn't find any way of doing this. Sorry. If I'll find something, will post an answer. – AK88 Jun 21 '17 at 04:17
  • The linked "duplicate" has broken images and even after trying out their suggestions, I did not achieve what I want. – guy Jun 21 '17 at 12:20
  • All the images in the linked question work fine for me. You should make sure you don't have a content filter breaking them. That said, I tend to agree it is not a duplicate. I don't have an answer though, I'm just a reviewer. – Dark Falcon Jun 21 '17 at 19:01

0 Answers0