The use of Python visual library Matplotlib

Source: Internet
Author: User

One. Import data

Import= pd.read_csv ('unrate.csv') unrate['DATE  '] = pd.to_datetime (unrate['DATE')print( Unrate.head (12))
The results are as follows:
DATE VALUE0 1948-01-01 3.41 1948-02-01 3.82 1948-03-01 4.03 1948-04-01 3.94 1948-05-01 3.55 1948-06-01 3.66 1948-07-01 3.67 1948-08-01 3.98 1948-09-01 3.89 1948-10-01 3.710 1948-11-01 3.811 1948-12-01 4.0
Two. Using the Matplotlib Library
Import Matplotlib.pyplot as Plt # %matplotlib Inline # Using The different pyplot functions, we can create, customize, and display a plot. For example, we can use 2 functions to:plt.plot () plt.show ()

The results are as follows:

Three. Inserting data

First_twelve = Unrate[0:12]plt.plot (first_twelve['DATE'), first_twelve['  VALUE']) plt.show ()

Because the x-axis is too compact, the method of rotating the x-axis results in the following.

Plt.plot (first_twelve['DATE'), first_twelve['VALUE']) Plt.xticks (rotation=45)#print Help (plt.xticks)plt.show ()

Four. Setting the x-axis y-axis description

Plt.plot (first_twelve['DATE'), first_twelve['VALUE']) Plt.xticks (rotation=90) plt.xlabel ('Month') Plt.ylabel ( ' unemployment Rate ' ) plt.title ('Monthly unemployment Trends, 1948') plt.show ()

Use of Python visual library matplotlib

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.