것들 "뻗어"된다 . 기본적으로 플롯의 종횡비가 1 (데이터 좌표) 인 이미지를 표시한다고 가정합니다.
이 동작을 비활성화하고 픽셀을 늘려 플롯을 채우려면 aspect="auto"
을 지정하십시오.
import matplotlib.pyplot as plt
import numpy as np
# Generate some data
x, y = np.random.random((2, 500))
x *= 10
# Make a 2D histogram
H, xedges, yedges = np.histogram2d(x, y, bins=(25, 25))
# Plot the results
fig, ax = plt.subplots(figsize=(8, 8), dpi=80, facecolor='w', edgecolor='k')
extent = [-50, +50, 0, 10]
im = ax.imshow(H, extent=extent, interpolation='nearest')
fig.colorbar(im)
plt.show()
그리고 우리는 단지 imshow
전화에 aspect="auto"
를 추가하여 문제를 해결할 수 있습니다 : 예를 들어
, 당신의 문제를 재현하는 데 (당신의 코드 기준)
import matplotlib.pyplot as plt
import numpy as np
# Generate some data
x, y = np.random.random((2, 500))
x *= 10
# Make a 2D histogram
H, xedges, yedges = np.histogram2d(x, y, bins=(25, 25))
# Plot the results
fig, ax = plt.subplots(figsize=(8, 8), dpi=80, facecolor='w', edgecolor='k')
extent = [-50, +50, 0, 10]
im = ax.imshow(H, extent=extent, interpolation='nearest', aspect='auto')
fig.colorbar(im)
plt.show()
작동하지 않음 : - \ – tamasgal
너무 늦었습니다 :( – bendaizer