系统环境:Ubuntu 18.04.1 LTS
Python使用的是虚拟环境:virutalenv
Python的版本:Python 3.6.9
简说Python之Jupyter Notebook
1.Jupyter Notebook
pip install -U ipywidgets "ipython[notebook]"
激活ipywidgetsHTML挂件项目
(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
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()