Giter VIP home page Giter VIP logo

pyecharts's Introduction

pyecharts logo

pyecharts

Python ❤️ ECharts = pyecharts

Github Actions Status Codecov Package version PyPI - Python Version

PyPI - Format Contributions welcome License

English README

📣 简介

Apache ECharts 是一个由百度开源的数据可视化,凭借着良好的交互性,精巧的图表设计,得到了众多开发者的认可。而 Python 是一门富有表达力的语言,很适合用于数据处理。当数据分析遇上数据可视化时,pyecharts 诞生了。

✨ 特性

  • 简洁的 API 设计,使用如丝滑般流畅,支持链式调用
  • 囊括了 30+ 种常见图表,应有尽有
  • 支持主流 Notebook 环境,Jupyter Notebook 和 JupyterLab
  • 可轻松集成至 Flask,Sanic,Django 等主流 Web 框架
  • 高度灵活的配置项,可轻松搭配出精美的图表
  • 详细的文档和示例,帮助开发者更快的上手项目
  • 多达 400+ 地图文件,并且支持原生百度地图,为地理数据可视化提供强有力的支持

⏳ 版本

v0.5.x 和 V1 间不兼容,V1 是一个全新的版本,详见 ISSUE#892ISSUE#1033

V0.5.x

支持 Python2.7,3.4+

经开发团队决定,0.5.x 版本将不再进行维护,0.5.x 版本代码位于 05x 分支,文档位于 05x-docs.pyecharts.org

V1

仅支持 Python3.6+

新版本系列将从 v1.0.0 开始,文档位于 pyecharts.org;示例位于 gallery.pyecharts.org

V2

仅支持 Python3.6+

新版本基于 Echarts 5.4.1+ 进行渲染, 文档和示例位置与 V1 相同

🔰 安装

pip 安装

# 安装 v1 以上版本
$ pip install pyecharts -U

# 如果需要安装 0.5.11 版本的开发者,可以使用
# pip install pyecharts==0.5.11

源码安装

# 安装 v1 以上版本
$ git clone https://github.com/pyecharts/pyecharts.git
# 如果需要安装 0.5.11 版本,请使用 git clone https://github.com/pyecharts/pyecharts.git -b v05x
$ cd pyecharts
$ pip install -r requirements.txt
$ python setup.py install

📝 使用

本地环境

生成 HTML

from pyecharts.charts import Bar
from pyecharts import options as opts

# V1 版本开始支持链式调用
bar = (
    Bar()
    .add_xaxis(["衬衫", "毛衣", "领带", "裤子", "风衣", "高跟鞋", "袜子"])
    .add_yaxis("商家A", [114, 55, 27, 101, 125, 27, 105])
    .add_yaxis("商家B", [57, 134, 137, 129, 145, 60, 49])
    .set_global_opts(title_opts=opts.TitleOpts(title="某商场销售情况"))
)
bar.render()

# 不习惯链式调用的开发者依旧可以单独调用方法
bar = Bar()
bar.add_xaxis(["衬衫", "毛衣", "领带", "裤子", "风衣", "高跟鞋", "袜子"])
bar.add_yaxis("商家A", [114, 55, 27, 101, 125, 27, 105])
bar.add_yaxis("商家B", [57, 134, 137, 129, 145, 60, 49])
bar.set_global_opts(title_opts=opts.TitleOpts(title="某商场销售情况"))
bar.render()

生成图片

from snapshot_selenium import snapshot as driver

from pyecharts import options as opts
from pyecharts.charts import Bar
from pyecharts.render import make_snapshot


def bar_chart() -> Bar:
    c = (
        Bar()
        .add_xaxis(["衬衫", "毛衣", "领带", "裤子", "风衣", "高跟鞋", "袜子"])
        .add_yaxis("商家A", [114, 55, 27, 101, 125, 27, 105])
        .add_yaxis("商家B", [57, 134, 137, 129, 145, 60, 49])
        .reversal_axis()
        .set_series_opts(label_opts=opts.LabelOpts(position="right"))
        .set_global_opts(title_opts=opts.TitleOpts(title="Bar-测试渲染图片"))
    )
    return c

