Line chart
import matplotlib.pyplot as plt
from matplotlib.ticker import MultipleLocator,
# x axis
x=[10,20,30,40,50,60,70,80,90]
# y axis
y1 = [0.9895, 0.9898, 0.9850, 0.9848, 0.9841, 0.9841, 0.9837, 0.9831, 0.9832]
y2 = [0.9863, 0.9896, 0.9836, 0.9847, 0.9803, 0.9794, 0.9814, 0.9807, 0.9792]
y3 = [0.9832, 0.9811, 0.9807, 0.9792, 0.9749, 0.9792, 0.9800, 0.9773, 0.9761]
y4 = [0.9811, 0.9795, 0.9753, 0.9720, 0.9711, 0.9743, 0.9723, 0.9660, 0.9621]
y5 = [0.9820, 0.9817, 0.9797, 0.9776, 0.9721, 0.9757, 0.9741, 0.9682, 0.9634]
fig = plt.figure(figsize=(4,4),dpi=100) #draw a picture
ax1 = fig.add_subplot(111) #add subgraph
Set sub scale
# #modify secondary scale
xminorLocator = MultipleLocator(10) #take x set the axis scale label to a multiple of 5
yminorLocator = MultipleLocator(0.05) #add this y axis scale label set to 0 . a multiple of 1
# #set the position of the secondary scale label without label text formatting
ax1.xaxis.set_minor_locator(xminorLocator)
ax1.yaxis.set_minor_locator(yminorLocator)
plt.minorticks_on() #display sub scale lines
# plt.minorticks_off() #do not display sub scale lines
Set Color - Line Shape - Label - Line Weight - Point Shape
line2 = ax1.plot(x,y2,'#00008B',linestyle="-.",label='B',linewidth=1.5,marker='>')
line3 = ax1.plot(x,y3,'#FF8C00',linestyle="-.",label='N',linewidth=1.5,marker='<')
line4 = ax1.plot(x,y4,'#808080',linestyle="-.",label='D',linewidth=1.5,marker='^')
line5 = ax1.plot(x,y5,'#008000',linestyle="-.",label='S',linewidth=1.5,marker='v')
line1 = ax1.plot(x,y1,'#FF0000',linestyle="-.",label='A',linewidth=1.5,marker='d')
Marker point shape

linestyle Line shape

Display scales all around
#label position :loc frameon: is the label border displayed
ax1.legend(loc='best', prop={'family':'Times New Roman', 'size':8},frameon=True)
#scale orientation :direction (in,out,inout ), primary and secondary tick marks :which ['major','minor'] set the length, width, and surrounding display of the scale
ax1.tick_params(direction='inout',which='major',length=5,width=2,bottom=True,top=True,left=True,right=True)
plt.tick_params(direction='inout',which='minor',length=2,bottom=True,top=True,left=True,right=True)
#set up x the scale value displayed on the axis
plt.xticks([20,40,60,80],fontproperties = 'Times New Roman', fontsize=8)
#set up y the scale value displayed on the axis
plt.yticks([0.85,0.90,0.95,1],fontproperties = 'Times New Roman', fontsize=8)
#set up x axis labels
plt.xlabel('Test set (%)',fontdict={'family' : 'Times New Roman', 'size':12})
#set up y axis labels
plt.ylabel('Accuracy (%)',fontdict={'family' : 'Times New Roman', 'size':12})
Set whether to display tick marks
plt.grid(b=1,linestyle="--",axis='both')
#b=0 or False do not display . axis='x'only display x axis . axis='y'only display y axis
plt.savefig('./Figure/LR-L2.pdf',dpi=100, bbox_inches="tight")
plt.show()
