import matplotlib. pyplot as plt
import numpy as np
import pandas as pd
plt. rcParams[ 'font.sans-serif' ] = [ 'Microsoft YaHei' ]
plt. rcParams[ 'axes.unicode_minus' ] = False
一、子图
1、创建子图 plt.subplot() 或 fig.add_subplot()
plt. subplot( nrows, ncols, index,
label,
title,
xlabel, ylabel
xlim, ylim
xticklabels, yticklabels
xticks, yticks
)
fig = plt. figure( )
fig. add_sublpot( 参数同上)
fig, ( ( ax1, ax2) , ( ax3, ax4) ) = plt. subplots( 2 , 2 )
fig, ax = plt. subplots( 2 , 2 )
ax1 = ax[ 0 , 1 ]
plt. figure( figsize= ( 18 , 4 ) )
ax1 = plt. subplot( 1 , 3 , 1 , ylim= ( 0 , 10 ) , title= '我是子图1' )
ax2 = plt. subplot( 1 , 3 , 2 , xticks= [ 1 , 2 , 3 , 4 , 5 ] )
ax3 = plt. subplot( 1 , 3 , 3 , yticklabels= '一二三四五' )
plt. show( )
fig = plt. figure( figsize= ( 18 , 4 ) )
ax1 = fig. add_subplot( 1 , 3 , 1 , ylim= ( 0 , 10 ) , title= '我是子图1' )
ax2 = fig. add_subplot( 1 , 3 , 2 , xticks= [ 1 , 2 , 3 , 4 , 5 ] )
ax3 <