# 需要安装 snapshot-selenium 或者 snapshot-phantomjs
make_snapshot(driver, bar_chart().render(), "bar.png")

Notebook 环境

Jupyter Notebook

JupyterLab

Web 框架

🔖 Demo

Demo 代码位于 example 文件夹下,欢迎参考 pyecharts 画廊 pyecharts-gallery

bar boxplot effectScatter funnel gague geo geo graph heatmap kline line liquid map bmap parallel pie ploar radar scatter tree treemap wordCloud bar3D line3D sankey scatter3D surface3D themeRiver sunburst overlap grid grid timeline

更多详细文档,请访问

⛏ 代码质量

单元测试

$ pip install -r test/requirements.txt
$ make

集成测试

使用 Travis CIAppVeyor 持续集成环境。

代码规范

使用 flake8, Codecov 以及 pylint 提升代码质量。

😉 Author

pyecharts 主要由以下几位开发者开发维护

更多贡献者信息可以访问 pyecharts/graphs/contributors

💡 贡献

期待能有更多的开发者参与到 pyecharts 的开发中来,我们会保证尽快 Reivew PR 并且及时回复。但提交 PR 请确保

  1. 通过所有单元测试,如若是新功能,请为其新增单元测试
  2. 遵守开发规范,使用 black 以及 isort 格式化代码($ pip install -r requirements-dev.txt)
  3. 如若需要,请更新相对应的文档

我们也非常欢迎开发者能为 pyecharts 提供更多的示例,共同来完善文档,文档项目位于 pyecharts/website

📃 License

MIT ©chenjiandongx

pyecharts's People

Contributors

645775992 avatar 647-coder avatar ayu-exorcist avatar bradyhu avatar chenjiandongx avatar chfw avatar crispgm avatar duayt avatar fangyangjz avatar greatofdream avatar hansz00 avatar harri2012 avatar jackzhenguo avatar jeasoft avatar kianmeng avatar kinegratii avatar lakdred avatar landpack avatar li-boxuan avatar liux20 avatar miraclexyz avatar mowujilun avatar plainheart avatar sd8089730 avatar singuj avatar smirkcao avatar sunhailin-leo avatar thombashi avatar timgates42 avatar zeroto521 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyecharts's Issues

是否可以实现添加error bar?

是否可以在柱状图、折线图之类里实现添加Error Bar?
相比matplotlib这类的,pyecharts十分的简单易用,而且也比较美观;但如果不能添加Error Bar的话,还是没有办法用于科研工作中的制图。

PS: 如果能实现绘制p值的星号大概就更加完美了😂

python3.6

TypeError: Object of type 'int64' is not JSON serializable

macOS上python3编译未通过

Collecting pyecharts
Downloading pyecharts-0.1.8.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/private/var/folders/f4/t5xbjjj97gj_wwrcpcvd7c3h0000gn/T/pip-build-mke1433t/pyecharts/setup.py", line 8, in
import pyecharts.version as about
File "/private/var/folders/f4/t5xbjjj97gj_wwrcpcvd7c3h0000gn/T/pip-build-mke1433t/pyecharts/pyecharts/init.py", line 4, in
from pyecharts.charts.bar import Bar
File "/private/var/folders/f4/t5xbjjj97gj_wwrcpcvd7c3h0000gn/T/pip-build-mke1433t/pyecharts/pyecharts/charts/bar.py", line 4, in
from pyecharts.base import Base
File "/private/var/folders/f4/t5xbjjj97gj_wwrcpcvd7c3h0000gn/T/pip-build-mke1433t/pyecharts/pyecharts/base.py", line 9, in
from jinja2 import Template
ModuleNotFoundError: No module named 'jinja2'

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/f4/t5xbjjj97gj_wwrcpcvd7c3h0000gn/T/pip-build-mke1433t/pyecharts/

