当前位置:网站首页>03 pyechars rectangular coordinate system chart (example code + effect drawing)
03 pyechars rectangular coordinate system chart (example code + effect drawing)
2022-07-28 12:52:00 【Lazy smile】
Catalog
4 EffectScatter Ripple effect scatter
8 PictorialBar Image histogram
Faker Introduction of functions in :
1.Bar Histogram / Bar chart
# Histogram / Bar chart
from pyecharts.charts import Bar
x_data = [" Chinese language and literature ", " mathematics ", " English ", " biological ", " Physics ", " chemical "] # x Axis data Data must be a string
y_data = [114, 95, 107, 81, 85, 87] # y Axis data Data must be integer or decimal
bar = Bar() # Initialization diagram
bar.add_xaxis(x_data) # x Axis
bar.add_yaxis(' achievement ', y_data) # y Axis
bar.render("bar.html") # Rendering html file 
2 Line Broken line diagram
# Broken line diagram
from pyecharts.charts import Line
x_data = ['1 month ', '2 month ', '3 month ', '4 month ', '5 month ', '6 month '] # x Axis data Data must be a string
y_data = [1123, 1153, 1089, 1207, 1298, 1123] # y Axis data Data must be integer or decimal
line = Line() # Initialization diagram
line.add_xaxis(x_data) # x Axis
line.add_yaxis(' Monthly consumption ', y_data) # y Axis
line.render("line.html") # Rendering html file 
3 Scatter Scatter plot
# Scatter plot
from pyecharts.charts import Scatter
x_data = ['1 month ', '2 month ', '3 month ', '4 month ', '5 month ', '6 month '] # x Axis data
y_data = [1123, 1153, 1089, 1207, 1298, 1123] # y Axis data
scatter = Scatter() # Initialization diagram
scatter.add_xaxis(x_data) # x Axis
scatter.add_yaxis(' Monthly consumption ', y_data) # y Axis
scatter.render("scatter.html") # Rendering html file 
4 EffectScatter Ripple effect scatter
from pyecharts.charts import EffectScatter
x_data = ['1 month ', '2 month ', '3 month ', '4 month ', '5 month ', '6 month '] # x Axis data
y_data = [1123, 1153, 1089, 1207, 1298, 1123] # y Axis data
effectScatter = EffectScatter()
effectScatter.add_xaxis(x_data) # x Axis
effectScatter.add_yaxis(' Monthly consumption ', y_data) # y Axis
effectScatter.render("effectScatter.html") # Rendering html file 
5 Boxplot Box figure
# Box figure
from pyecharts.charts import Boxplot
import random
x_data = ['A', 'B', 'C', 'D', 'E', 'F']
y_data = [[random.randint(100, 200) for i in range(10)] for item in x_data] #[[164, 102, 161, 106, 144, 186, 197, 186, 196, 125], [158, 131, 143, 111, 110, 175, 109, 107, 104, 153], [163, 174, 182, 142, 134, 158, 113, 149, 176, 183], [198, 142, 182, 125, 105, 149, 171, 122, 105, 156], [146, 126, 100, 164, 149, 117, 118, 170, 138, 155], [177, 110, 119, 178, 126, 164, 131, 176, 195, 134]]
print(y_data)
Boxplot = Boxplot()
Boxplot.add_xaxis(x_data) # x Axis
Boxplot.add_yaxis('', Boxplot.prepare_data(y_data)) # y Axis
Boxplot.render("Boxplot.html") # Rendering html file 
6 Kline k Line graph
# k Line graph
from pyecharts.charts import Kline
date_list = ["2022/6/{}".format(i + 1) for i in range(30)]
y_data = [
[2320.26, 2320.26, 2287.3, 2362.94],
[2300, 2291.3, 2288.26, 2308.38],
[2295.35, 2346.5, 2295.35, 2345.92],
[2347.22, 2358.98, 2337.35, 2363.8],
[2360.75, 2382.48, 2347.89, 2383.76],
[2383.43, 2385.42, 2371.23, 2391.82],
[2377.41, 2419.02, 2369.57, 2421.15],
[2425.92, 2428.15, 2417.58, 2440.38],
[2411, 2433.13, 2403.3, 2437.42],
[2432.68, 2334.48, 2427.7, 2441.73],
[2430.69, 2418.53, 2394.22, 2433.89],
[2416.62, 2432.4, 2414.4, 2443.03],
[2441.91, 2421.56, 2418.43, 2444.8],
[2420.26, 2382.91, 2373.53, 2427.07],
[2383.49, 2397.18, 2370.61, 2397.94],
[2378.82, 2325.95, 2309.17, 2378.82],
[2322.94, 2314.16, 2308.76, 2330.88],
[2320.62, 2325.82, 2315.01, 2338.78],
[2313.74, 2293.34, 2289.89, 2340.71],
[2297.77, 2313.22, 2292.03, 2324.63],
[2322.32, 2365.59, 2308.92, 2366.16],
[2364.54, 2359.51, 2330.86, 2369.65],
[2332.08, 2273.4, 2259.25, 2333.54],
[2274.81, 2326.31, 2270.1, 2328.14],
[2333.61, 2347.18, 2321.6, 2351.44],
[2340.44, 2324.29, 2304.27, 2352.02],
[2326.42, 2318.61, 2314.59, 2333.67],
[2314.68, 2310.59, 2296.58, 2320.96],
[2309.16, 2286.6, 2264.83, 2333.29],
[2282.17, 2263.97, 2253.25, 2286.33],
]
kline = (Kline()
.add_xaxis(date_list)
.add_yaxis('', y_data)
)
kline.render("kline.html") # Rendering html file 
7 HeatMap Heat map
# Heat map
from pyecharts.charts import HeatMap
import random
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 = [' Sunday ', ' Monday ', ' Tuesday ', ' Wednesday ', ' Thursday ', ' Friday ', ' Saturday ']
heat = (HeatMap()
.add_xaxis(hour_list)
.add_yaxis("", week_list, data)
)
heat.render("heat.html")
8 PictorialBar Image histogram
# Pictogram
from pyecharts.charts import PictorialBar
x_data = ['1 month ', '2 month ', '3 month ', '4 month ', '5 month ', '6 month '] # x Axis data
y_data = [1123, 1153, 1089, 1207, 1298, 1123] # y Axis data
pictorialBar = PictorialBar() # Initialization diagram
pictorialBar.add_xaxis(x_data) # x Axis
pictorialBar.add_yaxis(' Monthly consumption ', y_data) # y Axis
pictorialBar.render("pictorialBar .html") # Rendering html file 
9 overlap Cascade diagram
9.1 Overlap_bar_line
# Cascade diagram Overlap_bar_line
from pyecharts.charts import Bar
from pyecharts.charts import Line
x_data = ['1 month ', '2 month ', '3 month ', '4 month ', '5 month ', '6 month ']
y_data_bar = [1123, 1153, 1089, 1207, 1298, 1123]
y_data_line = [1300, 1200, 1100, 1400, 1500, 1200]
bar = (Bar()
.add_xaxis(x_data)
.add_yaxis('', y_data_bar)
)
line = (Line()
.add_xaxis(x_data)
.add_yaxis('', y_data_line)
)
overlap = bar.overlap(line)
overlap.render("overlap_bar_line .html")
9.2 Overlap_line_scatter
# Cascade diagram Overlap_line_scatter
from pyecharts import options as opts
from pyecharts.charts import Line, Scatter
from pyecharts.faker import Faker
x = Faker.choose()
line = (
Line()
.add_xaxis(x)
.add_yaxis(" merchants A", Faker.values())
.add_yaxis(" merchants B", Faker.values())
.set_global_opts(title_opts=opts.TitleOpts(title="Overlap-line+scatter"))
)
scatter = (
Scatter()
.add_xaxis(x)
.add_yaxis(" merchants A", Faker.values())
.add_yaxis(" merchants B", Faker.values())
)
line.overlap(scatter)
line.render("overlap_line_scatter.html")
Faker.values() Detailed explanation : Generate 7 A random integer , this 7 A random integer is usually a combination of two and three digits
Faker Introduction of functions in :
class _Faker:
clothes = [" shirt ", " sweater ", " necktie ", " The trousers ", " Windbreaker ", " High heels ", " socks "]
drinks = [" coke ", " Sprite ", " Orange Juice ", " Green tea ", " Milk tea ", " Budweiser ", " Qingdao "]
phones = [" millet ", " samsung ", " Huawei ", " Apple ", " meizu ", "VIVO", "OPPO"]
fruits = [" strawberry ", " Mango. ", " grapes ", " Snow pear ", " watermelon ", " lemon ", " Cherry "]
animal = [" Hippo ", " Python ", " The tiger ", " Elephant ", " The rabbit ", " Panda ", " The lion "]
cars = [" BMW ", " ferrari ", " Mercedes ", " audi ", " The public ", " Toyota ", " tesla "]
dogs = [" Siberian Husky ", " Samoye ", " Poodle ", " Golden hair ", " Shepherd Dog ", " Ji Wawa ", " corgi "]
week = [" Monday ", " Tuesday ", " Wednesday ", " Thursday ", " Friday ", " Saturday ", " Sunday "]
week_en = "Saturday Friday Thursday Wednesday Tuesday Monday Sunday".split()
clock = (
"12a 1a 2a 3a 4a 5a 6a 7a 8a 9a 10a 11a 12p "
"1p 2p 3p 4p 5p 6p 7p 8p 9p 10p 11p".split()
)
visual_color = [
"#313695",
"#4575b4",
"#74add1",
"#abd9e9",
"#e0f3f8",
"#ffffbf",
"#fee090",
"#fdae61",
"#f46d43",
"#d73027",
"#a50026",
]
months = ["{} month ".format(i) for i in range(1, 13)]
provinces = [" guangdong ", " Beijing ", " Shanghai ", " jiangxi ", " hunan ", " Zhejiang ", " jiangsu "]
guangdong_city = [" Shantou city ", " Shanwei cities ", " Jieyang city ", " yangjiang ", " Zhaoqing city ", " guangzhou ", " huizhou "]
country = [
"China",
"Canada",
"Brazil",
"Russia",
"United States",
"Africa",
"Germany",
]
days_attrs = ["{} God ".format(i) for i in range(30)]
days_values = [random.randint(1, 30) for _ in range(30)]
边栏推荐
- Unity loads GLB model
- MMA8452Q几种模式的初始化实例
- Multi Chain and multi currency wallet system development cross chain technology
- 1331. Array sequence number conversion: simple simulation question
- FlexPro软件:生产、研究和开发中的测量数据分析
- 揭秘界面控件DevExpress WinForms为何弃用受关注的MaskBox属性
- C for循环内定义int i变量出现的重定义问题
- 机器学习实战-逻辑回归-19
- Solution to the binary tree problem of niuke.com
- Quick read in
猜你喜欢

