Computer >> 컴퓨터 >  >> 프로그램 작성 >> Python

matlibplot 축의 눈금과 표시를 끄는 방법은 무엇입니까?

<시간/>

matplotlib 축의 눈금과 표시를 끄려면 다음 단계를 수행할 수 있습니다. -

  • 그림 크기를 설정하고 서브플롯 사이 및 주변 여백을 조정합니다.
  • numpy를 사용하여 x 및 y 데이터 포인트를 생성합니다.
  • plot()을 사용하여 x 및 y 데이터 포인트를 플로팅합니다. 방법.
  • 플롯의 현재 축을 가져옵니다.
  • set_tick_params() 사용 X 및 Y축 레이블 표시를 숨깁니다.
  • set_xticks() 사용 및 set_yticks() X 및 Y축 눈금 표시를 숨깁니다.
  • 그림을 표시하려면 show()를 사용하세요. 방법.

예시

import numpy as np
from matplotlib import pyplot as plt

# Set the figure size
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True

# Create x and y data points
x = np.linspace(-10, 10, 100)
y = np.sin(x)

plt.plot(x, y)
ax = plt.gca()

# Hide X and Y axes label marks
ax.xaxis.set_tick_params(labelbottom=False)
ax.yaxis.set_tick_params(labelleft=False)

# Hide X and Y axes tick marks
ax.set_xticks([])
ax.set_yticks([])

plt.show()

출력

다음 출력을 생성합니다.

matlibplot 축의 눈금과 표시를 끄는 방법은 무엇입니까? matlibplot 축의 눈금과 표시를 끄는 방법은 무엇입니까?