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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:07:53+00:00 2026-05-30T19:07:53+00:00

I have produced 3 sets of data which are organised in numpy arrays. I’m

  • 0

I have produced 3 sets of data which are organised in numpy arrays. I’m interested in plotting the probability distribution of these three sets of data as normed histograms. All three distributions should look almost identical so it seems sensible to plot all three on the same axis for ease of comparison.

By default matplotlib histograms are plotted as bars which makes the image I want look very messy. Hence, my question is whether it is possible to force pyplot.hist to only draw a box/circle/triangle where the top of the bar would be in the default form so I can cleanly display all three distributions on the same graph or whether I have to calculate the histogram data and then plot it separately as a scatter graph.

Thanks in advance.

  • 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-30T19:07:54+00:00Added an answer on May 30, 2026 at 7:07 pm

    There are two ways to plot three histograms simultaniously, but both are not what you’ve asked for. To do what you ask, you must calculate the histogram, e.g. by using numpy.histogram, then plot using the plot method. Use scatter only if you want to associate other information with your points by setting a size for each point.

    The first alternative approach to using hist involves passing all three data sets at once to the hist method. The hist method then adjusts the widths and placements of each bar so that all three sets are clearly presented.

    The second alternative is to use the histtype='step' option, which makes clear plots for each set.

    Here is a script demonstrating this:

    import numpy as np
    import matplotlib.pyplot as plt
    
    np.random.seed(101)
    a = np.random.normal(size=1000)
    b = np.random.normal(size=1000)
    c = np.random.normal(size=1000)
    
    common_params = dict(bins=20, 
                         range=(-5, 5), 
                         normed=True)
    
    plt.subplots_adjust(hspace=.4)
    plt.subplot(311)
    plt.title('Default')
    plt.hist(a, **common_params)
    plt.hist(b, **common_params)
    plt.hist(c, **common_params)
    plt.subplot(312)
    plt.title('Skinny shift - 3 at a time')
    plt.hist((a, b, c), **common_params)
    plt.subplot(313)
    common_params['histtype'] = 'step'
    plt.title('With steps')
    plt.hist(a, **common_params)
    plt.hist(b, **common_params)
    plt.hist(c, **common_params)
    
    plt.savefig('3hist.png')
    plt.show()
    

    And here is the resulting plot:

    enter image description here

    Keep in mind you could do all this with the object oriented interface as well, e.g. make individual subplots, etc.

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

Sidebar

Related Questions

I have some data (produced by a legacy application) that I know is invalid
my current code is below. What I have is two sets of data phi
I have a simple openGL ES program which basically sets up two triangles which
I have two sets of data (3 columns: x=categorical, y = numerical, l =
I have two sets of scattered data x y z and x2 y2 z2
I have produced a new Maven Project from gae-archetype-gwt from within IntelliJ, and everything
I have 12 .csv files produced by another program. The .csv files contain numeric
I have an array that is produced from people wanting to reserve a time
I have some HTML that is being produced by a WordPress plugin that is
I have a List of object, produced by JPA q.getResultList() . I would like

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.