matplotlib의 LaTeX 포맷터를 사용하여 float 형식을 지정하려면 다음 단계를 수행할 수 있습니다. -
단계
-
Figure 크기를 설정하고 서브플롯 사이와 주변의 패딩을 조정합니다.
-
numpy를 사용하여 x 및 y 데이터 포인트를 만듭니다.
-
plot()을 사용하여 x 및 y 데이터 포인트를 플로팅합니다. 방법.
-
곡선 사이의 영역을 채웁니다.
-
LaTeX 표현으로 그림의 제목을 설정합니다.
-
그림을 표시하려면 show()를 사용하세요. 방법.
예시
import numpy as np
from matplotlib import pyplot as plt
# Set the figures size
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
# x and y data points
x = np.linspace(-5, 5, 100)
y = x**3/3
# Plot the data points
plt.plot(x, y)
# Fill the area between the curve
plt.fill_between(x, y)
# LaTex representation
plt.title("$area=\int_a^b{x^2dx}$=83.3")
# Display the plot
plt.show() 출력
다음 출력을 생성합니다 -