无法导入Bar模块

嗨,我在使用的时候完全是copy测试代码来执行的,安装步骤是先装了Image 然后在装的pyecharts,但是执行文件的时候报错:ImportError: cannot import name Bar。请问是怎么回事呢?

TypeError: __init__() got an unexpected keyword argument 'is_grid'

bar = Bar("柱状图示例", height=720, is_grid=True)
如上的代码报错:
File "", line 6, in
bar = Bar("柱状图示例", height=720, is_grid=True)
File "build\bdist.win32\egg\pyecharts\charts\bar.py", line 14, in init
super(Bar, self).init(title, subtitle, **kwargs)
TypeError: init() got an unexpected keyword argument 'is_grid'

怎么设置线条的颜色?

今天在知乎看到你的文章,发现画的图太好看了,但是我没有看到怎么设置线条的颜色,想请问下怎么样在折线图中设置颜色?

ImportError: cannot import name 'Bar'

windows7+python3.5

pip install Image失败,提示”The headers or library files could not be found for zlib,
a required dependency when compiling Pillow from source.“,改用pip install pillow后,pyecharts安装成功,但运行示例的时候:ImportError: cannot import name 'Bar'

如何实现数据的异步加载

一个月分钟级的K线数据, 画出来缩放的时候就已经卡得不要不要的了,有没有可能实现数据的异步加载呢?

能否同时显示多个秃瓢

譬如我画一个K线图,是否能在上面叠加显示均线之类的,目前当我画出K线图后,在画均线时,只能显示一个对象

多图的交互

刚从matplotlib的坑里转过来,很喜欢pyecharts自带的交互。仔细看了文档,发现用户不能自定义多图之间的交互。想问问有没有要往这个方向开发的打算?

3D多图显示问题

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import statsmodels.formula.api as smf
from pyecharts import Scatter3D
v = pd.read_csv("Guerry.csv")

''' data from rdataset  http://vincentarelbundock.github.io/Rdatasets/datasets.html HistData Guerry'''

results = smf.ols('Lottery ~ Literacy + np.log(Pop1831)', data=v).fit()


def lineplot_zip(z_xy,param):
    v = z_xy[:,0]*param[1]+z_xy[:,1]*param[2] +param[0]
    return v

v1 = v.sort_values('Lottery')


f_xy_zip = [[x,y] for x in np.linspace(0,100,num=100) for y in np.linspace(0,10,num=100)]

z = lineplot_zip(np.array(f_xy_zip),results.params.tolist())


ret = [[t[0][0],t[0][1],t[1]] for t in zip(f_xy_zip,z)]
range_color = ['#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf',
               '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026']
range_color1 = sorted(['#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf',
               '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026'])

ret_s =[[s[0],s[1],s[2]]  for s in zip(v1['Literacy'].tolist(),np.log(v['Pop1831']).tolist(),v1['Lottery'].tolist())]


Sc = Scatter3D('guerry test',width=1200, height=600)
Sc.add("s",ret, is_visualmap=True, grid3D_opacity=2,visual_range_color=range_color,center = [25,50])
Sc.add("t",ret_s, is_visualmap=True,grid3D_opacity=2,visual_range_color=range_color,center = [75,50])
Sc.render("ttt.html")

1没办法在jupyter_notebook上显示3D散点图
二是没有办法 在一个html总绘制 多个散点图

map结合 visualMap是否支持地图下钻及页面筛选器

你好,在实际场景中有如下应用

  1. 地图的下钻:例如在已经给出的两个示例,a.全国地图, b.广东省地图,是否支持在全国地图中点击广东,下钻到广东地国(现阶段只有鼠标悬浮出有标符信息)
  2. 地图页面筛选器:实现不同业务数据的可视化展示。
  3. 支持图面汉化: **特色使用我大中华汉字

