Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1897974
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:42:37+00:00 2026-05-17T06:42:37+00:00

I have data that is mostly centered in a small range (1-10) but there

  • 0

I have data that is mostly centered in a small range (1-10) but there is a significant number of points (say, 10%) which are in (10-1000). I would like to plot a histogram for this data that will focus on (1-10) but will also show the (10-1000) data. Something like a log-scale for th histogram.

Yes, i know this means not all bins are of equal size

A simple hist(x) gives
alt text
while hist(x,breaks=c(0,1,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2,3,4,5,7.5,10,15,20,50,100,200,500,1000,10000))) gives
alt text

none of which is what I want.

update
following the answers here I now produce something that is almost exactly what I want (I went with a continuous plot instead of bar-histogram):

breaks <- c(0,1,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2,4,8)
ggplot(t,aes(x)) + geom_histogram(colour="darkblue", size=1, fill="blue") + scale_x_log10('true size/predicted size', breaks = breaks, labels = breaks)![alt text][3]

alt text
the only problem is that I’d like to match between the scale and the actual bars plotted. There two options for doing that : the one is simply use the actual margins of the plotted bars (how?) then get “ugly” x-axis labels like 1.1754,1.2985 etc. The other, which I prefer, is to control the actual bins margins used so they will match the breaks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T06:42:38+00:00Added an answer on May 17, 2026 at 6:42 am

    Using ggplot2 seems like the most easy option. If you want more control over your axes and your breaks, you can do something like the following :

    EDIT : new code provided

    x <- c(rexp(1000,0.5)+0.5,rexp(100,0.5)*100)
    
    breaks<- c(0,0.1,0.2,0.5,1,2,5,10,20,50,100,200,500,1000,10000)
    major <- c(0.1,1,10,100,1000,10000)
    
    
    H <- hist(log10(x),plot=F)
    
    
    plot(H$mids,H$counts,type="n",
          xaxt="n",
          xlab="X",ylab="Counts",
          main="Histogram of X",
          bg="lightgrey"
    )
    abline(v=log10(breaks),col="lightgrey",lty=2)
    abline(v=log10(major),col="lightgrey")
    abline(h=pretty(H$counts),col="lightgrey")
    plot(H,add=T,freq=T,col="blue")
    #Position of ticks
    at <- log10(breaks)
    
    #Creation X axis
    axis(1,at=at,labels=10^at)
    

    This is as close as I can get to the ggplot2. Putting the background grey is not that straightforward, but doable if you define a rectangle with the size of your plot screen and put the background as grey.

    Check all the functions I used, and also ?par. It will allow you to build your own graphs. Hope this helps.

    alt text

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have YAML data that looks sort of like this, but ~150k of it:
Let's say I have data structures that're something like this: Public Class AttendenceRecord Public
I have a Java program that is mostly GUI and it shows data that
I have data that looks like CUSTOMER, CUSTOMER_ID, PRODUCT ABC INC 1 XYX ABC
I have data that needs to be executed on a certain background thread. I
I have data that looks like this: entities id name 1 Apple 2 Orange
I have SQL data that looks like this: events id name capacity 1 Cooking
I have some data that I want to store somewhere in my Rails app
For whatever reason, I have a lot of clients that have existing data that's
We have some input data that sometimes appears with &nbsp characters on the end.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.