1. Matplotlib多 y 轴折线图–科研美图
from mpl_toolkits. axisartist. parasite_axes import HostAxes, ParasiteAxes
import matplotlib. pyplot as plt
import numpy as np
import pandas as pd
plt. rcParams[ 'font.sans-serif' ] = [ 'SimHei' ]
plt. rcParams[ 'axes.unicode_minus' ] = False
data= pd. read_csv( r'C:\Users\mengx\Desktop\机器学习岩石力学参数预测部分\all_ma_log.csv' , encoding= 'gb2312' , engine= 'python' )
print ( data. columns)
fig = plt. figure( 1 , figsize= ( 10 , 4 ) )
ax_1 = HostAxes( fig, [ 0 , 0 , 0.9 , 0.9 ] )
ax_2 = ParasiteAxes( ax_1, sharex= ax_1)
ax_3 = ParasiteAxes( ax_1, sharex= ax_1)
ax_4 = ParasiteAxes( ax_1, sharex= ax_1)
ax_5 = ParasiteAxes( ax_1, sharex= ax_1)
ax_6 = ParasiteAxes( ax_1, sharex= ax_1)
ax_1. parasites. append( ax_2)
ax_1. parasites. append( ax_3)
ax_1. parasites. append( ax_4)
ax_1. parasites. append( ax_5)
ax_1. parasites. append( ax_6)
ax_1. axis[ 'right' ] . set_visible( False )
ax_1. axis[ 'top' ] . set_visible( False )
ax_2. axis[ 'right' ] . set_visible( True )
ax_2. axis[ 'right' ] . major_ticklabels. set_visible( True )
ax_2. axis[ 'right' ] . label. set_visible( True )
ax_1. set_ylabel( 'cof' )
ax_1. set_xlabel( 'Distance (m)' )
ax_2. set_ylabel( 'Temperature' )
ax_3. set_ylabel( 'load' )
ax_4. set_ylabel( 'CP' )
ax_5. set_ylabel( 'Wear' )
ax_6. set_ylabel( 'Wear' )
three_axisline = ax_3. get_grid_helper( ) . new_fixed_axis
four_axisline = ax_4. get_grid_helper( ) . new_fixed_axis
five_axisline = ax_5. get_grid_helper( ) . new_fixed_axis
six_axisline = ax_6. get_grid_helper( ) . new_fixed_axis
ax_3. axis[ 'right2' ] = three_axisline( loc= 'right' , axes= ax_3, offset= ( 40 , 0 ) )
ax_4. axis[ 'right3' ] = four_axisline( loc= 'right' , axes= ax_4, offset= ( 80 ,