2017-07-29 9 48 52

2017-07-29 9 49 03

python3安装成功了,但是Python2一直不成功

错误代码如下:

E:>pip2 install pyecharts --no-cache-dir
Collecting pyecharts
Downloading pyecharts-0.1.5.tar.gz
Complete output from command python setup.py
Traceback (most recent call last):
File "", line 1, in
File "c:\users\admini~1\appdata\local\temp
p.py", line 6, in
import pyecharts.version as about
File "pyecharts_init_.py", line 5, in <m
from pyecharts.charts.effectscatter impor
File "pyecharts\charts\effectscatter.py", l
from pyecharts.charts.scatter import Scat
File "pyecharts\charts\scatter.py", line 7,
import Image
ImportError: No module named Image

----------------------------------------

Command "python setup.py egg_info" failed with er
\appdata\local\temp\pip-build-vdikyj\pyecharts\

环境是windows7 64位
我先装的python3的版本,然后安装的2,3安装运行都没有问题,但是2有错误提示,我看了一下,和某一个issue是类似的,Image有问题

能否对DataFrame多列数据同时自动渲染

现在每个数据值渲染,都用单独add()的方式。如果一个DataFrame有50列,可能就要加49次。能不能设,一个DataFrame加入,默认index为轴,也可以指定某一列为轴,其他数据自动识别,形成多数据渲染,这样就方便高效得多了。

包安装失败怎么解决?

使用命令
pip install pyecharts
安装时出现以下错误:
Command "python setup.py egg_info" failed with error code 1 in c:\users\eship\appdata\local\temp\pip-build-dndqiu\pyecharts\

请问怎么解决呀?

echarts.simple in notebook template is too old

I am not able to source a link for echarts.simple:

Currently, it is:

//cdn.bootcss.com/echarts/3.2.2/echarts.simple

Preferred source could be:

//oog4yfyu0.bkt.clouddn.com/echarts.simple

This affects : #61 when scattered3d cannot be displayed together with word cloud in the same notebook page.

py2.7下编码问题render方法报错

bar = Bar("图表")
bar.pdcast(user_grouped['sum_bet'])
bar.add("销量",bar.pdcast(user_grouped['sum_bet'])[1],bar.pdcast(user_grouped['sum_bet'])[0])
bar.render()
直接调用render方法报错UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 19: ordinal not in range(128)
而调用render_notebook()则能够在notebook中正常显示。
其中x轴为中文,但是也都声明了utf-8编码,不知道问题出在哪里了。中文编码真是头疼的问题啊。。。
网上查了下可能是因为json.dump会默认把中文当做ascii来处理造成的?
求高人指教
default

问题求助:图片无法显示

将kline图与line图用custom()放在一张表中,再用grid()另一张bar图联系,没有报错,但是显示不出图表。 请问该如何解决?
同问, 是否有办法实现bar/line/kline 双x轴? 类似于matplotlib 里的 subplot() + twinx()。

地图(Geo)和热力图(HeatMap)等的显示问题

在使用pyecharts绘制地图或热力图的时候,左下角可以拖动调节的区域显示了low和hight两个单词。感觉hight应该改成high?查了一下好像是visualmap的问题。

 'visualMap': {'calculable': True,
               'inRange': {'color': ['#50a3ba', '#eac763', '#d94e5d']},
               'left': 'left',
               'max': 200,
               'min': 0,
               'orient': 'vertical',
               'text': ['hight', 'low'],
               'textStyle': {'color': '#fff'},
               'top': 'bottom',
               'type': 'continuous'}}

考虑加个table进来吗

多图组合显示时,除了看图,很多时候还会想要看表,能不能再加入个表格,可以展示数据,并且表格可以与图混排? 谢谢

建议x_axis 和 y_axis 数据类型扩展为iterable,不必限制为list。同时建议增加对pd.Series 和 pd.DataFrame的特殊支持

