matplotlib를 사용하여 레이블이 지정된 단일 눈금을 X축에 추가합니다. 다음 단계를 수행할 수 있습니다.
단계
-
Figure 크기를 설정하고 서브플롯 사이와 주변의 패딩을 조정합니다.
-
x 만들기 및 y numpy를 사용하는 데이터 포인트.
-
plot()을 사용하여 x 및 y 데이터 포인트를 플로팅합니다. 방법.
-
xticks 설정 한 지점에서.
-
틱 라벨 설정 단일 틱 포인트용입니다.
-
그림을 표시하려면 Show()를 사용하세요. 방법.
예
import numpy as np
import matplotlib.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(-5, 5, 50)
y = np.sin(x)
# Plot x and y data points
fig, ax = plt.subplots(1, 1)
p = ax.plot(x, y)
# Set xticks at a point
ax.set_xticks([-1.075])
# Set xticklabels for the point
ax.set_xticklabels(["$\\bf{It\ is -\!1.075\ label}$"])
# Display the plot
plt.show()
출력
다음 출력을 생성합니다 -
