Introduction to Matplotlib

Source: Internet
Author: User
Keywords matplotlib matplotlib tutorial matplotlib python
Matplotlib was inspired by MATLAB. MATLAB is a widely used language and tool in the field of data drawing. MATLAB language is process-oriented. Using function calls, MATLAB can easily draw a line with a line of commands, and then use a series of functions to adjust the results.

Matplotlib has a set of drawing interfaces that completely imitate the function form of MATLAB, in the matplotlib.pyplot module. This set of function interfaces facilitates MATLAB users to transition to the matplotlib package

Official website: http://matplotlib.org/

Learning method: learning from the official website examples

http://matplotlib.org/examples/index.html
http://matplotlib.org/gallery.html
 import matplotlib.pyplot as plt
In the drawing structure, figure creates a window, and subplot creates a subplot. All paintings can only be done on sub-pictures. plt means the current sub-picture, if not, create a sub-picture. All you will see is that some tutorials use plt to set, some tutorials use sub-picture properties to set. They often have corresponding function functions.

Figure: Panel (figure), all images in matplotlib are located in figure objects, an image can only have one figure object.

Subplot: Subplot, create one or more subplot objects (namely axes) under the figure object to draw the image.


Configuration parameters:
axex: set the color of the coordinate axis boundary and surface, coordinate scale value and grid display
figure: Control dpi, border color, figure size, and subplot settings
font: font family, font size and style settings
grid: Set grid color and linear
legend: Set the legend and the text display
line: set the line (color, line type, width, etc.) and mark
patch: is a graphical object that fills 2D space, such as polygons and circles. Control line width, color and anti-aliasing settings, etc.
savefig: You can set the saved graphics individually. For example, set the background of the rendered file to white.
verbose: Set matplotlib to output information during execution, such as silent, helpful, debug, and debug-annoying.
xticks and yticks: Set the color, size, direction, and label size for the major and minor scales on the x,y axis.

If these two colors are not enough, you can also define the color value in two other ways:

1. Use HTML hex string color=’#123456’ Use legal HTML color names (’red’,’chartreuse’, etc.).
2. You can also pass in an RGB primitive normalized to [0,1]. color=(0.3,0.3,0.4)

Background color
By providing an axisbg parameter to methods such as matplotlib.pyplot.axes() or matplotlib.pyplot.subplot(), you can specify the background color of the coordinates.

subplot(111,axisbg=(0.1843,0.3098,0.3098))

The libraries that need to be introduced include

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.ticker import MultipleLocator
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.