altair.Encoding#
- class altair.Encoding(angle=Undefined, color=Undefined, description=Undefined, detail=Undefined, fill=Undefined, fillOpacity=Undefined, href=Undefined, key=Undefined, latitude=Undefined, latitude2=Undefined, longitude=Undefined, longitude2=Undefined, opacity=Undefined, order=Undefined, radius=Undefined, radius2=Undefined, shape=Undefined, size=Undefined, stroke=Undefined, strokeDash=Undefined, strokeOpacity=Undefined, strokeWidth=Undefined, text=Undefined, theta=Undefined, theta2=Undefined, tooltip=Undefined, url=Undefined, x=Undefined, x2=Undefined, xError=Undefined, xError2=Undefined, xOffset=Undefined, y=Undefined, y2=Undefined, yError=Undefined, yError2=Undefined, yOffset=Undefined, **kwds)#
Encoding 模式的包装器。
- 参数:
- angledict,
NumericMarkPropDef
,FieldOrDatumDefWithConditionDatumDefnumber
,FieldOrDatumDefWithConditionMarkPropFieldDefnumber
,ValueDefWithConditionMarkPropFieldOrDatumDefnumber
旋转角度。点和文本标记的旋转角度。
- colordict,
ColorDef
,FieldOrDatumDefWithConditionDatumDefGradientstringnull
,FieldOrDatumDefWithConditionMarkPropFieldDefGradientstringnull
,ValueDefWithConditionMarkPropFieldOrDatumDefGradientstringnull
标记的颜色 - 填充颜色或描边颜色,取决于标记定义的
filled
属性。默认情况下,color
表示"area"
,"bar"
,"tick"
,"text"
,"trail"
,"circle"
和"square"
的填充颜色 /"line"
和"point"
的描边颜色。默认值:如果未定义,默认颜色取决于 标记配置 的
color
属性。注意:1) 若要精细控制标记的填充和描边颜色,请使用
fill
和stroke
通道。如果指定了冲突的编码,fill
或stroke
编码的优先级高于color
,因此可能会覆盖color
编码。2) 有关自定义 颜色方案 的更多信息,请参阅比例尺文档。- descriptiondict,
StringFieldDefWithCondition
,StringValueDefWithCondition
ARIA 可访问性(仅 SVG 输出)的标记文本描述。对于 SVG 输出,
"aria-label"
属性将设置为此描述。- detaildict,
FieldDefWithoutScale
, Sequence[dict,FieldDefWithoutScale
] 附加细节层。用于在聚合视图以及线、轨迹和面积标记中对数据进行分组的附加细节层,无需将数据映射到特定的视觉通道。
- filldict,
ColorDef
,FieldOrDatumDefWithConditionDatumDefGradientstringnull
,FieldOrDatumDefWithConditionMarkPropFieldDefGradientstringnull
,ValueDefWithConditionMarkPropFieldOrDatumDefGradientstringnull
标记的填充颜色。默认值:如果未定义,默认颜色取决于 标记配置 的
color
属性。注意:
fill
编码的优先级高于color
,因此如果指定了冲突的编码,可能会覆盖color
编码。- fillOpacitydict,
NumericMarkPropDef
,FieldOrDatumDefWithConditionDatumDefnumber
,FieldOrDatumDefWithConditionMarkPropFieldDefnumber
,ValueDefWithConditionMarkPropFieldOrDatumDefnumber
标记的填充不透明度。
默认值:如果未定义,默认不透明度取决于 标记配置 的
fillOpacity
属性。- hrefdict,
StringFieldDefWithCondition
,StringValueDefWithCondition
鼠标点击时加载的 URL。
- keydict,
FieldDefWithoutScale
用作数据绑定唯一键的数据字段。当可视化数据更新时,键值将用于将数据元素与现有标记实例匹配。使用键通道可以实现动态数据过渡时的对象一致性。
- latitudedict,
DatumDef
,LatLongDef
,LatLongFieldDef
地理投影标记的纬度位置。
- latitude2dict,
DatumDef
,Position2Def
,PositionValueDef
,SecondaryFieldDef
地理投影范围标记
"area"
,"bar"
,"rect"
和"rule"
的纬度-2 位置。- longitudedict,
DatumDef
,LatLongDef
,LatLongFieldDef
地理投影标记的经度位置。
- longitude2dict,
DatumDef
,Position2Def
,PositionValueDef
,SecondaryFieldDef
地理投影范围标记
"area"
,"bar"
,"rect"
和"rule"
的经度-2 位置。- opacitydict,
NumericMarkPropDef
,FieldOrDatumDefWithConditionDatumDefnumber
,FieldOrDatumDefWithConditionMarkPropFieldDefnumber
,ValueDefWithConditionMarkPropFieldOrDatumDefnumber
标记的不透明度。
默认值:如果未定义,默认不透明度取决于 标记配置 的
opacity
属性。- orderdict,
OrderOnlyDef
,OrderFieldDef
,OrderValueDef
, Sequence[dict,OrderFieldDef
] 标记的顺序。
对于堆叠标记,此
order
通道编码 堆叠顺序。对于线和轨迹标记,此
order
通道编码线中数据点的顺序。这对于创建 连接散点图 非常有用。将order
设置为{"value": null}
会使线标记使用数据源中的原始顺序。否则,此
order
通道编码标记的图层顺序。
注意:在聚合图中,
order
字段应进行聚合,以避免创建额外的聚合分组。- radiusdict,
PolarDef
,PositionValueDef
,PositionDatumDefBase
,PositionFieldDefBase
弧形标记的外部半径(像素为单位)。
- radius2dict,
DatumDef
,Position2Def
,PositionValueDef
,SecondaryFieldDef
弧形标记的内部半径(像素为单位)。
- shapedict,
ShapeDef
,FieldOrDatumDefWithConditionDatumDefstringnull
,FieldOrDatumDefWithConditionMarkPropFieldDefTypeForShapestringnull
,ValueDefWithConditionMarkPropFieldOrDatumDefTypeForShapestringnull
标记的形状。
1. 对于
point
标记,支持的值包括: - 绘图形状:"circle"
,"square"
,"cross"
,"diamond"
,"triangle-up"
,"triangle-down"
,"triangle-right"
或"triangle-left"
。 - 线符号"stroke"
- 居中方向形状"arrow"
,"wedge"
或"triangle"
- 自定义 SVG 路径字符串 (为了正确调整大小,自定义形状路径应定义在坐标范围为 x 和 y 维度上从 -1 到 1 的方形边界框内。)对于
geoshape
标记,它应该是 geojson 数据的字段定义
默认值:如果未定义,默认形状取决于 标记配置 的
shape
属性。(如果未设置,则为"circle"
。)- sizedict,
NumericMarkPropDef
,FieldOrDatumDefWithConditionDatumDefnumber
,FieldOrDatumDefWithConditionMarkPropFieldDefnumber
,ValueDefWithConditionMarkPropFieldOrDatumDefnumber
标记的大小。
对于
"point"
,"square"
和"circle"
,- 符号大小,或标记的像素面积。对于
"bar"
和"tick"
- 条形图和刻度线的大小。对于
"text"
- 文本的字体大小。"line"
,"area"
和"rect"
不支持 size。(使用"trail"
代替大小变化的线)
- strokedict,
ColorDef
,FieldOrDatumDefWithConditionDatumDefGradientstringnull
,FieldOrDatumDefWithConditionMarkPropFieldDefGradientstringnull
,ValueDefWithConditionMarkPropFieldOrDatumDefGradientstringnull
标记的描边颜色。默认值:如果未定义,默认颜色取决于 标记配置 的
color
属性。注意:
stroke
编码的优先级高于color
,因此如果指定了冲突的编码,可能会覆盖color
编码。- strokeDashdict,
NumericArrayMarkPropDef
,FieldOrDatumDefWithConditionDatumDefnumberArray
,FieldOrDatumDefWithConditionMarkPropFieldDefnumberArray
,ValueDefWithConditionMarkPropFieldOrDatumDefnumberArray
标记的描边虚线样式。
默认值:
[1,0]
(无虚线)。- strokeOpacitydict,
NumericMarkPropDef
,FieldOrDatumDefWithConditionDatumDefnumber
,FieldOrDatumDefWithConditionMarkPropFieldDefnumber
,ValueDefWithConditionMarkPropFieldOrDatumDefnumber
标记的描边不透明度。
默认值:如果未定义,默认不透明度取决于 标记配置 的
strokeOpacity
属性。- strokeWidthdict,
NumericMarkPropDef
,FieldOrDatumDefWithConditionDatumDefnumber
,FieldOrDatumDefWithConditionMarkPropFieldDefnumber
,ValueDefWithConditionMarkPropFieldOrDatumDefnumber
标记的描边宽度。
默认值:如果未定义,默认描边宽度取决于 标记配置 的
strokeWidth
属性。- textdict,
TextDef
,ValueDefWithConditionStringFieldDefText
,FieldOrDatumDefWithConditionStringDatumDefText
,FieldOrDatumDefWithConditionStringFieldDefText
text
标记的文本。- thetadict,
PolarDef
,PositionValueDef
,PositionDatumDefBase
,PositionFieldDefBase
对于弧形标记,如果未指定 theta2,则为弧长(弧度为单位),否则为起始弧角。(值为 0 表示向上或“北方”,值增加表示顺时针方向。)
对于文本标记,极坐标角度(弧度为单位)。
- theta2dict,
DatumDef
,Position2Def
,PositionValueDef
,SecondaryFieldDef
弧形标记的结束角(弧度为单位)。值为 0 表示向上或“北方”,值增加表示顺时针方向。
- tooltipdict,
StringFieldDefWithCondition
,StringValueDefWithCondition
, Sequence[dict,StringFieldDef
], None 鼠标悬停时显示的工具提示文本。指定
tooltip
编码会覆盖 标记定义中的工具提示属性。有关 Vega-Lite 中工具提示的详细讨论,请参阅 工具提示 文档。
- urldict,
StringFieldDefWithCondition
,StringValueDefWithCondition
图像标记的 URL。
- xdict,
PositionDef
,PositionDatumDef
,PositionFieldDef
,PositionValueDef
标记的 X 坐标,或未指定
x2
或width
的水平"bar"
和"area"
的宽度。此通道的
value
可以是一个数字,也可以是一个字符串"width"
表示图的宽度。- x2dict,
DatumDef
,Position2Def
,PositionValueDef
,SecondaryFieldDef
范围标记
"area"
,"bar"
,"rect"
和"rule"
的 X2 坐标。此通道的
value
可以是一个数字,也可以是一个字符串"width"
表示图的宽度。- xErrordict,
ValueDefnumber
,SecondaryFieldDef
指定误差的
"errorbar"
和"errorband"
的 x 坐标误差值。- xError2dict,
ValueDefnumber
,SecondaryFieldDef
指定误差的
"errorbar"
和"errorband"
的 x 坐标次要误差值。- xOffsetdict,
OffsetDef
,ScaleDatumDef
,ScaleFieldDef
,ValueDefnumber
标记 x 位置的偏移量
- ydict,
PositionDef
,PositionDatumDef
,PositionFieldDef
,PositionValueDef
标记的 Y 坐标,或未指定
y2
或height
的垂直"bar"
和"area"
的高度。此通道的
value
可以是一个数字,也可以是一个字符串"height"
表示图的高度。- y2dict,
DatumDef
,Position2Def
,PositionValueDef
,SecondaryFieldDef
范围标记
"area"
,"bar"
,"rect"
和"rule"
的 Y2 坐标。此通道的
value
可以是一个数字,也可以是一个字符串"height"
表示图的高度。- yErrordict,
ValueDefnumber
,SecondaryFieldDef
指定误差的
"errorbar"
和"errorband"
的 y 坐标误差值。- yError2dict,
ValueDefnumber
,SecondaryFieldDef
指定误差的
"errorbar"
和"errorband"
的 y 坐标次要误差值。- yOffsetdict,
OffsetDef
,ScaleDatumDef
,ScaleFieldDef
,ValueDefnumber
标记 y 位置的偏移量
- angledict,
- __init__(angle=Undefined, color=Undefined, description=Undefined, detail=Undefined, fill=Undefined, fillOpacity=Undefined, href=Undefined, key=Undefined, latitude=Undefined, latitude2=Undefined, longitude=Undefined, longitude2=Undefined, opacity=Undefined, order=Undefined, radius=Undefined, radius2=Undefined, shape=Undefined, size=Undefined, stroke=Undefined, strokeDash=Undefined, strokeOpacity=Undefined, strokeWidth=Undefined, text=Undefined, theta=Undefined, theta2=Undefined, tooltip=Undefined, url=Undefined, x=Undefined, x2=Undefined, xError=Undefined, xError2=Undefined, xOffset=Undefined, y=Undefined, y2=Undefined, yError=Undefined, yError2=Undefined, yOffset=Undefined, **kwds)#
方法
__init__
([angle, color, description, ...])copy
([deep, ignore])返回对象的副本。
from_dict
(dct[, validate])从字典表示形式构建类。
from_json
(json_string[, validate])从有效的 JSON 字符串实例化对象。
resolve_references
([schema])在此对象的模式或根模式上下文中解析引用。
to_dict
([validate, ignore, context])返回对象的字典表示形式。
to_json
([validate, indent, sort_keys, ...])将此对象的 JSON 表示形式作为字符串输出。
validate
(instance[, schema])在根模式上下文中,根据类模式验证实例。
validate_property
(name, value[, schema])在根模式上下文中,根据属性模式验证属性。