SoFunction
Updated on 2024-11-13

Python using matplotlib to draw multiple graphs to display individually example method

This article example describes how Python uses matplotlib to draw multiple graphs to display individually. Shared for your reference, as follows:

I Code

import numpy as np
import  as plt
# Create an array of self variables
x= (0,2*,500)
# Create an array of function values
y1 = (x)
y2 = (x)
y3 = (x*x)
#Creating Graphics
(1)
'''
It means to locate the 1st diagram in a diagram with 4 subdiagrams in 2 rows and 2 columns to perform the operation (drawing).
The 1 at the end indicates the first subfigure. The number changes to locate a different subfigure.
'''
# First row, first column of graphics
ax1 = (2,2,1)
# First row, second column of graphics
ax2 = (2,2,2)
#The second line
ax3 = (2,1,2)
#Select ax1
(ax1)
# Plotting the red curve
(x,y1,color='red')
# Limit y-axis range
(-1.2,1.2)
#Select ax2
(ax2)
# Plotting the blue curve
(x,y2,'b--')
(-1.2,1.2)
#Select ax3
(ax3)
(x,y3,'g--')
(-1.2,1.2)
()

II. Operational results

More about Python related content can be viewed on this site's topic: theSummary of Python mathematical operations techniques》、《Summary of Python image manipulation techniques》、《Python Data Structures and Algorithms Tutorial》、《Summary of Python function usage tips》、《Summary of Python string manipulation techniquesand thePython introductory and advanced classic tutorials

I hope that what I have said in this article will help you in Python programming.