altair.LayerChart#
- class altair.LayerChart(layer=Undefined, autosize=Undefined, background=Undefined, config=Undefined, data=Undefined, datasets=Undefined, description=Undefined, encoding=Undefined, height=Undefined, name=Undefined, padding=Undefined, params=Undefined, projection=Undefined, resolve=Undefined, title=Undefined, transform=Undefined, usermeta=Undefined, view=Undefined, width=Undefined, **kwds)#
在一个面板中带有图层的图表。
- __init__(layer=Undefined, autosize=Undefined, background=Undefined, config=Undefined, data=Undefined, datasets=Undefined, description=Undefined, encoding=Undefined, height=Undefined, name=Undefined, padding=Undefined, params=Undefined, projection=Undefined, resolve=Undefined, title=Undefined, transform=Undefined, usermeta=Undefined, view=Undefined, width=Undefined, **kwds)#
请参考
TopLevelLayerSpec
TopLevelLayerSpec schema 包装器。- 参数:
- layerSequence[dict,
UnitSpec
,LayerSpec
] 要叠加的图层或单个视图规范。
注意:
layer
内的规范不能使用row
和column
通道,因为不允许对分面规范进行分层。相反,请使用 facet operator 并将图层放在分面内部。- autosizedict,
AutosizeType
,AutoSizeParams
, Literal[‘pad’, ‘none’, ‘fit’, ‘fit-x’, ‘fit-y’] 如何确定可视化的尺寸。如果是一个字符串,应该是
"pad"
、"fit"
或"none"
之一。对象值还可以额外指定内容尺寸调整和自动调整的参数。默认值:
pad
- backgroundstr, dict,
Color
,ExprRef
,HexColor
,ColorName
, Literal[‘black’, ‘silver’, ‘gray’, ‘white’, ‘maroon’, ‘red’, ‘purple’, ‘fuchsia’, ‘green’, ‘lime’, ‘olive’, ‘yellow’, ‘navy’, ‘blue’, ‘teal’, ‘aqua’, ‘orange’, ‘aliceblue’, ‘antiquewhite’, ‘aquamarine’, ‘azure’, ‘beige’, ‘bisque’, ‘blanchedalmond’, ‘blueviolet’, ‘brown’, ‘burlywood’, ‘cadetblue’, ‘chartreuse’, ‘chocolate’, ‘coral’, ‘cornflowerblue’, ‘cornsilk’, ‘crimson’, ‘cyan’, ‘darkblue’, ‘darkcyan’, ‘darkgoldenrod’, ‘darkgray’, ‘darkgreen’, ‘darkgrey’, ‘darkkhaki’, ‘darkmagenta’, ‘darkolivegreen’, ‘darkorange’, ‘darkorchid’, ‘darkred’, ‘darksalmon’, ‘darkseagreen’, ‘darkslateblue’, ‘darkslategray’, ‘darkslategrey’, ‘darkturquoise’, ‘darkviolet’, ‘deeppink’, ‘deepskyblue’, ‘dimgray’, ‘dimgrey’, ‘dodgerblue’, ‘firebrick’, ‘floralwhite’, ‘forestgreen’, ‘gainsboro’, ‘ghostwhite’, ‘gold’, ‘goldenrod’, ‘greenyellow’, ‘grey’, ‘honeydew’, ‘hotpink’, ‘indianred’, ‘indigo’, ‘ivory’, ‘khaki’, ‘lavender’, ‘lavenderblush’, ‘lawngreen’, ‘lemonchiffon’, ‘lightblue’, ‘lightcoral’, ‘lightcyan’, ‘lightgoldenrodyellow’, ‘lightgray’, ‘lightgreen’, ‘lightgrey’, ‘lightpink’, ‘lightsalmon’, ‘lightseagreen’, ‘lightskyblue’, ‘lightslategray’, ‘lightslategrey’, ‘lightsteelblue’, ‘lightyellow’, ‘limegreen’, ‘linen’, ‘magenta’, ‘mediumaquamarine’, ‘mediumblue’, ‘mediumorchid’, ‘mediumpurple’, ‘mediumseagreen’, ‘mediumslateblue’, ‘mediumspringgreen’, ‘mediumturquoise’, ‘mediumvioletred’, ‘midnightblue’, ‘mintcream’, ‘mistyrose’, ‘moccasin’, ‘navajowhite’, ‘oldlace’, ‘olivedrab’, ‘orangered’, ‘orchid’, ‘palegoldenrod’, ‘palegreen’, ‘paleturquoise’, ‘palevioletred’, ‘papayawhip’, ‘peachpuff’, ‘peru’, ‘pink’, ‘plum’, ‘powderblue’, ‘rosybrown’, ‘royalblue’, ‘saddlebrown’, ‘salmon’, ‘sandybrown’, ‘seagreen’, ‘seashell’, ‘sienna’, ‘skyblue’, ‘slateblue’, ‘slategray’, ‘slategrey’, ‘snow’, ‘springgreen’, ‘steelblue’, ‘tan’, ‘thistle’, ‘tomato’, ‘turquoise’, ‘violet’, ‘wheat’, ‘whitesmoke’, ‘yellowgreen’, ‘rebeccapurple’] 用作整个视图背景的 CSS 颜色属性。
默认值:
"white"
- configdict,
Config
Vega-Lite 配置对象。此属性只能在规范的顶层定义。
- datadict,
Data
,UrlData
,Generator
,NamedData
,DataSource
,InlineData
,SphereGenerator
,SequenceGenerator
,GraticuleGenerator
, None 描述数据源的对象。设置为
null
可忽略父数据源。如果没有设置数据,则从父级派生。- datasetsdict,
Datasets
用于命名数据集的全局数据存储。这是从名称到内联数据集的映射。它可以是对象或原始值的数组,也可以是字符串。原始值数组作为具有
data
属性的对象摄入。- descriptionstr
此标记的描述,用于注释目的。
- encodingdict,
SharedEncoding
编码通道与底层图层中字段定义之间的共享键值映射。
- heightdict, float,
Step
, Literal[‘container’] 可视化的高度。
对于具有连续 y 字段的绘图,高度应为数字。
对于具有离散 y 字段或没有 y 字段的绘图,高度可以是表示固定高度的数字,也可以是形式为
{step: number}
的对象,用于定义每个离散步长的对应高度。(没有 y 字段等同于有一个离散步长。)要启用高度的响应式尺寸调整,应将其设置为
"container"
。
默认值: 对于具有连续 y 字段的绘图,基于
config.view.continuousHeight
;否则,基于config.view.discreteHeight
。注意: 对于具有 row 和 column 通道的绘图,这表示单个视图的高度,并且不能使用
"container"
选项。另请参阅: height 文档。
- namestr
可视化名称,用于后续引用。
- paddingdict, float,
ExprRef
,Padding
默认可视化填充,以像素为单位,从可视化画布边缘到数据矩形。如果是一个数字,则指定所有边的填充。如果是一个对象,则值应采用格式
{"left": 5, "top": 5, "right": 5, "bottom": 5}
来指定可视化各边的填充。默认值:
5
- paramsSequence[dict,
TopLevelParameter
,VariableParameter
,TopLevelSelectionParameter
] 用于参数化可视化的动态变量或选择。
- projectiondict,
Projection
定义底层图层共享的地理投影属性的对象。
- resolvedict,
Resolve
视图组合规范的刻度、轴和图例解析。
- titlestr, dict,
Text
, Sequence[str],TitleParams
绘图标题。
- transformSequence[dict,
Transform
,BinTransform
,FoldTransform
,LoessTransform
,PivotTransform
,StackTransform
,ExtentTransform
,FilterTransform
,ImputeTransform
,LookupTransform
,SampleTransform
,WindowTransform
,DensityTransform
,FlattenTransform
,QuantileTransform
,TimeUnitTransform
,AggregateTransform
,CalculateTransform
,RegressionTransform
,JoinAggregateTransform
] 数据转换数组,例如过滤和新字段计算。
- usermetadict,
Dict
可选元数据,将传递给 Vega。此对象完全被 Vega 和 Vega-Lite 忽略,可用于自定义元数据。
- viewdict,
ViewBackground
定义视图背景填充和描边属性的对象。
默认值: 无 (透明)
- widthdict, float,
Step
, Literal[‘container’] 可视化的宽度。
对于具有连续 x 字段的绘图,宽度应为数字。
对于具有离散 x 字段或没有 x 字段的绘图,宽度可以是表示固定宽度的数字,也可以是形式为
{step: number}
的对象,用于定义每个离散步长的对应宽度。(没有 x 字段等同于有一个离散步长。)要启用宽度的响应式尺寸调整,应将其设置为
"container"
。
默认值: 对于具有连续 x 字段的绘图,基于
config.view.continuousWidth
;否则,基于config.view.discreteWidth
。注意: 对于具有 row 和 column 通道的绘图,这表示单个视图的宽度,并且不能使用
"container"
选项。另请参阅: width 文档。
- $schemastr
JSON schema 的 URL,用于 Vega-Lite 规范。除非你有理由更改,否则请使用
https://vega.github.io/schema/vega-lite/v5.json
。$schema
属性的设置允许支持 JSON schema 的编辑器进行自动验证和自动完成。
- layerSequence[dict,
方法
__init__
([layer, autosize, background, ...])请参考
TopLevelLayerSpec
TopLevelLayerSpec schema 包装器。add_layers
(*layers)add_params
(*params)向图表添加一个或多个参数。
add_selection
(*selections)'add_selection' 已废弃。
configure
([arc, area, aria, autosize, axis, ...])请参考
Config
Config schema 包装器。configure_arc
([align, angle, aria, ...])请参考
RectConfig
RectConfig schema 包装器。configure_area
([align, angle, aria, ...])请参考
AreaConfig
AreaConfig schema 包装器。configure_axis
([aria, bandPosition, ...])请参考
AxisConfig
AxisConfig schema 包装器。configure_axisBand
([aria, bandPosition, ...])请参考
AxisConfig
AxisConfig schema 包装器。configure_axisBottom
([aria, bandPosition, ...])请参考
AxisConfig
AxisConfig schema 包装器。configure_axisDiscrete
([aria, bandPosition, ...])请参考
AxisConfig
AxisConfig schema 包装器。configure_axisLeft
([aria, bandPosition, ...])请参考
AxisConfig
AxisConfig schema 包装器。configure_axisPoint
([aria, bandPosition, ...])请参考
AxisConfig
AxisConfig schema 包装器。configure_axisQuantitative
([aria, ...])请参考
AxisConfig
AxisConfig schema 包装器。configure_axisRight
([aria, bandPosition, ...])请参考
AxisConfig
AxisConfig schema 包装器。configure_axisTemporal
([aria, bandPosition, ...])请参考
AxisConfig
AxisConfig schema 包装器。configure_axisTop
([aria, bandPosition, ...])请参考
AxisConfig
AxisConfig schema 包装器。configure_axisX
([aria, bandPosition, ...])请参考
AxisConfig
AxisConfig schema 包装器。configure_axisXBand
([aria, bandPosition, ...])请参考
AxisConfig
AxisConfig schema 包装器。configure_axisXDiscrete
([aria, ...])请参考
AxisConfig
AxisConfig schema 包装器。configure_axisXPoint
([aria, bandPosition, ...])请参考
AxisConfig
AxisConfig schema 包装器。configure_axisXQuantitative
([aria, ...])请参考
AxisConfig
AxisConfig schema 包装器。configure_axisXTemporal
([aria, ...])请参考
AxisConfig
AxisConfig schema 包装器。configure_axisY
([aria, bandPosition, ...])请参考
AxisConfig
AxisConfig schema 包装器。configure_axisYBand
([aria, bandPosition, ...])请参考
AxisConfig
AxisConfig schema 包装器。configure_axisYDiscrete
([aria, ...])请参考
AxisConfig
AxisConfig schema 包装器。configure_axisYPoint
([aria, bandPosition, ...])请参考
AxisConfig
AxisConfig schema 包装器。configure_axisYQuantitative
([aria, ...])请参考
AxisConfig
AxisConfig schema 包装器。configure_axisYTemporal
([aria, ...])请参考
AxisConfig
AxisConfig schema 包装器。configure_bar
([align, angle, aria, ...])请参考
BarConfig
BarConfig schema 包装器。configure_boxplot
([box, extent, median, ...])请参考
BoxPlotConfig
BoxPlotConfig schema 包装器。configure_circle
([align, angle, aria, ...])请参考
MarkConfig
MarkConfig schema 包装器。configure_concat
([columns, spacing])请参考
CompositionConfig
CompositionConfig schema 包装器。configure_errorband
([band, borders, extent, ...])请参考
ErrorBandConfig
ErrorBandConfig schema 包装器。configure_errorbar
([extent, rule, size, ...])请参考
ErrorBarConfig
ErrorBarConfig schema 包装器。configure_facet
([columns, spacing])请参考
CompositionConfig
CompositionConfig schema 包装器。configure_geoshape
([align, angle, aria, ...])请参考
MarkConfig
MarkConfig schema 包装器。configure_header
([format, formatType, ...])请参考
HeaderConfig
HeaderConfig schema 包装器。configure_headerColumn
([format, formatType, ...])请参考
HeaderConfig
HeaderConfig schema 包装器。configure_headerFacet
([format, formatType, ...])请参考
HeaderConfig
HeaderConfig schema 包装器。configure_headerRow
([format, formatType, ...])请参考
HeaderConfig
HeaderConfig schema 包装器。configure_image
([align, angle, aria, ...])请参考
RectConfig
RectConfig schema 包装器。configure_legend
([aria, clipHeight, ...])请参考
LegendConfig
LegendConfig schema 包装器。configure_line
([align, angle, aria, ...])请参考
LineConfig
LineConfig schema 包装器。configure_mark
([align, angle, aria, ...])请参考
MarkConfig
MarkConfig schema 包装器。configure_point
([align, angle, aria, ...])请参考
MarkConfig
MarkConfig schema 包装器。configure_projection
([center, clipAngle, ...])请参考
ProjectionConfig
ProjectionConfig schema 包装器。configure_range
([category, diverging, ...])请参考
RangeConfig
RangeConfig schema 包装器。configure_rect
([align, angle, aria, ...])请参考
RectConfig
RectConfig schema 包装器。configure_rule
([align, angle, aria, ...])请参考
MarkConfig
MarkConfig schema 包装器。configure_scale
([bandPaddingInner, ...])请参考
ScaleConfig
ScaleConfig schema 包装器。configure_selection
([interval, point])请参考
SelectionConfig
SelectionConfig schema 包装器。configure_square
([align, angle, aria, ...])请参考
MarkConfig
MarkConfig schema 包装器。configure_text
([align, angle, aria, ...])请参考
MarkConfig
MarkConfig schema 包装器。configure_tick
([align, angle, aria, ...])请参考
TickConfig
TickConfig schema 包装器。configure_title
([align, anchor, angle, ...])请参考
TitleConfig
TitleConfig schema 包装器。configure_tooltipFormat
([...])请参考
FormatConfig
FormatConfig schema 包装器。configure_trail
([align, angle, aria, ...])请参考
LineConfig
LineConfig schema 包装器。configure_view
([clip, continuousHeight, ...])请参考
ViewConfig
ViewConfig schema 包装器。copy
([deep, ignore])返回对象的副本。
display
([renderer, theme, actions])在 Jupyter notebook 或 JupyterLab 中显示图表。
encode
(*args[, angle, color, column, ...])将数据的属性映射到图表的视觉属性(请参阅
FacetedEncoding
)。facet
([facet, row, column, data, columns])从当前图表创建分面图表。
from_dict
(dct[, validate])从字典表示构造类。
from_json
(json_string[, validate])从有效的 JSON 字符串实例化对象。
interactive
([name, bind_x, bind_y])使图表轴刻度具有交互性。
open_editor
(*[, fullscreen])使用默认浏览器在 Vega chart editor 中打开图表规范。
project
([type, center, clipAngle, ...])向图表添加地理投影。
properties
(**kwargs)设置图表的顶层属性。
repeat
([repeat, row, column, layer, columns])返回从该图表构建的 RepeatChart。
resolve_axis
([x, y])请参考
AxisResolveMap
AxisResolveMap schema 包装器。resolve_legend
([angle, color, fill, ...])请参考
LegendResolveMap
LegendResolveMap schema 包装器。resolve_references
([schema])在此对象的 schema 或根 schema 上下文中解析引用。
resolve_scale
([angle, color, fill, ...])请参考
ScaleResolveMap
ScaleResolveMap schema 包装器。save
(fp[, format, ...])将图表保存为各种格式的文件。
serve
([ip, port, n_retries, files, ...])'serve' 已废弃。
显示
()使用活动的渲染器显示图表。
to_dict
([validate, format, ignore, context])将图表转换为适合 JSON 导出的字典。
to_html
([base_url, output_div, ...])将 Vega/Vega-Lite 规范嵌入到 HTML 页面中。
to_json
([validate, indent, sort_keys, ...])将图表转换为 JSON 字符串。
to_url
(*[, fullscreen])将图表转换为 URL,该 URL 在 Vega chart editor 中打开图表规范。
transform_aggregate
([aggregate, groupby])向 schema 添加
AggregateTransform
。transform_bin
([as_, field, bin])向 schema 添加
BinTransform
。transform_calculate
([as_, calculate])向 schema 添加
CalculateTransform
。transform_density
(density[, as_, bandwidth, ...])向 spec 添加
DensityTransform
。transform_extent
(extent, param)向 spec 添加
ExtentTransform
。transform_filter
([predicate, empty])向 spec 添加
FilterTransform
。transform_flatten
(flatten[, as_])向 schema 添加
FlattenTransform
。transform_fold
(fold[, as_])向 spec 添加
FoldTransform
。transform_impute
(impute, key[, frame, ...])向 schema 添加
ImputeTransform
。transform_joinaggregate
([joinaggregate, groupby])向 schema 添加
JoinAggregateTransform
。transform_loess
(on, loess[, as_, bandwidth, ...])向 spec 添加
LoessTransform
。transform_lookup
([lookup, from_, as_, default])向图表添加
DataLookupTransform
或SelectionLookupTransform
。transform_pivot
(pivot, value[, groupby, ...])向图表添加
PivotTransform
。transform_quantile
(quantile[, as_, groupby, ...])向图表添加
QuantileTransform
。transform_regression
(on, regression[, as_, ...])向图表添加
RegressionTransform
。transform_sample
([sample])向模式添加
SampleTransform
。transform_stack
(as_, stack, groupby[, ...])向模式添加
StackTransform
。transform_timeunit
([as_, field, timeUnit])向模式添加
TimeUnitTransform
。transform_window
([window, frame, groupby, ...])向模式添加
WindowTransform
。transformed_data
([row_limit, exclude])评估 LayerChart 的转换。
validate
(instance[, schema])在根模式(rootschema)的上下文中,根据类模式(schema)验证实例。
validate_property
(name, value[, schema])在根模式(rootschema)的上下文中,根据属性模式(property schema)验证属性。
属性
data