基于Pyecharts绘制常见的直角坐标系图表

1.直方图

# -*-coding:utf-8 -*-
# @Time :  21:02
# @Author: 黄荣津
# @File : 1.直方图.py
# @Software: PyCharm

from pyecharts.charts import *
from pyecharts.components import Table
from pyecharts import options as opts
from pyecharts.commons.utils import JsCode
import random
import datetime
from pyecharts.globals import CurrentConfig
CurrentConfig.ONLINE_HOST = "https://cdn.kesci.com/lib/pyecharts_assets/"

x_data = ['python', 'java', 'c','c++', 'R', 'excel']
y_data = [143, 123, 69, 107, 90, 73]
bar = (Bar()
       .add_xaxis(x_data)
       .add_yaxis('', y_data)
      )
bar.render("1.直方图.html")

基于Pyecharts绘制常见的直角坐标系图表_第1张图片

2.折线图

# -*-coding:utf-8 -*-
# @Time :  21:19
# @Author: 黄荣津
# @File : 2.折线图.py
# @Software: PyCharm


from pyecharts.charts import *
from pyecharts.components import Table
from pyecharts import options as opts
from pyecharts.commons.utils import JsCode
import random
import datetime
from pyecharts.globals import CurrentConfig
CurrentConfig.ONLINE_HOST = "https://cdn.kesci.com/lib/pyecharts_assets/"

x_data = ['python', 'java', 'c','c++', 'R', 'excel']
y_data = [143, 123, 69, 107, 90, 73]
line = (Line()
       .add_xaxis(x_data)
       .add_yaxis('', y_data)
      )
line.render("2.折线图.html")

 基于Pyecharts绘制常见的直角坐标系图表_第2张图片

3.箱形图

# -*-coding:utf-8 -*-
# @Time :  21:25
# @Author: 黄荣津
# @File : 3.箱型图.py
# @Software: PyCharm

from pyecharts.charts import *
from pyecharts.components import Table
from pyecharts import options as opts
from pyecharts.commons.utils import JsCode
import random
import datetime
from pyecharts.globals import CurrentConfig
CurrentConfig.ONLINE_HOST = "https://cdn.kesci.com/lib/pyecharts_assets/"

x_data = ['python', 'java', 'c','c++', 'R', 'excel']
y_data = [[random.randint(100, 150) for i in range(20)] for item in x_data]

class Box:
    pass

box =( Boxplot()
.add_xaxis(x_data)
.add_yaxis("", (y_data))
)
box.render("3.箱型图.html")

基于Pyecharts绘制常见的直角坐标系图表_第3张图片

 

4.散点图

# -*-coding:utf-8 -*-
# @Time :  21:58
# @Author: 黄荣津
# @File : 4.散点图.py
# @Software: PyCharm


from pyecharts.charts import *
from pyecharts.components import Table
from pyecharts import options as opts
from pyecharts.commons.utils import JsCode
import random
import datetime
from pyecharts.globals import CurrentConfig
CurrentConfig.ONLINE_HOST = "https://cdn.kesci.com/lib/pyecharts_assets/"
x_data = ['python', 'java', 'c','c++', 'R', 'excel']
y_data = [143, 123, 69, 107, 90, 73]
Scatter=(Scatter()
       .add_xaxis(x_data)
       .add_yaxis('', y_data)
      )
Scatter.render("4.散点图.html")

基于Pyecharts绘制常见的直角坐标系图表_第4张图片

 

5.带涟漪效果散点图

# -*-coding:utf-8 -*-
# @Time :  22:23
# @Author: 黄荣津
# @File : 5.带涟漪效果散点图.py
# @Software: PyCharm


from pyecharts.charts import *
from pyecharts.components import Table
from pyecharts import options as opts
from pyecharts.commons.utils import JsCode
import random
import datetime
from pyecharts.globals import CurrentConfig
CurrentConfig.ONLINE_HOST = "https://cdn.kesci.com/lib/pyecharts_assets/"
x_data = ['python', 'java', 'c','c++', 'R', 'excel']
y_data = [143, 123, 69, 107, 90, 73]

