ax.get_ylim()을 사용하려면 matplotlib의 메서드를 사용하면 다음 단계를 수행할 수 있습니다.
단계
-
Figure 크기를 설정하고 서브플롯 사이와 주변의 패딩을 조정합니다.
-
새 그림을 만들거나 기존 그림을 활성화하세요.
-
하위 플롯 배열의 일부로 그림에 '도끼'를 추가합니다.
-
numpy를 사용하여 임의의 데이터 포인트를 만듭니다.
-
plot()을 사용하여 y 데이터 포인트를 플로팅합니다. 방법.
-
ax.get_ylim() 사용 인쇄하는 방법입니다.
-
그림을 표시하려면 Show()를 사용하세요. 방법.
예시
import numpy as np
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
fig = plt.figure()
# Add an axes to the figure
ax = fig.add_subplot(1, 1, 1)
# Create random data points using numpy
y = np.random.rand(10)
# Plot the data points
ax.plot(y, 'b')
# Print the data points using ax.get_ylim
print("ylim:", ax.get_ylim())
plt.show()
출력
다음 출력을 생성합니다 -

콘솔에서 ylim 값을 얻을 수 있습니다-
ylim: (0.011546568085342858, 1.0373520884865295)