Python에서 ogive 차트를 만드는 방법
ogive 는 데이터 세트에서 특정 값보다 높거나 낮은 데이터 값의 개수를 나타내는 그래프입니다. 이 튜토리얼에서는 Python에서 탄두를 생성하는 방법을 설명합니다.
예: Python에서 Ogive를 만드는 방법
Python에서 데이터세트에 대한 목표를 생성하려면 다음 단계를 완료하세요.
1단계: 데이터세트를 만듭니다.
먼저 간단한 데이터 세트를 만들 수 있습니다.
import numpy as np #create array of 1,000 random integers between 0 and 10 np.random.seed(1) data = np.random.randint(0, 10, 1000) #view first ten values data[:10] array([5, 8, 9, 5, 0, 0, 1, 7, 6, 9])
2단계: 탄두를 생성합니다.
그런 다음 numpy.histogram 함수를 사용하여 클래스와 클래스 빈도를 자동으로 찾을 수 있습니다. 그런 다음 matplotlib를 사용하여 탄두를 생성할 수 있습니다.
import numpy as np import matplotlib.pyplot as plt #obtain histogram values with 10 bins values, base = np.histogram(data, bins=10) #find the cumulative sums cumulative = np.cumsum(values) # plot the warhead plt.plot(base[:-1], cumulative, 'ro-')
글머리 기호 차트는 numpy.histogram 함수에서 지정하는 상자 수에 따라 다르게 보입니다. 예를 들어, 30개의 그룹을 사용한 경우 차트는 다음과 같습니다.
#obtain histogram values with 30 bins
values, base = np.histogram(data, bins= 10 )
#find the cumulative sums
cumulative = np.cumsum(values)
# plot the warhead
plt.plot(base[:-1], cumulative, 'ro-')
‘ ro-‘ 인수는 다음을 지정합니다.
- 빨간색(r)을 사용하세요.
- 수업시간마다 원을 사용하세요 (o)
- 선을 사용하여 원(-)을 연결합니다.
차트의 미학을 변경하려면 이러한 옵션을 자유롭게 수정하세요.