Data analysis using python: "Matplotlib"

Source: Internet
Author: User
Tags mathematical functions install matplotlib

First, Brief introduction matplotlib
1. Matplotlib is a powerful toolkit for Python drawing and data visualization
2. Installation method: Pip Install Matplotlib
3. Citation method: Import Matplotlib.pyplot as Plt
4. Drawing function: Plt.plot ()
5. Display Image: Plt.show ()



--Linetype LineStyle (-,-.,--,.. )

-colour color (b,g,r,y,k,w,...
2, plot function draw multiple curves
3, Pandas package support for plot

Three, matplotlib-image annotation
--Set Image title: Plt.title ()
--Set X axis name: Plt.xlabel ()
--Set Y axis name: Plt.ylabel ()
--Set X axis range: Plt.xlim ()
--Set Y axis range: Plt.ylim ()
--Set X-axis scale: plt.xticks ()
--Set Y-axis scale: plt.yticks ()
--Set diagram example: Plt.legend ()

Four, matplotlib example--Drawing mathematical function image
Use the Matplotlib module to draw mathematical functions in a window y=x, y=x2, y=3x3+5x2+2x+1 images, distinguish them using different color lines, and use the legend to show what functions each line represents.

Five, Matplotlib: Canvas and sub-chart
Canvas: Figure
--fig = Plt.figure ()
Figure: Subplot
--ax1 = Fig.add_subplot (2,2,1)
Adjust Sub-chart spacing:
--subplots_adjust (left, bottom, right, top, wspace, hspace)

Vi. supported diagram types for matplotlib-

Seven, matplotlib--plot candlestick chart
There are many function interfaces for drawing financial related graphs in the Matplotlib.finanace sub-package.
Draw a candlestick chart: Matplotlib.finance.candlestick_ochl function

Viii. Sample Code
First download before use: Pip install Matplotlib
---then introduced: Import Matplotlib.pylot as Plt
---drawing function: Plt.plot ()
---display function: plt.show ()

Use Plt.plot? To view its parameters
We can change the shape of this line by adding parameters.

Data analysis using python: "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.