effectScatter = (EffectScatter()
           .add_xaxis(x_data)
           .add_yaxis('', y_data)
           )

effectScatter.render("5.带涟漪效果散点图.html")

基于Pyecharts绘制常见的直角坐标系图表_第5张图片

 

6.k线图

# -*-coding:utf-8 -*-
# @Time :  22:27
# @Author: 黄荣津
# @File : 6.k线图.py
# @Software: PyCharm

from pyecharts.charts import *
from pyecharts.components import Table
from pyecharts import options as opts
from pyecharts.commons.utils import JsCode
import random
import datetime
from pyecharts.globals import CurrentConfig
CurrentConfig.ONLINE_HOST = "https://cdn.kesci.com/lib/pyecharts_assets/"


date_list = ["2022/4/{}".format(i + 1) for i in range(30)]
y_data = [[random.randint(200, 350) for i in range(20)] for item in date_list]

kline = (Kline()
         .add_xaxis(date_list)
         .add_yaxis('', y_data)
         )

kline.render("6.k线图.html")

基于Pyecharts绘制常见的直角坐标系图表_第6张图片

 

7.热力图

# -*-coding:utf-8 -*-
# @Time :  22:36
# @Author: 黄荣津
# @File : 7.热力图.py
# @Software: PyCharm

from pyecharts.charts import *
from pyecharts.components import Table
from pyecharts import options as opts
from pyecharts.commons.utils import JsCode
import random
import datetime
from pyecharts.globals import CurrentConfig
CurrentConfig.ONLINE_HOST = "https://cdn.kesci.com/lib/pyecharts_assets/"

data = [[i, j, random.randint(0, 100)] for i in range(24) for j in range(7)]
hour_list = [str(i) for i in range(24)]
week_list = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']

heat = (HeatMap()
        .add_xaxis(hour_list)
        .add_yaxis("", week_list, data)
        )

heat.render("7.热力图.html")

基于Pyecharts绘制常见的直角坐标系图表_第7张图片

 

8.象型图

# -*-coding:utf-8 -*-
# @Time :  22:46
# @Author: 黄荣津
# @File : 8.象型图.py
# @Software: PyCharm


from pyecharts.charts import *
from pyecharts.components import Table
from pyecharts import options as opts
from pyecharts.commons.utils import JsCode
import random
import datetime
from pyecharts.globals import CurrentConfig
CurrentConfig.ONLINE_HOST = "https://cdn.kesci.com/lib/pyecharts_assets/"

x_data = ['python', 'java', 'c','c++', 'R', 'excel']
y_data = [143, 123, 69, 107, 90, 33]
pictorialBar = (PictorialBar()
                .add_xaxis(x_data)
                .add_yaxis('', y_data)
                )

pictorialBar.render("8.象型图.html")

基于Pyecharts绘制常见的直角坐标系图表_第8张图片

 

9.层叠图

# -*-coding:utf-8 -*-
# @Time :  23:02
# @Author: 黄荣津
# @File : 9.层叠图.py
# @Software: PyCharm

from pyecharts.charts import *
from pyecharts.components import Table
from pyecharts import options as opts
from pyecharts.commons.utils import JsCode
import random
import datetime
from pyecharts.globals import CurrentConfig
CurrentConfig.ONLINE_HOST = "https://cdn.kesci.com/lib/pyecharts_assets/"

x_data = ['python', 'java', 'c','c++', 'R', 'excel']
y_data = [143, 123, 69, 107, 90, 73]
bar = (Bar()
       .add_xaxis(x_data)
       .add_yaxis('', y_data)
       )

line = (Line()
        .add_xaxis(x_data)
        .add_yaxis('', y_data)
        )

overlap = bar.overlap(line) #利用第一个图表为基础,往后的数据都将会画在第一个图表上
overlap.render("9.层叠图.html")

基于Pyecharts绘制常见的直角坐标系图表_第9张图片

 

你可能感兴趣的:(笔记,python)