SoFunction
Updated on 2024-10-29

Explain in detail how to draw common Cartesian coordinate system charts based on Pyecharts

1. Histogram

# -*-coding:utf-8 -*-
# @Time :  21:02
# @Author: Huang Rongjin
# @File : 1.histogram.py
# @Software: PyCharm
 
from  import *
from  import Table
from pyecharts import options as opts
from  import JsCode
import random
import datetime
from  import CurrentConfig
CurrentConfig.ONLINE_HOST = "/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)
      )
("1. histogram.html")

2. Line graphs

# -*-coding:utf-8 -*-
# @Time :  21:19
# @Author: Huang Rongjin
# @File : 2. line graph.py
# @Software: PyCharm
 
from  import *
from  import Table
from pyecharts import options as opts
from  import JsCode
import random
import datetime
from  import CurrentConfig
CurrentConfig.ONLINE_HOST = "/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)
      )
("2. line graphs.html")

3. Box Chart

# -*-coding:utf-8 -*-
# @Time :  21:25
# @Author: Huang Rongjin
# @File : 3. box diagram.py
# @Software: PyCharm
 
from  import *
from  import Table
from pyecharts import options as opts
from  import JsCode
import random
import datetime
from  import CurrentConfig
CurrentConfig.ONLINE_HOST = "/lib/pyecharts_assets/"
 
x_data = ['python', 'java', 'c','c++', 'R', 'excel']
y_data = [[(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))
)
("3. box diagram.html")

4. Scatterplot

# -*-coding:utf-8 -*-
# @Time :  21:58
# @Author: Huang Rongjin
# @File : 4. Scatterplot.py
# @Software: PyCharm
 
 
from  import *
from  import Table
from pyecharts import options as opts
from  import JsCode
import random
import datetime
from  import CurrentConfig
CurrentConfig.ONLINE_HOST = "/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)
      )
("4. scatterplot.html")

5. Scatterplot with ripple effect

# -*-coding:utf-8 -*-
# @Time :  22:23
# @Author: Huang Rongjin
# @File : 5. Scatterplot with ripple effect.py
# @Software: PyCharm
 
 
from  import *
from  import Table
from pyecharts import options as opts
from  import JsCode
import random
import datetime
from  import CurrentConfig
CurrentConfig.ONLINE_HOST = "/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)
           )
 
("5. scatterplot with ripple effect.html")

line drawing

# -*-coding:utf-8 -*-
# @Time :  22:27
# @Author: Huang Rongjin
# @File : line graph.py
# @Software: PyCharm
 
from  import *
from  import Table
from pyecharts import options as opts
from  import JsCode
import random
import datetime
from  import CurrentConfig
CurrentConfig.ONLINE_HOST = "/lib/pyecharts_assets/"
 
date_list = ["2022/4/{}".format(i + 1) for i in range(30)]
y_data = [[(200, 350) for i in range(20)] for item in date_list]
 
kline = (Kline()
         .add_xaxis(date_list)
         .add_yaxis('', y_data)
         )
 
("Line Chart.html")

7. Heat map

# -*-coding:utf-8 -*-
# @Time :  22:36
# @Author: Huang Rongjin
# @File : 7. heat map.py
# @Software: PyCharm
 
from  import *
from  import Table
from pyecharts import options as opts
from  import JsCode
import random
import datetime
from  import CurrentConfig
CurrentConfig.ONLINE_HOST = "/lib/pyecharts_assets/"
 
data = [[i, j, (0, 100)] for i in range(24) for j in range(7)]
hour_list = [str(i) for i in range(24)]
week_list = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
 
heat = (HeatMap()
        .add_xaxis(hour_list)
        .add_yaxis("", week_list, data)
        )
 
("7. heatmap.html")

8. Pictograms

# -*-coding:utf-8 -*-
# @Time :  22:46
# @Author: Huang Rongjin
# @File : 8. pictogram.py
# @Software: PyCharm
 
from  import *
from  import Table
from pyecharts import options as opts
from  import JsCode
import random
import datetime
from  import CurrentConfig
CurrentConfig.ONLINE_HOST = "/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)
                )
 
("8. pictogram.html")

9. Cascading diagrams

# -*-coding:utf-8 -*-
# @Time :  23:02
# @Author: Huang Rongjin
# @File : 9. Cascading Maps.py
# @Software: PyCharm
 
from  import *
from  import Table
from pyecharts import options as opts
from  import JsCode
import random
import datetime
from  import CurrentConfig
CurrentConfig.ONLINE_HOST = "/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 = (line) #Use the first chart as a base and all subsequent data will be plotted on the first chart.
("9. cascading map.html")

summarize

To this article on how to draw based on Pyecharts common Cartesian coordinate system charts are introduced to this article, more related Pyecharts draw Cartesian coordinate system charts content, please search for my previous posts or continue to browse the following related articles I hope you will support me in the future!