效果图
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
FONT_SIZE = 18
COLORS = ["#468de4", 'orange', 'green', '#e44a44', 'purple', 'grey']
fig = plt.figure(figsize=(14,6))
ax1 = plt.subplot(121)
ax21 = fig.add_subplot(4, 2, (2, 6))
ax22 = plt.subplot(428, sharex=ax21)
# 4 landmarks 1 agent
ax1.set_title("sin", fontsize=FONT_SIZE)
ax1.grid()
ax1.set_xlabel('x_label', fontdict={'size':FONT_SIZE})
ax1.set_ylabel('y_label', fontdict={'size':FONT_SIZE})
ax1.tick_params(labelsize=FONT_SIZE)
data_x = np.arange(100) / 10.
data_y = np.sin(data_x)
ax1.plot(data_x, data_y, label='sin', c=COLORS[0])
# 4 landmarks 1 agent
ax21.set_title("cos", fontsize=FONT_SIZE)
ax21.tick_params(labelsize=FONT_SIZE)
ax21.spines['bottom'].set_visible(False)
ax21.tick_params(labeltop=False, labelbottom=False) # don't put tick labels at the top
ax21.tick_params(top=False, right=False) # don't put tick labels at the top
ax21.grid()
ax21.set_ylim(0.45, 1.)
ax22.set_ylim(-1., -0.55)
ax22.set_xlabel('x_label', fontdict={'size':FONT_SIZE})
ax22.tick_params(labelsize=FONT_SIZE)
ax22.spines['top'].set_visible(False)
ax22.xaxis.tick_bottom()
ax22.grid()
fig.subplots_adjust(hspace=0.05)
kwargs = dict(marker=[(-1, -.5), (1, .5)], markersize=12,
linestyle="none", color='k', mec='k', mew=1, clip_on=False)
ax21.plot([0, 1], [0, 0], transform=ax21.transAxes, **kwargs)
ax22.plot([0, 1], [1, 1], transform=ax22.transAxes, **kwargs)
data_y = np.cos(data_x)
ax21.plot([], [], label='sin', c=COLORS[0])
ax21.plot(data_x, data_y, label='cos', c=COLORS[1])
ax22.plot(data_x, data_y, label='cos', c=COLORS[1])
ax21.legend(ncol=2, loc='center', bbox_to_anchor=(-0.1,1.14), fontsize=12, columnspacing=0.25)
plt.subplots_adjust(left=0.09, right=0.98)
plt.savefig('test.pdf') # vector img
plt.show()