LeetCode84 柱状图中最大的矩形

05 pyechars 基本图表(示例代码+效果图)

Uncover why devaxpress WinForms, an interface control, discards the popular maskbox property

03 pyechars 直角坐标系图表(示例代码+效果图)

Hongjiu fruit passed the hearing: five month operating profit of 900million Ali and China agricultural reclamation are shareholders

VS1003 debugging routine

MMA8452Q几种模式的初始化实例

单调栈Monotonic Stack

Minimally invasive electrophysiology has passed the registration: a listed enterprise with annual revenue of 190million minimally invasive mass production

机器学习实战-神经网络-21
随机推荐
stm32 回环结构接收串口数据并处理
LeetCode94. 二叉树的中序遍历
New progress in the implementation of the industry | the openatom openharmony sub forum of the 2022 open atom global open source summit was successfully held
C语言项目中使用json
VS code更新后不在原来位置
FutureWarning: Indexing with multiple keys (implicitly converted to a tuple of keys) will be depreca
上位机和三菱FN2x通信实例
西门子对接Leuze BPS_304i 笔记
The usage and Simulation Implementation of vector in STL
VS1003调试例程
Using JSON in C language projects
云原生—运行时环境
CCF201912-2 回收站选址
LeetCode84 柱状图中最大的矩形
Custom paging tag 02 of JSP custom tag
一台电脑上 多个项目公用一个 公私钥对拉取gerrit服务器代码
Merge table rows - three levels of for loop traversal data
The 'name' attribute value associated with the element type 'item' cannot contain '& lt;' Character solution
Unity loads GLB model
连通块&&食物链——(并查集小结)