{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## pyecharts\n", "- [HTML](http://htmlpreview.github.io/?https://github.com/zzsza/TIL/blob/master/python/pyecharts.html) 에서 확인하면 이쁜 그래프도 보입니다!!!\n", "- Baidu에서 데이터 시각화를 위해 만든 오픈소스인 Echarts의 파이썬 버전\n", "- 다양한 그래프 제공\n", "- [공식 문서](http://pyecharts.org/#/en-us/)\n", "- Dynamic\n", "- 단, 옵션의 단추가 중국어\n", "- 그래프를 그릴 때, echarts와 echartql을 로컬에서 찾으려고 함\n", " - 따라서 nbconvert를 사용해 HTML으로 저장한 후, 쉘에서 수정\n", " \n", " ```\n", " sed -i \"\" \"s|/nbextensions/echarts/echarts-gl.min|https://cdn.jsdelivr.net/npm/echarts-gl@1.1.1/dist/echarts-gl.min|g; s|/nbextensions/echarts/echarts.min|https://cdnjs.cloudflare.com/ajax/libs/echarts/4.1.0/echarts.min|g\" 파일이름.ipynb\n", " ```" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import pyecharts\n", "import pandas as pd\n", "import numpy as np" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "attr = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\n", "v1 = [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]\n", "v2 = [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]\n", "bar = pyecharts.Bar(\"Bar chart\", \"precipitation and evaporation one year\")\n", "bar.add(\"precipitation\", attr, v1, mark_line=[\"average\"], mark_point=[\"max\", \"min\"])\n", "bar.add(\"evaporation\", attr, v2, mark_line=[\"average\"], mark_point=[\"max\", \"min\"])\n", "bar.render()\n", "bar.height = 500\n", "bar.width = 800" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "