系統環境:Ubuntu 18.04.1 LTS
Python使用的是虛擬環境:virutalenv
Python的版本:Python 3.6.9
簡說Python之Jupyter Notebook
1.Jupyter Notebook
pip install -U ipywidgets "ipython[notebook]"
激活ipywidgets
HTML掛件項目
(zsdpy1) $ jupyter nbextension enable --py widgetsnbextension
Enabling notebook extension jupyter-js-widgets/extension...
- Validating: OK
啟動Jupyter
(zsdpy1) $ cd /home/zsd/work/
(zsdpy1) $ jupyter notebook --port 5000 --no-browser --ip="*"
輸入地址:http://172.30.xx.252:5000
Jupyter Notebook
最大的優勢在於演示,可以用作於:
- 項目說明文檔,解釋和溝通
- PPT演示,很多數據分析Echarts,方便數據可視化
- 個人技術的展示
如下:
\
Jupyter Notebook的Echarts應用
1.安裝pyecharts
pip install pyecharts
升級方式:
$ pip install pyecharts -U
2.應用展示
開源地址:https://github.com/pyecharts/pyecharts
展示代碼:
from pyecharts.charts import Bar
from pyecharts import options as opts
bar =(
Bar()
.add_xaxis(["數學","語文","英語","物理","化學","生物"])
.add_yaxis("男生平均成績",[114,100,108,60,78,54])
.add_yaxis("女生平均成績",[90,110,120,54,65,48])
.set_global_opts(title_opts=opts.TitleOpts(title="某高校高考成績情況"))
)
bar.render_notebook()
地圖代碼的演示:
from pyecharts import options as opts
from pyecharts.charts import Geo
from pyecharts.globals import ChartType, SymbolType
c = (
Geo()
.add_schema(
maptype="china",
itemstyle_opts=opts.ItemStyleOpts(color="#323c48", border_color="#111"),
)
.add(
"",
[("廣州", 55), ("北京", 66), ("杭州", 77), ("重慶", 88)],
type_=ChartType.EFFECT_SCATTER,
color="white",
)
.add(
"geo",
[("廣州", "上海"), ("廣州", "北京"), ("廣州", "杭州"), ("廣州", "重慶")],
type_=ChartType.LINES,
effect_opts=opts.EffectOpts(
symbol=SymbolType.ARROW, symbol_size=6, color="blue"
),
linestyle_opts=opts.LineStyleOpts(curve=0.2),
)
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
.set_global_opts(title_opts=opts.TitleOpts(title="Geo-Lines-background"))
)
c.render_notebook()