import matplotlib.pyplot as plt from matplotlib.pyplot import MultipleLocator import os import numpy as np # plt.rcParams['font.sans-serif'] = ['SimHei'] plt.rcParams['axes.unicode_minus'] = False ### x_5 = [7.6, 22, 47.9, 88.8] y_5 = [31.1, 36.4, 39.4, 41.0] x_RT = [10.2, 27.6, 57.4, 102.7] y_RT = [38.2, 41.7, 42.7, 44.0] # x_x = [8.94, 25.29, 54.16, 99.01] # y_x = [40.5, 46.9, 49.7, 51.1] x_7 = [37.8, 72.1] y_7 = [43.1, 44.6] x = [37.89, 72.2] y = [44.1, 45.3] # # %color = ['150 205 205', '#CC00FF', '#99CCFF', '#66CC00', '#CC99FF', '#990099', '#66FF33', '#CCCCFF', '#0000CC', '#666666', '#BB5500', '#EEEE00', '#FF3EFF', '#FF88C2', '#FF0033'] ###全局定义字体类型 font = {'family': 'Times New Roman'} plt.rc('font', **font) plt.xlim(5, 105) plt.ylim(30, 50) # 把x轴的刻度间隔设置为10,并存在变量里 ############################### 设置坐标轴间隔 x_major_locator = MultipleLocator(10) ax = plt.gca() ax.xaxis.set_major_locator(x_major_locator) # y_major_locator = MultipleLocator(2) # ay = plt.gca() # ay.yaxis.set_major_locator(y_major_locator) plt.plot(x_5, y_5, marker='p', markersize='15', label='xx(s-x)') plt.plot(x_RT, y_RT, marker='^', markersize='15', label='xx(s-x)') plt.plot(x_7, y_7, marker='h', markersize='15', label='xx(l-x)') plt.plot(x, y, marker='o', markersize='15', label='XX(l-x)') plt.xlabel('Params(M)', family='Times New Roman', fontsize=16) plt.ylabel('AP(%)', family='Times New Roman', fontsize=16) plt.grid() plt.title('xxxxxx', family='Times New Roman', size=16) plt.legend(loc="lower right", prop={'family':'Times New Roman', 'size':13}) plt.show()