커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
bar 그래프에 수치 표현하기
undefined주차
북마크
김*현
댓글
9
추천
0
조회수
10
조회수
10
답변 완료

* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.

* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.


아래와 같이 bar 그래프 상단에 수치를 표현하고 싶습니다. 어떻게 하면 될까요?



<현재 화면>

스파르타 즉문즉답

<원하는 화면>

스파르타 즉문즉답




작성한 코드 및 에러 메세지

discounted_data = sparta_data.groupby('discounted')['user_id'].count()

discounted_data


sum_of_discounted_data = sum(sparta_data.groupby('discounted')['user_id'].count())


discounted_data_of_10000 = sparta_data[sparta_data['discounted']==10000]['user_id'].count()

discounted_data_of_20000 = sparta_data[sparta_data['discounted']==20000]['user_id'].count()

discounted_data_of_30000 = sparta_data[sparta_data['discounted']==30000]['user_id'].count()


#각 결제 인원에서 실제 실험 인원인 12000명을 나누고 각 퍼센테이지 구하기

percent_of_discounted_data_of_10000 = discounted_data_of_10000/sum_of_discounted_data *100

percent_of_discounted_data_of_20000 = discounted_data_of_20000/sum_of_discounted_data *100

percent_of_discounted_data_of_30000 = discounted_data_of_30000/sum_of_discounted_data *100


print(percent_of_discounted_data_of_10000 , percent_of_discounted_data_of_20000, percent_of_discounted_data_of_30000)



#그래프 사이즈

plt.figure(figsize=(10,5))

#x 그룹 지정하기

x_list =["10000", "20000", "30000"]

#y 값

#각각 어떤 값이 들어가야 하는지 입력해 볼까요?

y_list = [percent_of_discounted_data_of_10000 , percent_of_discounted_data_of_20000, percent_of_discounted_data_of_30000]


#x,y값 설정

plt.bar(x_list, y_list)


#그래프 타이틀

plt.title('할인별 결제 전환율 비교 분석')

#x축 레이블

plt.xlabel('할인 금액')

#y축 레이블

plt.ylabel('결제 전환율')

#그래프 보여주기

plt.show()




취소
 공유
취소
댓글 0
댓글 알림
나의얼굴