1、将list放宽到iterable可以方便很多。
2、关于Series,建议自动获取name, index, values属性,分别作为add参数。对于index为timestamp或数值类型,也自动转为string;
3、至于DataFrame,只是在Series上一次绘制多条线。

当然自己扩展也不复杂,个人感觉可能很多人都有这个需求,毕竟pandas的使用相当广泛。

Linux Mint 底下安装问题

环境:Linux Mint
Python版本: Both 2.7 and 3.4
问题:貌似是Pip源的问题,换到清华的时候,无法安装,是不是找错东西了?
$ pip3 install pyecharts
Collecting pyecharts
Collecting Image (from pyecharts)
Collecting pprint (from pyecharts)
Collecting django (from Image->pyecharts)
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/fe/ca/a7b35a0f5088f26b1ef3c7add57161a7d387a4cbd30db01c1091aa87e207/Django-1.11.3-py2.py3-none-any.whl
Requirement already satisfied: pillow in /usr/lib/python3/dist-packages (from Image->pyecharts)
Requirement already satisfied: pytz in /usr/local/lib/python3.5/dist-packages (from django->Image->pyecharts)
Installing collected packages: django, Image, pprint, pyecharts
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python3.5/dist-packages/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/usr/local/lib/python3.5/dist-packages/pip/req/req_set.py", line 784, in install
**kwargs
File "/usr/local/lib/python3.5/dist-packages/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/usr/local/lib/python3.5/dist-packages/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/usr/local/lib/python3.5/dist-packages/pip/wheel.py", line 345, in move_wheel_files
clobber(source, lib_dir, True)
File "/usr/local/lib/python3.5/dist-packages/pip/wheel.py", line 316, in clobber
ensure_dir(destdir)
File "/usr/local/lib/python3.5/dist-packages/pip/utils/init.py", line 83, in ensure_dir
os.makedirs(path)
File "/usr/lib/python3.5/os.py", line 241, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] 权限不够: '/usr/local/lib/python3.5/dist-packages/Django-1.11.3.dist-info'

请问一下微博转发关系图中的json项所指的都是哪些参数呢?

你好,请问一下微博关系图中的nodes, links, categories, cont, mid, userl = j 这后三个参数指明什么呢?我阅读weibo.json看到三个数组[name 描述节点大小等]、[source 指明link]、[name 节点名字],没有弄明白哪有6个参数,希望不吝赐教。

比如我自以为是的参考写了一个json,却得到这样的结果

Traceback (most recent call last):
File "test2.py", line 7, in
nodes, links, categories, cont, mid, userl = j
ValueError: not enough values to unpack (expected 6, got 3)

建议grid布局支持相对布局

对于gird,不知道是否可以支持相对布局,而不仅是绝对布局,绝对布局中,title, legend,对齐非常麻烦。
当然这可能需要Echarts本身支持,但我没研究Echarts.

radar图可以开放更多的模式么?

现在的radar图默认selectedMode为single, 不同数据源只能分开展示。
这种图 暂时无法很好的支持,只能强行定制。

我现在是这样改的,希望未来的支持更全面更兼容,或者可以提供更开放的定制接口

radar._option.get('legend')[0]['data'] = [aaa, bbb...]  # data name related with series data name
radar._option.get('legend')[0]['selectedMode'] = True

建议加个英文版的readme

如题,貌似没有看到英文版的readme,建议可以加个,这样更多人可以更好地使用到你的这个库。

非常感谢

这个库真的好强大。我是一个非程序爱好者(“自学成才”),自学了python,我以前都用matplotlib做可视化,但是代码真的好多好复杂。
遇到pyecharts发现真的太好理解了,谢谢。

pycharm安装报错

使用pycharm安装,提供缺少model报错

py27+pycharm
ImportError: No module named Image

2017-07-28 10 44 43

py36+pycharm
ModuleNotFoundError: No module named 'jinja2'

2017-07-28 10 45 25

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.