matplotlib에서 축, 범례 및 흰색 패딩을 제거하는
Axes
원본 코드 스 니펫은 x 축과 y 축을 숨겨서 그림의 축을 성공적으로 제거합니다. However, this technique may not entirely resolve the issue of white padding and frame around the image.def make_image(inputname,outputname):
data = mpimg.imread(inputname)[:,:,0]
fig = plt.imshow(data)
fig.set_cmap('hot')
plt.axis('off')
plt.savefig(outputname, bbox_inches='tight')
Removing White PaddingTo remove the white padding, we can use the axis('off') method, which hides all axes and borders, leaving only the image itself. 그러나이 방법은 여전히 이미지 주위에 소량의 공백을 남길 수 있습니다.
업데이트 된 코드 스 니펫
def make_image (inputname, outputname) : data = mpimg.imread (inputname) [:, :, 0] 그림 = plt.imshow (데이터) 그림 세트 _cmap ( '핫') plt.axis ( 'off') plt.savefig (outputname, bbox_inches = 'tight')
Axis ( 'off') 및 bbox_inches = 'tight'를 사용하여 모든 축, 범례 및 흰색 패딩을 효과적으로 제거 할 수 있습니다.부인 성명: 제공된 모든 리소스는 부분적으로 인터넷에서 가져온 것입니다. 귀하의 저작권이나 기타 권리 및 이익이 침해된 경우 자세한 이유를 설명하고 저작권 또는 권리 및 이익에 대한 증거를 제공한 후 이메일([email protected])로 보내주십시오. 최대한 빨리 처리해 드리겠습니다.
Copyright© 2022 湘ICP备2022001581号-3