ComputerLanguage_Program/PYTHON
[PYTHON] bokeh 라이브러리를 통한 산점도 그리기
pbj0812
2020. 10. 14. 01:20
0. 목표
- bokeh 라이브러리를 통한 산점도 그리기
1. 실습
1) 설치
pip install bokeh
2) 데이터 생성
- x좌표, y좌표, 원의 반지름 순
x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
y = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
z = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
3) 데이터 프레임화
df = pd.DataFrame({
'x' : x,
'y' : y,
'z' : z
})
4) figure 객체 생성
p = figure()
5) 산점도 제작
- radius를 적당히 나눠주지 않으면 원이 튀어나감
p.scatter(df['x'], df['y'], radius=df['z']/10,
fill_color='black', fill_alpha=0.6, line_color=None)
6) 저장
output_file("scatterplot.html")
show(p)
2. 결과
- scatterplot.html 파일이 생겨남과 동시에 새로운 창 하나 생성
- 오른쪽 아이콘들을 통하여 조작 가능