Python uses the Pylab library to draw the histogram function

Source: Internet
Author: User
This article mainly introduces Python using Pylab Library to achieve the histogram function, combined with instance form analysis of Python data read, traverse and based on the Pylab library to draw histograms of the relevant operation skills, the need for friends can refer to the next

The examples in this article describe Python's ability to draw histograms using the Pylab library. Share to everyone for your reference, as follows:

Python histogram

#!/usr/bin/python#-*-coding:utf-8-*-import pylab as Pldatafile = "DataList.txt" templist = []with open (DataFile, "R") as Data: For  everline in data:    arreverline = [Float (index) for index in Everline.split ()]    templist.append ( Arreverline[0]) pl.hist (templist,100) Pl.xlabel ("Histogram title", fontproperties= ' Simhei ') pl.show ()

DataList.txt Content

14 2 1 0.5 0.5 0 1 0.5 1.5 18.519 2 2 0.5 1 0 1 0.5 0 2119.5 2 1.5 2 0 0.5 2 0 1 2017.5 1.5 1 1.5 2 0 1.5 0 0 18.519.5 2 2  2 0.5 0 1 0 0.5 19.516.5 2 0.5 1 0 0.5 0.5 0 0.5 19.515.5 2 1 1.5 0 0 1 0.5 1 17.513.5 1.5 1 1 2 0 2 0.5 2 2014.5 2 1.5 2 0 0 1 0 2 18.516 2 2 1.5 1 0.5 1 0 2 19.5 ...

Output results


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.