matplotlib 그림에서 색상과 선 스타일을 모두 순환하려면 다음 단계를 수행하면 됩니다.
단계
-
Figure 크기를 설정하고 서브플롯 사이와 주변의 패딩을 조정합니다.
-
현재 rcParams 설정 , 색상 포함 및 선 스타일 .
-
plot()을 사용하여 데이터 포인트를 플로팅합니다. 방법.
-
그림을 표시하려면 Show()를 사용하세요. 방법.
예시
import matplotlib.pyplot as plt
from cycler import cycler
# Set the figure size
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
# Set the rcParams with color or linestyle
plt.rc('axes', prop_cycle=(cycler('color', ['r', 'g', 'b', 'y']) +
cycler('linestyle', [':', '-.', '-', '--'])))
# Plot the data points
plt.plot([0, 5, 2, 1])
plt.plot([2, 6, 3, 1])
plt.plot([3, 8, 5, 1])
plt.plot([4, 9, 0, 3])
plt.show() 출력
다음 출력을 생성합니다 -
