Python matplotlib drawing multiple sub graphs

Source: Internet
Author: User
Tags sca
"" To
draw multiple children
a figure object can contain more than one child graph (Axes), in Matplotlib, a plot area, called a child graph, with Axes object, you can use subplot () to quickly draw a chart containing multiple child graphs. It is called as follows: the
entire drawing area of the subplot (numrows,numcols,plotnum)
chart is divided into numrows rows and Numcols columns, and then numbering each region in Left-to-right order, The upper-left area is numbered 1. The Plotnum parameter specifies the area of the created Axes object ""
"
import numpy as NP
import Matplotlib.pyplot as Plt
plt.figure (1) #创建图表1
plt.figure (2) #创建图表2
Ax1=plt.subplot (211) #在图表2中创建子图1
Ax2=plt.subplot (212) #在图表2中创建子图2
x= Np.linspace (0,3,100) for
i in Xrange (5):
    plt.figure (1)
    Plt.plot (X,np.exp (I*X/3))
    Plt.sca (AX1)
    Plt.plot (X,np.sin (i*x))
    Plt.sca (ax2)
    Plt.plot (X,np.cos (i*x))
plt.show ()

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.