histogram 函数
根据数值样本绘制直方图。
语法
histogram([v1, v2, ...])histogram(values, bins = n, option = value, ...)
参数与选项
list | 形如 [1, 2, 3] 的列表字面量。 |
|---|---|
bins | 直方图分箱数量。 |
title | 图形上方显示的标题文本。 |
labels | 坐标轴或类别标签。2D 图通常为 [xLabel, yLabel];图表中在支持时用于标注分类。 |
color / colour | 颜色名、CSS 颜色,或用于多个系列/图元的颜色列表。 |
axes | 坐标轴显示控制;使用 none/false 隐藏坐标轴。 |
gridlines | 网格线显示控制;true 显示,false 隐藏。 |
background | 图形背景颜色。 |
transparency | 透明度控制,范围 0 到 1,数值越大越透明。 |
view | 可见数值范围,例如 [xmin..xmax, ymin..ymax] 或 [xmin..xmax, ymin..ymax, zmin..zmax]。 |
示例
- 直方图
histogram([1, 1, 2, 2, 2, 3, 4], bins = 4)样本分入四个直方图区间。 - 分箱
histogram([1, 1, 2, 2, 2, 3, 4], bins = 3)样本分入三个区间。 - 标题
histogram([1, 1, 2, 2, 2, 3, 4], bins = 4, title = 'Distribution')直方图显示指定标题。 - 颜色
histogram([1, 1, 2, 2, 2, 3, 4], bins = 4, color = cyan)直方条绘制为青色。 - 坐标轴与网格
histogram([1, 1, 2, 2, 2, 3, 4], bins = 4, axes = none, gridlines = false)直方图结果包含指定的坐标轴和网格选项。 - 背景
histogram([1, 1, 2, 2, 2, 3, 4], bins = 4, background = '#f8fafc')直方图使用自定义背景。 - 透明度
histogram([1, 1, 2, 2, 2, 3, 4], bins = 4, transparency = 0.25)直方条以半透明方式绘制。 - 显示范围
histogram([1, 1, 2, 2, 2, 3, 4], bins = 4, view = [0..5, 0..4])固定可见的直方图窗口。 - 综合选项
histogram([1, 1, 2, 2, 2, 3, 4], bins = 4, title = 'Distribution', color = cyan, background = '#f8fafc', transparency = 0.2, view = [0..5, 0..4])同时应用分箱数、标题、颜色、背景、透明度和显示范围。