Python全系列 教程
3567个小节阅读:5928.9k
目录
鸿蒙应用开发
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
箱型图也称为盒须图。用于显示数据的位置、分散程度、异常值等。图中可以体现出中位数、四分之一、四分之三、上限、下限、异常值等信息。
class pyecharts.charts.Boxplot(RectChart)
xxxxxxxxxx
class Boxplot(
# 初始化配置项,参考 `global_options.InitOpts`
init_opts: opts.InitOpts = opts.InitOpts()
)
func pyecharts.charts.Boxplot.add_yaxis
xxxxxxxxxx
def add_yaxis(
# 系列名称,用于 tooltip 的显示,legend 的图例筛选。
series_name: str,
# 系列数据
y_axis: types.Sequence[types.Union[opts.BoxplotItem, dict]],
# 是否选中图例
is_selected: bool = True,
# 使用的 x 轴的 index,在单个图表实例中存在多个 x 轴的时候有用。
xaxis_index: Optional[Numeric] = None,
# 使用的 y 轴的 index,在单个图表实例中存在多个 y 轴的时候有用。
yaxis_index: Optional[Numeric] = None,
# 标签配置项,参考 `series_options.LabelOpts`
label_opts: Union[opts.LabelOpts, dict] = opts.LabelOpts(),
# 标记点配置项,参考 `series_options.MarkPointOpts`
markpoint_opts: Union[opts.MarkPointOpts, dict] = opts.MarkPointOpts(),
# 标记线配置项,参考 `series_options.MarkLineOpts`
markline_opts: Union[opts.MarkLineOpts, dict] = opts.MarkLineOpts(),
# 提示框组件配置项,参考 `series_options.TooltipOpts`
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
# 图元样式配置项,参考 `series_options.ItemStyleOpts`
itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
)
BoxplotItem:箱形图数据项
xxxxxxxxxx
class BoxplotItem(
# 数据项名称。
name: Optional[str] = None,
# 单个数据项的数值。
value: Optional[Numeric] = None,
# 文本的样式设置,参考 `series_options.LabelOpts`。
label_opts: Union[LabelOpts, dict, None] = None,
# 图元样式配置项,参考 `series_options.ItemStyleOpts`
itemstyle_opts: Union[ItemStyleOpts, dict, None] = None,
# 提示框组件配置项,参考 `series_options.TooltipOpts`
tooltip_opts: Union[TooltipOpts, dict, None] = None,
)
【示例】绘制箱图
xxxxxxxxxx
from pyecharts import options as opts
from pyecharts.charts import Boxplot
v1 = [ [890, 810, 810, 820, 800, 770, 760, 740, 750, 760, 910, 920],
[890, 840, 780, 810, 760, 810, 790, 810, 820, 850, 870, 870],
[850, 740, 900, 1070, 930, 850, 950, 980, 980, 880, 1000, 980],
[960, 940, 960, 940, 880, 800, 850, 880, 900, 840, 830, 790], ]
c = Boxplot()
c.add_xaxis(["expr1", "expr2","expr3","expr4"])
c.add_yaxis("A", c.prepare_data(v1))
c.set_global_opts(title_opts=opts.TitleOpts(title="BoxPlot-基本示例"))
c.render_notebook()
【示例】绘制箱图
xxxxxxxxxx
from pyecharts import options as opts
from pyecharts.charts import Boxplot
v1 = [ [890, 810, 810, 820, 800, 770, 760, 740, 750, 760, 910, 920],
[890, 840, 780, 810, 760, 810, 790, 810, 820, 850, 870, 870], ]
v2 = [ [850, 740, 900, 1070, 930, 850, 950, 980, 980, 880, 1000, 980],
[960, 940, 960, 940, 880, 800, 850, 880, 900, 840, 830, 790], ]
c = Boxplot()
c.add_xaxis(["expr1", "expr2"])
c.add_yaxis("A", c.prepare_data(v1))
c.add_yaxis("B", c.prepare_data(v2))
c.set_global_opts(title_opts=opts.TitleOpts(title="BoxPlot-基本示例"))
c.render_notebook()
实时效果反馈
1. pyecharts模块中Boxplot绘制 _______。
A 饼图
B 散点图
C 箱图
D 热力图
2. pyecharts模块中绘制箱图,下划线处分别需要填写的代码是_____:
xxxxxxxxxx
from pyecharts import options as opts
from pyecharts.charts import Boxplot
v1 = [ [890, 810, 810, 820, 800, 770, 760, 740, 750, 760, 910, 920],
[890, 840, 780, 810, 760, 810, 790, 810, 820, 850, 870, 870],
[850, 740, 900, 1070, 930, 850, 950, 980, 980, 880, 1000, 980],
[960, 940, 960, 940, 880, 800, 850, 880, 900, 840, 830, 790], ]
c = _________
c.add_xaxis(["expr1", "expr2","expr3","expr4"])
c.add_yaxis("A", c.prepare_data(v1))
c.set_global_opts(title_opts=opts.TitleOpts(title="BoxPlot-基本示例"))
#notebook中展示
__________
A Boxplot() c.render()
B Boxplot() c.render_notebook()
C boxplot() c.render_notebook()
答案
1=>C 2=>B