Jupyter Dash Only 2line으로 인터랙티브 트리 맵 그리기

이번 포스트에서는 Google Colab에서 샘플 데이터셋으로 트리맵을 그리는 방법을 보여드리겠습니다.


계획적으로 / jupyter-dash


Jupyter Notebook 및 JupyterLab에서 Dash 앱 개발





주피터 대쉬



이 라이브러리를 사용하면 Jupyter 환경(예: 클래식 노트북, JupyterLab, Visual Studio Code 노트북, nteract, PyCharm 노트북 등) 내에서 대화형으로 Plotly Dash 앱을 쉽게 개발할 수 있습니다.

자세한 내용과 사용 예는 notebooks/getting_started.ipynb을 참조하십시오.

설치


pip...를 사용하여 JupyterDash Python 패키지를 설치할 수 있습니다.
$ pip install jupyter-dash
또는 콘다
$ conda install -c conda-forge -c plotly jupyter-dash

JupyterLab 지원


JupyterLab에서 사용하는 경우 JupyterDash는 JupyterLab 버전 2.0 이상이 필요한 JupyterLab 확장 jupyterlab-dash 에 의존합니다.
이 확장은 Python 패키지에 포함되어 있지만 활성화하려면 JupyterLab을 다시 빌드해야 합니다. JupyterLab은 재구축 권한을 요청하는 팝업 대화 상자를 자동으로 생성해야 하지만 다음을 사용하여 명령줄에서 수동으로 재구축을 수행할 수도 있습니다.
$ jupyter lab build
확장 프로그램이 제대로 설치되었는지 확인하려면 jupyter labextension list로 전화하십시오.

Colab 지원


버전 0.3.0부터 JupyterDash 작동…

View on GitHub

Step1 패키지 설치




!pip install jupyter_dash
!pip install --upgrade plotly 


Step2 패키지 가져오기




import dash 
from jupyter_dash import JupyterDash 
import dash_core_components as dcc 
import dash_html_components as html 
import plotly.express as px
from dash.dependencies import Input, Output


Step3 데이터셋 불러오기 및 트리맵 그리기




gapminder = px.data.gapminder() # load data
gapminder.head() # display data

# tree-map
gapminder['board'] = 'world'
px.treemap(gapminder, path=['board', 'year', 'country'], values='pop')


당신은 다음을 볼 수 있습니다


좋은 웹페이지 즐겨찾기