当前位置:网站首页>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)]
边栏推荐
- Markdown concise grammar manual
- SuperMap itablet license module division
- Leetcode: array
- What SaaS architecture design does a software architect need to know?
- Marketing play is changeable, and understanding the rules is the key!
- MySQL总是安装不成功,这样处理就好啦
- 界面控件Telerik UI for WPF - 如何使用RadSpreadsheet记录或评论
- 一台电脑上 多个项目公用一个 公私钥对拉取gerrit服务器代码
- Force buckle 315 calculates the number of elements smaller than the current element on the right
- Communication example between upper computer and Mitsubishi fn2x
猜你喜欢

LeetCode 42.接雨水

揭秘界面控件DevExpress WinForms为何弃用受关注的MaskBox属性

What SaaS architecture design does a software architect need to know?

04 pyechars 地理图表(示例代码+效果图)

Cloud native - runtime environment

Jinshanyun rushes to the dual main listing of Hong Kong stocks: the annual revenue of 9billion is a project supported by Lei Jun

30 years of open source community | 2022 open atom global open source summit 30 years of special activities of open source community were successfully held

C for循环内定义int i变量出现的重定义问题

图书馆自动预约脚本

Ccf201912-2 recycling station site selection
随机推荐
力扣315计算右侧小于当前元素的个数
Developing NES game (cc65) 03 and VRAM buffer with C language
Custom paging tag 02 of JSP custom tag
Leetcode394 string decoding
GMT installation and use
[nuxt 3] (XII) project directory structure 3
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
Unity loads GLB model
The input string contains an array of numbers and non characters, such as a123x456. Take the consecutive numbers as an integer, store them in an array in turn, such as 123 in a[0], 456 in a[1], and ou
Insufficient permission to pull server code through Jenkins and other precautions
Fundamentals of machine learning - support vector machine svm-17
Using dependent packages to directly implement paging and SQL statements
合并表格行---三层for循环遍历数据
非标自动化设备企业如何借助ERP系统,做好产品质量管理?
20220728-Object类常用方法
BA autoboot plug-in of uniapp application boot
Deployment之滚动更新策略。
leetcode:704二分查找
Use json.stringify() to format data
Fastjson parses multi-level JSON strings