Python 은 하위 그림 그리 기 및 하위 그림 눈금 변환 등 문 제 를 실현 합 니 다.

1.그림 과 관련 된 대 비 는 서브 맵 형식 으로 보 여 주 며 먼저 효 과 를 본다.

2.다음 과 같은 코드 를 그립 니 다.

accuracy_alexnet_clef = [78.05, 78.43, 78.65, 78.61, 78.69]
accuracy_resnet_clef  = [84.56, 84.84, 85.07, 85.01, 85.13]
accuracy_alexnet_office10 = [87.30, 87.57, 87.78, 87.72, 87.50]
accuracy_resnet_office10  = [96.31, 96.35, 96.62, 96.43, 96.15]
orders = ['2', '3', '5', '10', '20']
names = ['alexnet', 'resnet']
#       
f, ax = plt.subplots(2,1,figsize=(6, 8))
#          
x = [i for i in range(len(orders))]
#          
x1 = [i + 0.35 for i in range(len(orders))]
#          
plt.subplots_adjust(wspace =0, hspace =0.4)
#       
figure_1 = ax[0]
#   x      
figure_1.set_xticks([i+0.15 for i in x])
figure_1.set_xticklabels(orders)
#   y    
figure_1.set_ylim(bottom=77,top=86)
#      ,x  x   ,accuracy_alexnet_clef  y    ,alpha     ,width      
# label    
figure_1.bar(x, accuracy_alexnet_clef, alpha=0.7, width = 0.35, facecolor = '#4c72b0', label='Alexnet')
figure_1.bar(x1, accuracy_resnet_clef, alpha=0.7, width = 0.35, facecolor = '#dd8452', label='Resnet')
figure_1.set_ylabel('Accuracy%') #   y    
figure_1.set_xlabel('Order') #   x    
figure_1.set_title('Alexnet') #         
figure_1.legend() #        
#       
figure_2 = ax[1]
figure_1.set_xticks([i+0.15 for i in x])
figure_1.set_xticklabels(orders)
figure_2.set_ylim(bottom=77,top=100)
figure_2.bar(x, accuracy_alexnet_office10,alpha=0.7,width = 0.35,facecolor = '#c44e52', label='Alexnet')
figure_2.bar(x1, accuracy_resnet_office10,alpha=0.7,width = 0.35,facecolor = '#5f9e6e', label='Alexnet')
# figure_2.bar(orders, accuracy_resnet_clef,alpha=0.7,width = 0.35,facecolor = '#dd8452')
figure_2.set_ylabel('Accuracy%')
figure_2.set_xlabel('Order')
figure_2.set_title('Resnet')
figure_2.legend()
f.suptitle('ImageCLEF_DA') #      
plt.show()
추가:python 에서 subplot 가 하위 그림 을 그 릴 때 하위 그림 좌표 축 라벨 과 제목 이 겹 치 는 문 제 를 해결 합 니 다.
1.문제 설명
python 의 matplotlib 의 subplot 를 사용 하여 하위 그림 을 그 릴 때 정보 가 서로 겹 치 는 상황 이 발생 합 니 다.
在这里插入图片描述
2.해결 방안
plt.show()앞 에 코드 plt.tight 추가layot()가 해결 할 수 있 습 니 다.

plt.subplot(211)
plt.figure(1)
plt.hist(x, 10)
plt.title("Histogram of sample points")
plt.subplot(212)
plt.plot(x,X.pdf(x))
plt.title("Probability Density Function(PDF)")
plt.tight_layout()
plt.show()
在这里插入图片描述
이상 은 개인 적 인 경험 이 므 로 여러분 에 게 참고 가 되 기 를 바 랍 니 다.여러분 들 도 저 희 를 많이 응원 해 주시 기 바 랍 니 다.

좋은 웹페이지 즐겨찾기