Technology Programming

Making Histograms in Python

    • 1). Open the terminal application on your Mac or a console window in Windows and type "python -v" at the prompt to ensure that you have Python 2.7; this action tells you the version that you have. If you are using a Mac, the version of Python that came with OS X is not compatible with the add-on libraries that you will have to install; visit Python (python.org) and install Python version 2.7.

    • 2). Download and install NumPy and Matplotlib from the Source Forge (sourceforge.net) open-source repository. Binary installers exist for both Mac OS X and Windows operating systems, so you will not have to deal with arcane command line installation procedures.

    • 3). Open the terminal application in Mac OS X or the console in Windows. Initiate the Python interpreter by typing "Python" at the command line. You will then see the Python prompt. Load the two new libraries with the following "command S":

      >>>>import numpy as np
      >>>>import matplotlib.pyplot as plt

    • 4). Create some data for this histogram by defining the axes of the histogram and generating some random IQ scores around a standard distribution with the following commands:

      >>>>mu, sigma = 100, 15
      >>>>x = mu + sigma * np.random.randn(10000)

    • 5). Create the layout and parameters of the histogram with the following commands:
      n, bins, patches = plt.hist(x, 50, normed=1, facecolor='g', alpha=0.75)

      Add labels and color the bars, or bins, of the histogram with the following commands:
      plt.xlabel('Smarts')
      plt.ylabel('Probability')
      plt.title('Histogram of IQ')
      plt.text(60, .025, r'$\mu=100,\ \sigma=15$')
      plt.axis([40, 160, 0, 0.03])

      Finally, generate the histogram with this command:
      plt.show()
      This will generate a bar graph illustrating IQ scores in the classic bell-curve shape with green bins, with their "y" axis representing IQ scores and their "x" axis representing the number of individuals who reached those scores.

SHARE
RELATED POSTS on "Technology"
WordPress - How to Set up a New Theme to WordPress 3.
WordPress - How to Set up a New Theme to WordPress 3.
Solution of Creative Web Design
Solution of Creative Web Design
The three disciplines of User Experience
The three disciplines of User Experience
Web Design Sheffield Options For Professional Enterprises
Web Design Sheffield Options For Professional Enterprises
Do you have what it takes?
Do you have what it takes?
Segway Cost
Segway Cost
Microsoft Access 2010: What's Coming with Office 2010?
Microsoft Access 2010: What's Coming with Office 2010?
Companies of Web Development in Ireland Provide Designs that Work
Companies of Web Development in Ireland Provide Designs that Work
Penguin Update to Put Red-Flags on Negative SEO
Penguin Update to Put Red-Flags on Negative SEO
Innovative web 2 design templates can make your business famous quickly
Innovative web 2 design templates can make your business famous quickly
Building A Search Engine Friendly Website
Building A Search Engine Friendly Website
Exceptional Advice To Build Up Your Internet Marketing
Exceptional Advice To Build Up Your Internet Marketing
The Benefits of Selecting The Right Hosting Company
The Benefits of Selecting The Right Hosting Company
Is There a Methodology for Making Successful Logos
Is There a Methodology for Making Successful Logos
Benefits of Ruby On Rails Development
Benefits of Ruby On Rails Development
The Power of Colour and Shapes in Your Infant's Life.
The Power of Colour and Shapes in Your Infant's Life.
Advantages of Hiring PSD To HTML Service Providers
Advantages of Hiring PSD To HTML Service Providers
How to Make Responsive Web Design Attractive?
How to Make Responsive Web Design Attractive?
Converting PSD to Responsive HTML
Converting PSD to Responsive HTML
Just a few realy really hints and tips when it comes to website design but look for.
Just a few realy really hints and tips when it comes to website design but look for.

Leave Your Reply

*