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 8509069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:20:03+00:00 2026-06-11T03:20:03+00:00

I am generating histograms with matplotlib. I need the bins to be of unequal

  • 0

I am generating histograms with matplotlib.

I need the bins to be of unequal width as I’m mostly interested in the lowest bins.
Right now I’m doing this:

plt.hist(hits_array, bins = (range(0,50,10) + range(50,550,50)))

This creates what I want (the first 5 bins have a width of 10, the rest of 50), but the first five bins are, of course, narrower than the latter ones, as all bins are displayed on the same axis.

Is there a way to influence the x-axis or histogram itself so I can break the scale after the first 5 bins, so all bins are displayed as equally wide?

(I realize that this will create a distorted view, and I’m fine with that, though I wouldn’t mind a bit of space between the two differently scaled parts of the axis.)

Any help will be greatly appreciated.
Thanks!

  • 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-06-11T03:20:05+00:00Added an answer on June 11, 2026 at 3:20 am

    You can use bar and there is no need to split the axis. Here is an example,

    import matplotlib.pylab as plt
    import numpy as np
    
    data = np.hstack((np.random.rand(1000)*50,np.random.rand(100)*500))
    binwidth1,binwidth2=10,50
    bins=range(0,50,binwidth1)+range(50,550,binwidth2)
    
    fig,(ax) = plt.subplots(1, 1)
    
    y,binEdges=np.histogram(data,bins=bins)
    
    ax.bar(0.5*(binEdges[1:]+binEdges[:-1])[:5], y[:5],width=.8*binwidth1,align='center')
    ax.bar(0.5*(binEdges[1:]+binEdges[:-1])[5:], y[5:],width=.8*binwidth1,align='center')
    plt.show()
    

    enter image description here

    In case you really want to split the axis have a look here.

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

Sidebar

Related Questions

I'm currently generating the amount of time given the number of seconds. This is
For generating random string i written code like this But if the function is
I'm generating an unknown amount of checkboxes in my form using mysql, this number
I’m interested in generating 3D height maps for a 2D game I am working
I am generating dynamic page using JSP, I want to save this dynamically generated
From my basic understanding about using matplotlib you store your desired plt in some
The FREQUENCY function in Microsoft Excel is useful for generating histograms. The first parameter
Generating a scaffold like this: rails generate scaffold User name:string email:string creates bits of
For generating PDF from HTML, i need to fill a variable with output from
I'm regularly generating histograms from simulated data, and find it quite helpful to attach

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.