From 798016479e9135e776238f3e4509e8fb1bdf5151 Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Sat, 16 Apr 2022 16:25:03 -0700 Subject: [PATCH 01/26] Add method based syntax from #1629 to v5 --- altair/utils/schemapi.py | 25 ++++++ altair/vegalite/v5/schema/channels.py | 106 +++++++++++++++++++++++++- tools/generate_schema_wrapper.py | 9 ++- tools/schemapi/schemapi.py | 25 ++++++ 4 files changed, 158 insertions(+), 7 deletions(-) diff --git a/altair/utils/schemapi.py b/altair/utils/schemapi.py index 2dfdc8ee1..3358d96f0 100644 --- a/altair/utils/schemapi.py +++ b/altair/utils/schemapi.py @@ -585,3 +585,28 @@ def from_dict( return cls(dct) else: return cls(dct) + + +class _PropertySetter(object): + def __init__(self, prop, schema): + self.prop = prop + self.schema = schema + + def __get__(self, obj, cls): + self.obj = obj + self.cls = cls + return self + + def __call__(self, *args, **kwargs): + obj = self.obj.copy() + # TODO: use schema to validate + obj[self.prop] = args[0] if args else kwargs + return obj + + +def with_property_setters(cls): + """Decorator to add property setters to a Schema class.""" + schema = cls.resolve_references() + for prop, propschema in schema.get("properties", {}).items(): + setattr(cls, prop, _PropertySetter(prop, propschema)) + return cls diff --git a/altair/vegalite/v5/schema/channels.py b/altair/vegalite/v5/schema/channels.py index 602a492ba..34bb21ab3 100644 --- a/altair/vegalite/v5/schema/channels.py +++ b/altair/vegalite/v5/schema/channels.py @@ -3,7 +3,7 @@ from . import core import pandas as pd -from altair.utils.schemapi import Undefined +from altair.utils.schemapi import Undefined, with_property_setters from altair.utils import parse_shorthand @@ -64,7 +64,7 @@ def to_dict(self, validate=True, ignore=(), context=None): class ValueChannelMixin(object): def to_dict(self, validate=True, ignore=(), context=None): context = context or {} - condition = getattr(self, 'condition', Undefined) + condition = self._get('condition', Undefined) copy = self # don't copy unless we need to if condition is not Undefined: if isinstance(condition, core.SchemaBase): @@ -81,7 +81,7 @@ def to_dict(self, validate=True, ignore=(), context=None): class DatumChannelMixin(object): def to_dict(self, validate=True, ignore=(), context=None): context = context or {} - datum = getattr(self, 'datum', Undefined) + datum = self._get('datum', Undefined) copy = self # don't copy unless we need to if datum is not Undefined: if isinstance(datum, core.SchemaBase): @@ -90,7 +90,7 @@ def to_dict(self, validate=True, ignore=(), context=None): ignore=ignore, context=context) - +@with_property_setters class Angle(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDefnumber): """Angle schema wrapper @@ -330,6 +330,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi **kwds) +@with_property_setters class AngleDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefnumber): """AngleDatum schema wrapper @@ -453,6 +454,7 @@ def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Und title=title, type=type, **kwds) +@with_property_setters class AngleValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDatumDefnumber): """AngleValue schema wrapper @@ -476,6 +478,7 @@ def __init__(self, value, condition=Undefined, **kwds): super(AngleValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class Color(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDefGradientstringnull): """Color schema wrapper @@ -715,6 +718,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi **kwds) +@with_property_setters class ColorDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefGradientstringnull): """ColorDatum schema wrapper @@ -838,6 +842,7 @@ def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Und title=title, type=type, **kwds) +@with_property_setters class ColorValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDatumDefGradientstringnull): """ColorValue schema wrapper @@ -862,6 +867,7 @@ def __init__(self, value, condition=Undefined, **kwds): super(ColorValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class Column(FieldChannelMixin, core.RowColumnEncodingFieldDef): """Column schema wrapper @@ -1085,6 +1091,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, align=Undefined, title=title, type=type, **kwds) +@with_property_setters class Description(FieldChannelMixin, core.StringFieldDefWithCondition): """Description schema wrapper @@ -1298,6 +1305,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, type=type, **kwds) +@with_property_setters class DescriptionValue(ValueChannelMixin, core.StringValueDefWithCondition): """DescriptionValue schema wrapper @@ -1322,6 +1330,7 @@ def __init__(self, value, condition=Undefined, **kwds): super(DescriptionValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class Detail(FieldChannelMixin, core.FieldDefWithoutScale): """Detail schema wrapper @@ -1490,6 +1499,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi title=title, type=type, **kwds) +@with_property_setters class Facet(FieldChannelMixin, core.FacetEncodingFieldDef): """Facet schema wrapper @@ -1751,6 +1761,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, align=Undefined, spacing=spacing, timeUnit=timeUnit, title=title, type=type, **kwds) +@with_property_setters class Fill(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDefGradientstringnull): """Fill schema wrapper @@ -1990,6 +2001,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi **kwds) +@with_property_setters class FillDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefGradientstringnull): """FillDatum schema wrapper @@ -2113,6 +2125,7 @@ def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Und title=title, type=type, **kwds) +@with_property_setters class FillValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDatumDefGradientstringnull): """FillValue schema wrapper @@ -2137,6 +2150,7 @@ def __init__(self, value, condition=Undefined, **kwds): super(FillValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class FillOpacity(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDefnumber): """FillOpacity schema wrapper @@ -2376,6 +2390,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, type=type, **kwds) +@with_property_setters class FillOpacityDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefnumber): """FillOpacityDatum schema wrapper @@ -2499,6 +2514,7 @@ def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Und condition=condition, title=title, type=type, **kwds) +@with_property_setters class FillOpacityValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDatumDefnumber): """FillOpacityValue schema wrapper @@ -2522,6 +2538,7 @@ def __init__(self, value, condition=Undefined, **kwds): super(FillOpacityValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class Href(FieldChannelMixin, core.StringFieldDefWithCondition): """Href schema wrapper @@ -2735,6 +2752,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi **kwds) +@with_property_setters class HrefValue(ValueChannelMixin, core.StringValueDefWithCondition): """HrefValue schema wrapper @@ -2759,6 +2777,7 @@ def __init__(self, value, condition=Undefined, **kwds): super(HrefValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class Key(FieldChannelMixin, core.FieldDefWithoutScale): """Key schema wrapper @@ -2927,6 +2946,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi **kwds) +@with_property_setters class Latitude(FieldChannelMixin, core.LatLongFieldDef): """Latitude schema wrapper @@ -3094,6 +3114,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, type=type, **kwds) +@with_property_setters class LatitudeDatum(DatumChannelMixin, core.DatumDef): """LatitudeDatum schema wrapper @@ -3206,6 +3227,7 @@ def __init__(self, datum, bandPosition=Undefined, title=Undefined, type=Undefine type=type, **kwds) +@with_property_setters class Latitude2(FieldChannelMixin, core.SecondaryFieldDef): """Latitude2 schema wrapper @@ -3306,6 +3328,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, **kwds) +@with_property_setters class Latitude2Datum(DatumChannelMixin, core.DatumDef): """Latitude2Datum schema wrapper @@ -3418,6 +3441,7 @@ def __init__(self, datum, bandPosition=Undefined, title=Undefined, type=Undefine type=type, **kwds) +@with_property_setters class Latitude2Value(ValueChannelMixin, core.PositionValueDef): """Latitude2Value schema wrapper @@ -3440,6 +3464,7 @@ def __init__(self, value, **kwds): super(Latitude2Value, self).__init__(value=value, **kwds) +@with_property_setters class Longitude(FieldChannelMixin, core.LatLongFieldDef): """Longitude schema wrapper @@ -3607,6 +3632,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, type=type, **kwds) +@with_property_setters class LongitudeDatum(DatumChannelMixin, core.DatumDef): """LongitudeDatum schema wrapper @@ -3719,6 +3745,7 @@ def __init__(self, datum, bandPosition=Undefined, title=Undefined, type=Undefine type=type, **kwds) +@with_property_setters class Longitude2(FieldChannelMixin, core.SecondaryFieldDef): """Longitude2 schema wrapper @@ -3819,6 +3846,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, **kwds) +@with_property_setters class Longitude2Datum(DatumChannelMixin, core.DatumDef): """Longitude2Datum schema wrapper @@ -3931,6 +3959,7 @@ def __init__(self, datum, bandPosition=Undefined, title=Undefined, type=Undefine type=type, **kwds) +@with_property_setters class Longitude2Value(ValueChannelMixin, core.PositionValueDef): """Longitude2Value schema wrapper @@ -3953,6 +3982,7 @@ def __init__(self, value, **kwds): super(Longitude2Value, self).__init__(value=value, **kwds) +@with_property_setters class Opacity(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDefnumber): """Opacity schema wrapper @@ -4192,6 +4222,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, type=type, **kwds) +@with_property_setters class OpacityDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefnumber): """OpacityDatum schema wrapper @@ -4315,6 +4346,7 @@ def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Und title=title, type=type, **kwds) +@with_property_setters class OpacityValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDatumDefnumber): """OpacityValue schema wrapper @@ -4338,6 +4370,7 @@ def __init__(self, value, condition=Undefined, **kwds): super(OpacityValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class Order(FieldChannelMixin, core.OrderFieldDef): """Order schema wrapper @@ -4508,6 +4541,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi type=type, **kwds) +@with_property_setters class OrderValue(ValueChannelMixin, core.OrderValueDef): """OrderValue schema wrapper @@ -4536,6 +4570,7 @@ def __init__(self, value, condition=Undefined, **kwds): super(OrderValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class Radius(FieldChannelMixin, core.PositionFieldDefBase): """Radius schema wrapper @@ -4786,6 +4821,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi **kwds) +@with_property_setters class RadiusDatum(DatumChannelMixin, core.PositionDatumDefBase): """RadiusDatum schema wrapper @@ -4942,6 +4978,7 @@ def __init__(self, datum, bandPosition=Undefined, scale=Undefined, stack=Undefin stack=stack, title=title, type=type, **kwds) +@with_property_setters class RadiusValue(ValueChannelMixin, core.PositionValueDef): """RadiusValue schema wrapper @@ -4964,6 +5001,7 @@ def __init__(self, value, **kwds): super(RadiusValue, self).__init__(value=value, **kwds) +@with_property_setters class Radius2(FieldChannelMixin, core.SecondaryFieldDef): """Radius2 schema wrapper @@ -5064,6 +5102,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, **kwds) +@with_property_setters class Radius2Datum(DatumChannelMixin, core.DatumDef): """Radius2Datum schema wrapper @@ -5176,6 +5215,7 @@ def __init__(self, datum, bandPosition=Undefined, title=Undefined, type=Undefine type=type, **kwds) +@with_property_setters class Radius2Value(ValueChannelMixin, core.PositionValueDef): """Radius2Value schema wrapper @@ -5198,6 +5238,7 @@ def __init__(self, value, **kwds): super(Radius2Value, self).__init__(value=value, **kwds) +@with_property_setters class Row(FieldChannelMixin, core.RowColumnEncodingFieldDef): """Row schema wrapper @@ -5421,6 +5462,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, align=Undefined, title=title, type=type, **kwds) +@with_property_setters class Shape(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDefTypeForShapestringnull): """Shape schema wrapper @@ -5660,6 +5702,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi **kwds) +@with_property_setters class ShapeDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefstringnull): """ShapeDatum schema wrapper @@ -5783,6 +5826,7 @@ def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Und title=title, type=type, **kwds) +@with_property_setters class ShapeValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDatumDefTypeForShapestringnull): """ShapeValue schema wrapper @@ -5807,6 +5851,7 @@ def __init__(self, value, condition=Undefined, **kwds): super(ShapeValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class Size(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDefnumber): """Size schema wrapper @@ -6046,6 +6091,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi **kwds) +@with_property_setters class SizeDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefnumber): """SizeDatum schema wrapper @@ -6169,6 +6215,7 @@ def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Und title=title, type=type, **kwds) +@with_property_setters class SizeValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDatumDefnumber): """SizeValue schema wrapper @@ -6192,6 +6239,7 @@ def __init__(self, value, condition=Undefined, **kwds): super(SizeValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class Stroke(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDefGradientstringnull): """Stroke schema wrapper @@ -6431,6 +6479,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, type=type, **kwds) +@with_property_setters class StrokeDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefGradientstringnull): """StrokeDatum schema wrapper @@ -6554,6 +6603,7 @@ def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Und title=title, type=type, **kwds) +@with_property_setters class StrokeValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDatumDefGradientstringnull): """StrokeValue schema wrapper @@ -6578,6 +6628,7 @@ def __init__(self, value, condition=Undefined, **kwds): super(StrokeValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class StrokeDash(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDefnumberArray): """StrokeDash schema wrapper @@ -6817,6 +6868,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, type=type, **kwds) +@with_property_setters class StrokeDashDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefnumberArray): """StrokeDashDatum schema wrapper @@ -6940,6 +6992,7 @@ def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Und condition=condition, title=title, type=type, **kwds) +@with_property_setters class StrokeDashValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDatumDefnumberArray): """StrokeDashValue schema wrapper @@ -6964,6 +7017,7 @@ def __init__(self, value, condition=Undefined, **kwds): super(StrokeDashValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class StrokeOpacity(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDefnumber): """StrokeOpacity schema wrapper @@ -7203,6 +7257,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, type=type, **kwds) +@with_property_setters class StrokeOpacityDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefnumber): """StrokeOpacityDatum schema wrapper @@ -7326,6 +7381,7 @@ def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Und condition=condition, title=title, type=type, **kwds) +@with_property_setters class StrokeOpacityValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDatumDefnumber): """StrokeOpacityValue schema wrapper @@ -7349,6 +7405,7 @@ def __init__(self, value, condition=Undefined, **kwds): super(StrokeOpacityValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class StrokeWidth(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDefnumber): """StrokeWidth schema wrapper @@ -7588,6 +7645,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, type=type, **kwds) +@with_property_setters class StrokeWidthDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefnumber): """StrokeWidthDatum schema wrapper @@ -7711,6 +7769,7 @@ def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Und condition=condition, title=title, type=type, **kwds) +@with_property_setters class StrokeWidthValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDatumDefnumber): """StrokeWidthValue schema wrapper @@ -7734,6 +7793,7 @@ def __init__(self, value, condition=Undefined, **kwds): super(StrokeWidthValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class Text(FieldChannelMixin, core.FieldOrDatumDefWithConditionStringFieldDefText): """Text schema wrapper @@ -7947,6 +8007,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi **kwds) +@with_property_setters class TextDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionStringDatumDefText): """TextDatum schema wrapper @@ -8105,6 +8166,7 @@ def __init__(self, datum, bandPosition=Undefined, condition=Undefined, format=Un **kwds) +@with_property_setters class TextValue(ValueChannelMixin, core.ValueDefWithConditionStringFieldDefText): """TextValue schema wrapper @@ -8128,6 +8190,7 @@ def __init__(self, value, condition=Undefined, **kwds): super(TextValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class Theta(FieldChannelMixin, core.PositionFieldDefBase): """Theta schema wrapper @@ -8377,6 +8440,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, type=type, **kwds) +@with_property_setters class ThetaDatum(DatumChannelMixin, core.PositionDatumDefBase): """ThetaDatum schema wrapper @@ -8533,6 +8597,7 @@ def __init__(self, datum, bandPosition=Undefined, scale=Undefined, stack=Undefin stack=stack, title=title, type=type, **kwds) +@with_property_setters class ThetaValue(ValueChannelMixin, core.PositionValueDef): """ThetaValue schema wrapper @@ -8555,6 +8620,7 @@ def __init__(self, value, **kwds): super(ThetaValue, self).__init__(value=value, **kwds) +@with_property_setters class Theta2(FieldChannelMixin, core.SecondaryFieldDef): """Theta2 schema wrapper @@ -8655,6 +8721,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi title=title, **kwds) +@with_property_setters class Theta2Datum(DatumChannelMixin, core.DatumDef): """Theta2Datum schema wrapper @@ -8767,6 +8834,7 @@ def __init__(self, datum, bandPosition=Undefined, title=Undefined, type=Undefine type=type, **kwds) +@with_property_setters class Theta2Value(ValueChannelMixin, core.PositionValueDef): """Theta2Value schema wrapper @@ -8789,6 +8857,7 @@ def __init__(self, value, **kwds): super(Theta2Value, self).__init__(value=value, **kwds) +@with_property_setters class Tooltip(FieldChannelMixin, core.StringFieldDefWithCondition): """Tooltip schema wrapper @@ -9002,6 +9071,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, type=type, **kwds) +@with_property_setters class TooltipValue(ValueChannelMixin, core.StringValueDefWithCondition): """TooltipValue schema wrapper @@ -9026,6 +9096,7 @@ def __init__(self, value, condition=Undefined, **kwds): super(TooltipValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class Url(FieldChannelMixin, core.StringFieldDefWithCondition): """Url schema wrapper @@ -9239,6 +9310,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi **kwds) +@with_property_setters class UrlValue(ValueChannelMixin, core.StringValueDefWithCondition): """UrlValue schema wrapper @@ -9263,6 +9335,7 @@ def __init__(self, value, condition=Undefined, **kwds): super(UrlValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class X(FieldChannelMixin, core.PositionFieldDef): """X schema wrapper @@ -9530,6 +9603,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, axis=Undefined, ban type=type, **kwds) +@with_property_setters class XDatum(DatumChannelMixin, core.PositionDatumDef): """XDatum schema wrapper @@ -9703,6 +9777,7 @@ def __init__(self, datum, axis=Undefined, bandPosition=Undefined, impute=Undefin scale=scale, stack=stack, title=title, type=type, **kwds) +@with_property_setters class XValue(ValueChannelMixin, core.PositionValueDef): """XValue schema wrapper @@ -9725,6 +9800,7 @@ def __init__(self, value, **kwds): super(XValue, self).__init__(value=value, **kwds) +@with_property_setters class X2(FieldChannelMixin, core.SecondaryFieldDef): """X2 schema wrapper @@ -9824,6 +9900,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi bin=bin, field=field, timeUnit=timeUnit, title=title, **kwds) +@with_property_setters class X2Datum(DatumChannelMixin, core.DatumDef): """X2Datum schema wrapper @@ -9936,6 +10013,7 @@ def __init__(self, datum, bandPosition=Undefined, title=Undefined, type=Undefine **kwds) +@with_property_setters class X2Value(ValueChannelMixin, core.PositionValueDef): """X2Value schema wrapper @@ -9958,6 +10036,7 @@ def __init__(self, value, **kwds): super(X2Value, self).__init__(value=value, **kwds) +@with_property_setters class XError(FieldChannelMixin, core.SecondaryFieldDef): """XError schema wrapper @@ -10058,6 +10137,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi title=title, **kwds) +@with_property_setters class XErrorValue(ValueChannelMixin, core.ValueDefnumber): """XErrorValue schema wrapper @@ -10080,6 +10160,7 @@ def __init__(self, value, **kwds): super(XErrorValue, self).__init__(value=value, **kwds) +@with_property_setters class XError2(FieldChannelMixin, core.SecondaryFieldDef): """XError2 schema wrapper @@ -10180,6 +10261,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, **kwds) +@with_property_setters class XError2Value(ValueChannelMixin, core.ValueDefnumber): """XError2Value schema wrapper @@ -10202,6 +10284,7 @@ def __init__(self, value, **kwds): super(XError2Value, self).__init__(value=value, **kwds) +@with_property_setters class XOffset(FieldChannelMixin, core.ScaleFieldDef): """XOffset schema wrapper @@ -10421,6 +10504,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi sort=sort, timeUnit=timeUnit, title=title, type=type, **kwds) +@with_property_setters class XOffsetDatum(DatumChannelMixin, core.ScaleDatumDef): """XOffsetDatum schema wrapper @@ -10547,6 +10631,7 @@ def __init__(self, datum, bandPosition=Undefined, scale=Undefined, title=Undefin title=title, type=type, **kwds) +@with_property_setters class XOffsetValue(ValueChannelMixin, core.ValueDefnumber): """XOffsetValue schema wrapper @@ -10569,6 +10654,7 @@ def __init__(self, value, **kwds): super(XOffsetValue, self).__init__(value=value, **kwds) +@with_property_setters class Y(FieldChannelMixin, core.PositionFieldDef): """Y schema wrapper @@ -10836,6 +10922,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, axis=Undefined, ban type=type, **kwds) +@with_property_setters class YDatum(DatumChannelMixin, core.PositionDatumDef): """YDatum schema wrapper @@ -11009,6 +11096,7 @@ def __init__(self, datum, axis=Undefined, bandPosition=Undefined, impute=Undefin scale=scale, stack=stack, title=title, type=type, **kwds) +@with_property_setters class YValue(ValueChannelMixin, core.PositionValueDef): """YValue schema wrapper @@ -11031,6 +11119,7 @@ def __init__(self, value, **kwds): super(YValue, self).__init__(value=value, **kwds) +@with_property_setters class Y2(FieldChannelMixin, core.SecondaryFieldDef): """Y2 schema wrapper @@ -11130,6 +11219,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi bin=bin, field=field, timeUnit=timeUnit, title=title, **kwds) +@with_property_setters class Y2Datum(DatumChannelMixin, core.DatumDef): """Y2Datum schema wrapper @@ -11242,6 +11332,7 @@ def __init__(self, datum, bandPosition=Undefined, title=Undefined, type=Undefine **kwds) +@with_property_setters class Y2Value(ValueChannelMixin, core.PositionValueDef): """Y2Value schema wrapper @@ -11264,6 +11355,7 @@ def __init__(self, value, **kwds): super(Y2Value, self).__init__(value=value, **kwds) +@with_property_setters class YError(FieldChannelMixin, core.SecondaryFieldDef): """YError schema wrapper @@ -11364,6 +11456,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi title=title, **kwds) +@with_property_setters class YErrorValue(ValueChannelMixin, core.ValueDefnumber): """YErrorValue schema wrapper @@ -11386,6 +11479,7 @@ def __init__(self, value, **kwds): super(YErrorValue, self).__init__(value=value, **kwds) +@with_property_setters class YError2(FieldChannelMixin, core.SecondaryFieldDef): """YError2 schema wrapper @@ -11486,6 +11580,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, **kwds) +@with_property_setters class YError2Value(ValueChannelMixin, core.ValueDefnumber): """YError2Value schema wrapper @@ -11508,6 +11603,7 @@ def __init__(self, value, **kwds): super(YError2Value, self).__init__(value=value, **kwds) +@with_property_setters class YOffset(FieldChannelMixin, core.ScaleFieldDef): """YOffset schema wrapper @@ -11727,6 +11823,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi sort=sort, timeUnit=timeUnit, title=title, type=type, **kwds) +@with_property_setters class YOffsetDatum(DatumChannelMixin, core.ScaleDatumDef): """YOffsetDatum schema wrapper @@ -11853,6 +11950,7 @@ def __init__(self, datum, bandPosition=Undefined, scale=Undefined, title=Undefin title=title, type=type, **kwds) +@with_property_setters class YOffsetValue(ValueChannelMixin, core.ValueDefnumber): """YOffsetValue schema wrapper diff --git a/tools/generate_schema_wrapper.py b/tools/generate_schema_wrapper.py index 2520df997..dcabb6280 100644 --- a/tools/generate_schema_wrapper.py +++ b/tools/generate_schema_wrapper.py @@ -145,7 +145,7 @@ def to_dict(self, validate=True, ignore=(), context=None): class ValueChannelMixin(object): def to_dict(self, validate=True, ignore=(), context=None): context = context or {} - condition = getattr(self, 'condition', Undefined) + condition = self._get('condition', Undefined) copy = self # don't copy unless we need to if condition is not Undefined: if isinstance(condition, core.SchemaBase): @@ -162,7 +162,7 @@ def to_dict(self, validate=True, ignore=(), context=None): class DatumChannelMixin(object): def to_dict(self, validate=True, ignore=(), context=None): context = context or {} - datum = getattr(self, 'datum', Undefined) + datum = self._get('datum', Undefined) copy = self # don't copy unless we need to if datum is not Undefined: if isinstance(datum, core.SchemaBase): @@ -176,6 +176,7 @@ def to_dict(self, validate=True, ignore=(), context=None): class FieldSchemaGenerator(SchemaGenerator): schema_class_template = textwrap.dedent( ''' + @with_property_setters class {classname}(FieldChannelMixin, core.{basename}): """{docstring}""" _class_is_valid_at_instantiation = False @@ -189,6 +190,7 @@ class {classname}(FieldChannelMixin, core.{basename}): class ValueSchemaGenerator(SchemaGenerator): schema_class_template = textwrap.dedent( ''' + @with_property_setters class {classname}(ValueChannelMixin, core.{basename}): """{docstring}""" _class_is_valid_at_instantiation = False @@ -202,6 +204,7 @@ class {classname}(ValueChannelMixin, core.{basename}): class DatumSchemaGenerator(SchemaGenerator): schema_class_template = textwrap.dedent( ''' + @with_property_setters class {classname}(DatumChannelMixin, core.{basename}): """{docstring}""" _class_is_valid_at_instantiation = False @@ -428,7 +431,7 @@ def generate_vegalite_channel_wrappers(schemafile, version, imports=None): imports = [ "from . import core", "import pandas as pd", - "from altair.utils.schemapi import Undefined", + "from altair.utils.schemapi import Undefined, with_property_setters", "from altair.utils import parse_shorthand", ] contents = [HEADER] diff --git a/tools/schemapi/schemapi.py b/tools/schemapi/schemapi.py index 3ca87b991..de20144a2 100644 --- a/tools/schemapi/schemapi.py +++ b/tools/schemapi/schemapi.py @@ -583,3 +583,28 @@ def from_dict( return cls(dct) else: return cls(dct) + + +class _PropertySetter(object): + def __init__(self, prop, schema): + self.prop = prop + self.schema = schema + + def __get__(self, obj, cls): + self.obj = obj + self.cls = cls + return self + + def __call__(self, *args, **kwargs): + obj = self.obj.copy() + # TODO: use schema to validate + obj[self.prop] = args[0] if args else kwargs + return obj + + +def with_property_setters(cls): + """Decorator to add property setters to a Schema class.""" + schema = cls.resolve_references() + for prop, propschema in schema.get("properties", {}).items(): + setattr(cls, prop, _PropertySetter(prop, propschema)) + return cls From 91ddea9170e3949286daa9889f5e2bd91e3d8249 Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Thu, 12 May 2022 17:33:00 -0700 Subject: [PATCH 02/26] Add correct function signatures and docstrings, and initial autocompletion parameter support --- altair/utils/schemapi.py | 7 +++++++ tools/schemapi/schemapi.py | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/altair/utils/schemapi.py b/altair/utils/schemapi.py index 3358d96f0..822f58e0b 100644 --- a/altair/utils/schemapi.py +++ b/altair/utils/schemapi.py @@ -9,6 +9,8 @@ import numpy as np import pandas as pd +from .. import vegalite + # If DEBUG_MODE is True, then schema objects are converted to dict and # validated at creation time. This slows things down, particularly for @@ -595,6 +597,11 @@ def __init__(self, prop, schema): def __get__(self, obj, cls): self.obj = obj self.cls = cls + altair_prop = getattr(vegalite, f"{self.prop}".capitalize()) + self.__doc__ = altair_prop.__doc__ + self.__signature__ = inspect.signature(altair_prop) + self.__wrapped__ = inspect.getfullargspec(altair_prop) + self.__name__ = altair_prop.__name__ return self def __call__(self, *args, **kwargs): diff --git a/tools/schemapi/schemapi.py b/tools/schemapi/schemapi.py index de20144a2..9127bb8fd 100644 --- a/tools/schemapi/schemapi.py +++ b/tools/schemapi/schemapi.py @@ -7,6 +7,8 @@ import numpy as np import pandas as pd +from ..altair import vegalite + # If DEBUG_MODE is True, then schema objects are converted to dict and # validated at creation time. This slows things down, particularly for @@ -593,6 +595,11 @@ def __init__(self, prop, schema): def __get__(self, obj, cls): self.obj = obj self.cls = cls + altair_prop = getattr(vegalite, f"{self.prop}".capitalize()) + self.__doc__ = altair_prop.__doc__ + self.__signature__ = inspect.signature(altair_prop) + self.__wrapped__ = inspect.getfullargspec(altair_prop) + self.__name__ = altair_prop.__name__ return self def __call__(self, *args, **kwargs): From cc5ca7c12b659bc206cc04546700b5ec806780e0 Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Wed, 30 Nov 2022 14:51:47 -0800 Subject: [PATCH 03/26] Add general param info to docstrings and pass through adding the helper class docstring when not appropriate --- altair/utils/schemapi.py | 30 +++++++++++++++++++++++++----- tools/schemapi/schemapi.py | 30 +++++++++++++++++++++++++----- 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/altair/utils/schemapi.py b/altair/utils/schemapi.py index b4671bec5..7576145ce 100644 --- a/altair/utils/schemapi.py +++ b/altair/utils/schemapi.py @@ -4,6 +4,7 @@ import contextlib import inspect import json +import textwrap from typing import Any import jsonschema @@ -602,11 +603,30 @@ def __init__(self, prop, schema): def __get__(self, obj, cls): self.obj = obj self.cls = cls - altair_prop = getattr(vegalite, f"{self.prop}".capitalize()) - self.__doc__ = altair_prop.__doc__ - self.__signature__ = inspect.signature(altair_prop) - self.__wrapped__ = inspect.getfullargspec(altair_prop) - self.__name__ = altair_prop.__name__ + # The docs from the encoding class parameter (e.g. `bin` in X, Color, + # etc); this provides a general description of the parameter. + self.__doc__ = self.schema['description'].replace('__', '**') + property_name = f"{self.prop}"[0].upper() + f"{self.prop}"[1:] + if hasattr(vegalite, property_name): + altair_prop = getattr(vegalite, property_name) + # Add the docstring from the helper class (e.g. `BinParams`) so + # that all the parameter names of the helper class are included in + # the final docstring + attribute_index = altair_prop.__doc__.index("Attributes\n") + self.__doc__ = ( + altair_prop.__doc__[:attribute_index].replace(' ', '') + + self.__doc__ + + textwrap.dedent(f'\n\n {altair_prop.__doc__[attribute_index:]}') + ) + # Add signatures and tab completion for the method and parameter names + # Currently works for `alt.X.bin` but not alt.X().bin` + self.__signature__ = inspect.signature(altair_prop) + self.__wrapped__ = inspect.getfullargspec(altair_prop) + self.__name__ = altair_prop.__name__ + else: + # It seems like bandPosition is the only parameter that doesn't + # have a helper class. + pass return self def __call__(self, *args, **kwargs): diff --git a/tools/schemapi/schemapi.py b/tools/schemapi/schemapi.py index 245f2bc07..13c3db78c 100644 --- a/tools/schemapi/schemapi.py +++ b/tools/schemapi/schemapi.py @@ -2,6 +2,7 @@ import contextlib import inspect import json +import textwrap from typing import Any import jsonschema @@ -600,11 +601,30 @@ def __init__(self, prop, schema): def __get__(self, obj, cls): self.obj = obj self.cls = cls - altair_prop = getattr(vegalite, f"{self.prop}".capitalize()) - self.__doc__ = altair_prop.__doc__ - self.__signature__ = inspect.signature(altair_prop) - self.__wrapped__ = inspect.getfullargspec(altair_prop) - self.__name__ = altair_prop.__name__ + # The docs from the encoding class parameter (e.g. `bin` in X, Color, + # etc); this provides a general description of the parameter. + self.__doc__ = self.schema['description'].replace('__', '**') + property_name = f"{self.prop}"[0].upper() + f"{self.prop}"[1:] + if hasattr(vegalite, property_name): + altair_prop = getattr(vegalite, property_name) + # Add the docstring from the helper class (e.g. `BinParams`) so + # that all the parameter names of the helper class are included in + # the final docstring + attribute_index = altair_prop.__doc__.index("Attributes\n") + self.__doc__ = ( + altair_prop.__doc__[:attribute_index].replace(' ', '') + + self.__doc__ + + textwrap.dedent(f'\n\n {altair_prop.__doc__[attribute_index:]}') + ) + # Add signatures and tab completion for the method and parameter names + # Currently works for `alt.X.bin` but not alt.X().bin` + self.__signature__ = inspect.signature(altair_prop) + self.__wrapped__ = inspect.getfullargspec(altair_prop) + self.__name__ = altair_prop.__name__ + else: + # It seems like bandPosition is the only parameter that doesn't + # have a helper class. + pass return self def __call__(self, *args, **kwargs): From de8c650f1ef03297c480bc468423fe4c1cc71731 Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Wed, 30 Nov 2022 15:04:13 -0800 Subject: [PATCH 04/26] Deal with docstring missing "Attributes" tag --- altair/utils/schemapi.py | 19 +++++++++++++------ tools/schemapi/schemapi.py | 19 +++++++++++++------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/altair/utils/schemapi.py b/altair/utils/schemapi.py index 7576145ce..287a0950d 100644 --- a/altair/utils/schemapi.py +++ b/altair/utils/schemapi.py @@ -612,12 +612,19 @@ def __get__(self, obj, cls): # Add the docstring from the helper class (e.g. `BinParams`) so # that all the parameter names of the helper class are included in # the final docstring - attribute_index = altair_prop.__doc__.index("Attributes\n") - self.__doc__ = ( - altair_prop.__doc__[:attribute_index].replace(' ', '') - + self.__doc__ - + textwrap.dedent(f'\n\n {altair_prop.__doc__[attribute_index:]}') - ) + attribute_index = altair_prop.__doc__.find("Attributes\n") + if attribute_index > -1: + self.__doc__ = ( + altair_prop.__doc__[:attribute_index].replace(' ', '') + + self.__doc__ + + textwrap.dedent(f'\n\n {altair_prop.__doc__[attribute_index:]}') + ) + # For short docsstrings such as Aggregate, Stack, et + else: + self.__doc__ = ( + altair_prop.__doc__.replace(' ', '') + + '\n' + self.__doc__ + ) # Add signatures and tab completion for the method and parameter names # Currently works for `alt.X.bin` but not alt.X().bin` self.__signature__ = inspect.signature(altair_prop) diff --git a/tools/schemapi/schemapi.py b/tools/schemapi/schemapi.py index 13c3db78c..b4f9f1f82 100644 --- a/tools/schemapi/schemapi.py +++ b/tools/schemapi/schemapi.py @@ -610,12 +610,19 @@ def __get__(self, obj, cls): # Add the docstring from the helper class (e.g. `BinParams`) so # that all the parameter names of the helper class are included in # the final docstring - attribute_index = altair_prop.__doc__.index("Attributes\n") - self.__doc__ = ( - altair_prop.__doc__[:attribute_index].replace(' ', '') - + self.__doc__ - + textwrap.dedent(f'\n\n {altair_prop.__doc__[attribute_index:]}') - ) + attribute_index = altair_prop.__doc__.find("Attributes\n") + if attribute_index > -1: + self.__doc__ = ( + altair_prop.__doc__[:attribute_index].replace(' ', '') + + self.__doc__ + + textwrap.dedent(f'\n\n {altair_prop.__doc__[attribute_index:]}') + ) + # For short docsstrings such as Aggregate, Stack, et + else: + self.__doc__ = ( + altair_prop.__doc__.replace(' ', '') + + '\n' + self.__doc__ + ) # Add signatures and tab completion for the method and parameter names # Currently works for `alt.X.bin` but not alt.X().bin` self.__signature__ = inspect.signature(altair_prop) From 3e45b79faf2e64d5b4a21c85d53ac503caec7894 Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Wed, 30 Nov 2022 15:14:31 -0800 Subject: [PATCH 05/26] Fix black formatting --- altair/utils/schemapi.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/altair/utils/schemapi.py b/altair/utils/schemapi.py index 287a0950d..d1e705624 100644 --- a/altair/utils/schemapi.py +++ b/altair/utils/schemapi.py @@ -605,7 +605,7 @@ def __get__(self, obj, cls): self.cls = cls # The docs from the encoding class parameter (e.g. `bin` in X, Color, # etc); this provides a general description of the parameter. - self.__doc__ = self.schema['description'].replace('__', '**') + self.__doc__ = self.schema["description"].replace("__", "**") property_name = f"{self.prop}"[0].upper() + f"{self.prop}"[1:] if hasattr(vegalite, property_name): altair_prop = getattr(vegalite, property_name) @@ -615,15 +615,17 @@ def __get__(self, obj, cls): attribute_index = altair_prop.__doc__.find("Attributes\n") if attribute_index > -1: self.__doc__ = ( - altair_prop.__doc__[:attribute_index].replace(' ', '') + altair_prop.__doc__[:attribute_index].replace(" ", "") + self.__doc__ - + textwrap.dedent(f'\n\n {altair_prop.__doc__[attribute_index:]}') + + textwrap.dedent( + f'\n\n {altair_prop.__doc__[attribute_index:]}' + ) ) # For short docsstrings such as Aggregate, Stack, et else: self.__doc__ = ( - altair_prop.__doc__.replace(' ', '') - + '\n' + self.__doc__ + altair_prop.__doc__.replace(" ", "") + + "\n" + self.__doc__ ) # Add signatures and tab completion for the method and parameter names # Currently works for `alt.X.bin` but not alt.X().bin` From 0bc0aa1ff2e6b57e54cf5f67385adcdeb6e49714 Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Wed, 30 Nov 2022 15:16:32 -0800 Subject: [PATCH 06/26] Fix black formatting --- altair/utils/schemapi.py | 5 ++--- tools/schemapi/schemapi.py | 11 ++++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/altair/utils/schemapi.py b/altair/utils/schemapi.py index d1e705624..5daeebc1d 100644 --- a/altair/utils/schemapi.py +++ b/altair/utils/schemapi.py @@ -618,14 +618,13 @@ def __get__(self, obj, cls): altair_prop.__doc__[:attribute_index].replace(" ", "") + self.__doc__ + textwrap.dedent( - f'\n\n {altair_prop.__doc__[attribute_index:]}' + f"\n\n {altair_prop.__doc__[attribute_index:]}" ) ) # For short docsstrings such as Aggregate, Stack, et else: self.__doc__ = ( - altair_prop.__doc__.replace(" ", "") - + "\n" + self.__doc__ + altair_prop.__doc__.replace(" ", "") + "\n" + self.__doc__ ) # Add signatures and tab completion for the method and parameter names # Currently works for `alt.X.bin` but not alt.X().bin` diff --git a/tools/schemapi/schemapi.py b/tools/schemapi/schemapi.py index b4f9f1f82..5faceec78 100644 --- a/tools/schemapi/schemapi.py +++ b/tools/schemapi/schemapi.py @@ -603,7 +603,7 @@ def __get__(self, obj, cls): self.cls = cls # The docs from the encoding class parameter (e.g. `bin` in X, Color, # etc); this provides a general description of the parameter. - self.__doc__ = self.schema['description'].replace('__', '**') + self.__doc__ = self.schema["description"].replace("__", "**") property_name = f"{self.prop}"[0].upper() + f"{self.prop}"[1:] if hasattr(vegalite, property_name): altair_prop = getattr(vegalite, property_name) @@ -613,15 +613,16 @@ def __get__(self, obj, cls): attribute_index = altair_prop.__doc__.find("Attributes\n") if attribute_index > -1: self.__doc__ = ( - altair_prop.__doc__[:attribute_index].replace(' ', '') + altair_prop.__doc__[:attribute_index].replace(" ", "") + self.__doc__ - + textwrap.dedent(f'\n\n {altair_prop.__doc__[attribute_index:]}') + + textwrap.dedent( + f"\n\n {altair_prop.__doc__[attribute_index:]}" + ) ) # For short docsstrings such as Aggregate, Stack, et else: self.__doc__ = ( - altair_prop.__doc__.replace(' ', '') - + '\n' + self.__doc__ + altair_prop.__doc__.replace(" ", "") + "\n" + self.__doc__ ) # Add signatures and tab completion for the method and parameter names # Currently works for `alt.X.bin` but not alt.X().bin` From d749916ecff38e8755a58cfd0bdc2b3a44891428 Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Sun, 4 Dec 2022 20:29:04 -0800 Subject: [PATCH 07/26] Update a few gallery examples to the method based syntax --- altair/examples/airport_connections.py | 22 ++++----- altair/examples/annual_weather_heatmap.py | 13 +++-- altair/examples/anscombe_plot.py | 4 +- altair/examples/bar_chart_trellis_compact.py | 12 ++--- .../examples/beckers_barley_trellis_plot.py | 31 +++++------- .../examples/beckers_barley_wrapped_facet.py | 2 +- altair/examples/bump_chart.py | 6 +-- altair/examples/candlestick_chart.py | 28 +++++------ altair/examples/co2_concentration.py | 29 ++++++----- altair/examples/comet_chart.py | 48 ++++++++++++------- altair/examples/connected_scatterplot.py | 4 +- altair/examples/density_stack.py | 2 +- .../examples/diverging_stacked_bar_chart.py | 8 +--- altair/examples/donut_chart.py | 9 ++-- altair/examples/dot_dash_plot.py | 12 ++--- altair/examples/streamgraph.py | 10 ++-- 16 files changed, 120 insertions(+), 120 deletions(-) diff --git a/altair/examples/airport_connections.py b/altair/examples/airport_connections.py index ef1363abc..0b54db495 100644 --- a/altair/examples/airport_connections.py +++ b/altair/examples/airport_connections.py @@ -1,8 +1,8 @@ """ Connections Among U.S. Airports Interactive ------------------------------------------- -This example shows all the connections between major U.S. airports. Lookup transformations -are used to find the coordinates of each airport and connecting airports. Connections +This example shows all the connections between major U.S. airports. Lookup transformations +are used to find the coordinates of each airport and connecting airports. Connections are displayed on mouseover via a single selection. """ # category: case studies @@ -26,10 +26,10 @@ ) background = alt.Chart(states).mark_geoshape( - fill="lightgray", + fill="lightgray", stroke="white" ).properties( - width=750, + width=750, height=500 ).project("albersUsa") @@ -39,11 +39,11 @@ latitude2="lat2:Q", longitude2="lon2:Q" ).transform_lookup( - lookup="origin", + lookup="origin", from_=lookup_data ).transform_lookup( - lookup="destination", - from_=lookup_data, + lookup="destination", + from_=lookup_data, as_=["state", "lat2", "lon2"] ).transform_filter( select_city @@ -52,14 +52,14 @@ points = alt.Chart(flights_airport).mark_circle().encode( latitude="latitude:Q", longitude="longitude:Q", - size=alt.Size("routes:Q", scale=alt.Scale(range=[0, 1000]), legend=None), - order=alt.Order("routes:Q", sort="descending"), + size=alt.Size("routes:Q").legend(None).scale(range=[0, 1000]), + order=alt.Order("routes:Q").sort("descending"), tooltip=["origin:N", "routes:Q"] ).transform_aggregate( - routes="count()", + routes="count()", groupby=["origin"] ).transform_lookup( - lookup="origin", + lookup="origin", from_=lookup_data ).transform_filter( (alt.datum.state != "PR") & (alt.datum.state != "VI") diff --git a/altair/examples/annual_weather_heatmap.py b/altair/examples/annual_weather_heatmap.py index 972c42404..d96b1e06c 100644 --- a/altair/examples/annual_weather_heatmap.py +++ b/altair/examples/annual_weather_heatmap.py @@ -9,11 +9,16 @@ source = data.seattle_weather() alt.Chart(source, title="Daily Max Temperatures (C) in Seattle, WA").mark_rect().encode( - x=alt.X("date(date):O", title="Day", axis=alt.Axis(format="%e", labelAngle=0)), - y=alt.Y("month(date):O", title="Month"), - color=alt.Color("max(temp_max)", legend=alt.Legend(title=None)), + alt.X("date(date):O").title("Day").axis(format="%e", labelAngle=0), + alt.Y("month(date):O").title("Month"), + alt.Color("max(temp_max)").title(None), tooltip=[ alt.Tooltip("monthdate(date)", title="Date"), alt.Tooltip("max(temp_max)", title="Max Temp"), ], -).configure_view(step=13, strokeWidth=0).configure_axis(domain=False) +).configure_view( + step=13, + strokeWidth=0 +).configure_axis( + domain=False +) diff --git a/altair/examples/anscombe_plot.py b/altair/examples/anscombe_plot.py index 9e2007485..906f15ee7 100644 --- a/altair/examples/anscombe_plot.py +++ b/altair/examples/anscombe_plot.py @@ -11,8 +11,8 @@ source = data.anscombe() alt.Chart(source).mark_circle().encode( - alt.X('X', scale=alt.Scale(zero=False)), - alt.Y('Y', scale=alt.Scale(zero=False)), + alt.X('X').scale(zero=False), + alt.Y('Y').scale(zero=False), alt.Facet('Series', columns=2), ).properties( width=180, diff --git a/altair/examples/bar_chart_trellis_compact.py b/altair/examples/bar_chart_trellis_compact.py index 6fb011476..2cb0e4b7d 100644 --- a/altair/examples/bar_chart_trellis_compact.py +++ b/altair/examples/bar_chart_trellis_compact.py @@ -40,11 +40,9 @@ ) alt.Chart(source, width=60, height=alt.Step(8)).mark_bar().encode( - y=alt.Y("c:N", axis=None), - x=alt.X("p:Q", title=None, axis=alt.Axis(format="%")), - color=alt.Color( - "c:N", title="settings", legend=alt.Legend(orient="bottom", titleOrient="left") - ), - row=alt.Row("a:N", title="Factor A", header=alt.Header(labelAngle=0)), - column=alt.Column("b:N", title="Factor B"), + alt.Y("c:N").axis(None), + alt.X("p:Q").title(None).axis(format="%"), + alt.Color("c:N").title("settings").legend(orient="bottom", titleOrient="left"), + alt.Row("a:N").title("Factor A").header(labelAngle=0), + alt.Column("b:N").title("Factor B"), ) diff --git a/altair/examples/beckers_barley_trellis_plot.py b/altair/examples/beckers_barley_trellis_plot.py index 4f780d963..9f7c68867 100644 --- a/altair/examples/beckers_barley_trellis_plot.py +++ b/altair/examples/beckers_barley_trellis_plot.py @@ -10,24 +10,19 @@ source = data.barley() alt.Chart(source, title="The Morris Mistake").mark_point().encode( - alt.X( - 'yield:Q', - title="Barley Yield (bushels/acre)", - scale=alt.Scale(zero=False), - axis=alt.Axis(grid=False) - ), - alt.Y( - 'variety:N', - title="", - sort='-x', - axis=alt.Axis(grid=True) - ), - color=alt.Color('year:N', legend=alt.Legend(title="Year")), - row=alt.Row( - 'site:N', - title="", - sort=alt.EncodingSortField(field='yield', op='sum', order='descending'), - ) + alt.X('yield:Q') + .title("Barley Yield (bushels/acre)") + .scale(zero=False) + .axis(grid=False), + alt.Y('variety:N') + .title("") + .sort('-x') + .axis(grid=True), + alt.Color('year:N') + .legend(title="Year"), + alt.Row('site:N') + .title("") + .sort(alt.EncodingSortField(field='yield', op='sum', order='descending')) ).properties( height=alt.Step(20) ).configure_view(stroke="transparent") diff --git a/altair/examples/beckers_barley_wrapped_facet.py b/altair/examples/beckers_barley_wrapped_facet.py index b67af69d4..1b36dfbc0 100644 --- a/altair/examples/beckers_barley_wrapped_facet.py +++ b/altair/examples/beckers_barley_wrapped_facet.py @@ -12,7 +12,7 @@ source = data.barley.url alt.Chart(source).mark_point().encode( - alt.X('median(yield):Q', scale=alt.Scale(zero=False)), + alt.X('median(yield):Q').scale(zero=False), y='variety:O', color='year:N', facet=alt.Facet('site:O', columns=2), diff --git a/altair/examples/bump_chart.py b/altair/examples/bump_chart.py index 1586b956e..20b407e68 100644 --- a/altair/examples/bump_chart.py +++ b/altair/examples/bump_chart.py @@ -14,8 +14,8 @@ stocks = data.stocks() source = stocks.groupby([pd.Grouper(key="date", freq="6M"),"symbol"]).mean().reset_index() -alt.Chart(source).mark_line(point = True).encode( - x = alt.X("date:O", timeUnit="yearmonth", title="date"), +alt.Chart(source).mark_line(point=True).encode( + x=alt.X("date:O", timeUnit="yearmonth").title("date"), y="rank:O", color=alt.Color("symbol:N") ).transform_window( @@ -26,4 +26,4 @@ title="Bump Chart for Stock Prices", width=600, height=150, -) \ No newline at end of file +) diff --git a/altair/examples/candlestick_chart.py b/altair/examples/candlestick_chart.py index 23b338b8e..47e713abb 100644 --- a/altair/examples/candlestick_chart.py +++ b/altair/examples/candlestick_chart.py @@ -12,27 +12,23 @@ source = data.ohlc() -open_close_color = alt.condition("datum.open <= datum.close", - alt.value("#06982d"), - alt.value("#ae1325")) +open_close_color = alt.condition( + "datum.open <= datum.close", + alt.value("#06982d"), + alt.value("#ae1325") +) base = alt.Chart(source).encode( - alt.X('date:T', - axis=alt.Axis( - format='%m/%d', - labelAngle=-45, - title='Date in 2009' - ) - ), + alt.X('date:T') + .axis(format='%m/%d', labelAngle=-45) + .title('Date in 2009'), color=open_close_color ) rule = base.mark_rule().encode( - alt.Y( - 'low:Q', - title='Price', - scale=alt.Scale(zero=False), - ), + alt.Y('low:Q') + .title('Price') + .scale(zero=False), alt.Y2('high:Q') ) @@ -41,4 +37,4 @@ alt.Y2('close:Q') ) -rule + bar \ No newline at end of file +rule + bar diff --git a/altair/examples/co2_concentration.py b/altair/examples/co2_concentration.py index cd53d4ed7..e82f830d6 100644 --- a/altair/examples/co2_concentration.py +++ b/altair/examples/co2_concentration.py @@ -27,25 +27,24 @@ groupby=['decade'], frame=[None, None] ).transform_calculate( - end="datum.first_date === datum.scaled_date ? 'first' : datum.last_date === datum.scaled_date ? 'last' : null" + end=( + "datum.first_date === datum.scaled_date ? 'first'" + ": datum.last_date === datum.scaled_date ? 'last'" + ": null" + ) ).encode( - x=alt.X( - "scaled_date:Q", - axis=alt.Axis(title="Year into Decade", tickCount=11) - ), - y=alt.Y( - "CO2:Q", - title="CO2 concentration in ppm", - scale=alt.Scale(zero=False) - ) + alt.X("scaled_date:Q") + .title("Year into Decade") + .axis(tickCount=11), + alt.Y("CO2:Q") + .title("CO2 concentration in ppm") + .scale(zero=False) ) line = base.mark_line().encode( - color=alt.Color( - "decade:O", - scale=alt.Scale(scheme="magma"), - legend=None - ) + alt.Color("decade:O") + .scale(scheme="magma") + .legend(None) ) text = base.encode(text="year:N") diff --git a/altair/examples/comet_chart.py b/altair/examples/comet_chart.py index 32dd9392c..b8edff751 100644 --- a/altair/examples/comet_chart.py +++ b/altair/examples/comet_chart.py @@ -11,22 +11,34 @@ import altair as alt import vega_datasets -( - alt.Chart(vega_datasets.data.barley.url) - .transform_pivot("year", value="yield", groupby=["variety", "site"]) - .transform_fold(["1931", "1932"], as_=["year", "yield"]) - .transform_calculate(calculate="datum['1932'] - datum['1931']", as_="delta") - .mark_trail() - .encode( - x=alt.X('year:O', title=None), - y=alt.Y('variety:N', title='Variety'), - size=alt.Size('yield:Q', scale=alt.Scale(range=[0, 12]), legend=alt.Legend(values=[20, 60], title='Barley Yield (bushels/acre)')), - color=alt.Color('delta:Q', scale=alt.Scale(domainMid=0), legend=alt.Legend(title='Yield Delta (%)')), - tooltip=alt.Tooltip(['year:O', 'yield:Q']), - column=alt.Column('site:N', title='Site') - - ) - .configure_view(stroke=None) - .configure_legend(orient='bottom', direction='horizontal') - .properties(title='Barley Yield comparison between 1932 and 1931') +alt.Chart( + vega_datasets.data.barley.url, + title='Barley Yield comparison between 1932 and 1931' +).mark_trail().encode( + alt.X('year:O').title(None), + alt.Y('variety:N').title('Variety'), + alt.Size('yield:Q') + .scale(range=[0, 12]) + .legend(values=[20, 60]) + .title('Barley Yield (bushels/acre)'), + alt.Color('delta:Q') + .scale(domainMid=0) + .title('Yield Delta (%)'), + alt.Tooltip(['year:O', 'yield:Q']), + alt.Column('site:N').title('Site') +).transform_pivot( + "year", + value="yield", + groupby=["variety", "site"] +).transform_fold( + ["1931", "1932"], + as_=["year", "yield"] +).transform_calculate( + calculate="datum['1932'] - datum['1931']", + as_="delta" +).configure_legend( + orient='bottom', + direction='horizontal' +).configure_view( + stroke=None ) diff --git a/altair/examples/connected_scatterplot.py b/altair/examples/connected_scatterplot.py index 8528fb86f..a5902841c 100644 --- a/altair/examples/connected_scatterplot.py +++ b/altair/examples/connected_scatterplot.py @@ -12,7 +12,7 @@ source = data.driving() alt.Chart(source).mark_line(point=True).encode( - alt.X('miles', scale=alt.Scale(zero=False)), - alt.Y('gas', scale=alt.Scale(zero=False)), + alt.X('miles').scale(zero=False), + alt.Y('gas').scale(zero=False), order='year' ) diff --git a/altair/examples/density_stack.py b/altair/examples/density_stack.py index e408e308d..56b0161f1 100644 --- a/altair/examples/density_stack.py +++ b/altair/examples/density_stack.py @@ -30,6 +30,6 @@ steps=200 ).mark_area().encode( alt.X('value:Q'), - alt.Y('density:Q', stack='zero'), + alt.Y('density:Q').stack('zero'), alt.Color('Measurement_type:N') ).properties(width=400, height=100) diff --git a/altair/examples/diverging_stacked_bar_chart.py b/altair/examples/diverging_stacked_bar_chart.py index cb2c21832..19ddc1d13 100644 --- a/altair/examples/diverging_stacked_bar_chart.py +++ b/altair/examples/diverging_stacked_bar_chart.py @@ -358,10 +358,6 @@ alt.Chart(source).mark_bar().encode( x='percentage_start:Q', x2='percentage_end:Q', - y=alt.Y('question:N', axis=y_axis), - color=alt.Color( - 'type:N', - legend=alt.Legend( title='Response'), - scale=color_scale, - ) + y=alt.Y('question:N').axis(y_axis), + color=alt.Color('type:N').title('Response').scale(color_scale), ) diff --git a/altair/examples/donut_chart.py b/altair/examples/donut_chart.py index 32498a56d..a734825da 100644 --- a/altair/examples/donut_chart.py +++ b/altair/examples/donut_chart.py @@ -10,9 +10,12 @@ import pandas as pd import altair as alt -source = pd.DataFrame({"category": [1, 2, 3, 4, 5, 6], "value": [4, 6, 10, 3, 7, 8]}) +source = pd.DataFrame({ + "category": [1, 2, 3, 4, 5, 6], + "value": [4, 6, 10, 3, 7, 8] +}) alt.Chart(source).mark_arc(innerRadius=50).encode( - theta=alt.Theta(field="value", type="quantitative"), - color=alt.Color(field="category", type="nominal"), + theta="value", + color="category:N", ) diff --git a/altair/examples/dot_dash_plot.py b/altair/examples/dot_dash_plot.py index 52f805adc..58ade5962 100644 --- a/altair/examples/dot_dash_plot.py +++ b/altair/examples/dot_dash_plot.py @@ -16,8 +16,8 @@ # Configure the points points = base.mark_point().encode( - x=alt.X('Miles_per_Gallon', title=''), - y=alt.Y('Horsepower', title=''), + alt.X('Miles_per_Gallon').title(''), + alt.Y('Horsepower').title(''), color=alt.condition(brush, 'Origin', alt.value('grey')) ) @@ -25,14 +25,14 @@ tick_axis = alt.Axis(labels=False, domain=False, ticks=False) x_ticks = base.mark_tick().encode( - alt.X('Miles_per_Gallon', axis=tick_axis), - alt.Y('Origin', title='', axis=tick_axis), + alt.X('Miles_per_Gallon').axis(tick_axis), + alt.Y('Origin').title('').axis(tick_axis), color=alt.condition(brush, 'Origin', alt.value('lightgrey')) ) y_ticks = base.mark_tick().encode( - alt.X('Origin', title='', axis=tick_axis), - alt.Y('Horsepower', axis=tick_axis), + alt.X('Origin').title('').axis(tick_axis), + alt.Y('Horsepower').axis(tick_axis), color=alt.condition(brush, 'Origin', alt.value('lightgrey')) ) diff --git a/altair/examples/streamgraph.py b/altair/examples/streamgraph.py index 64b8e4176..b9bdcb512 100644 --- a/altair/examples/streamgraph.py +++ b/altair/examples/streamgraph.py @@ -10,11 +10,7 @@ source = data.unemployment_across_industries.url alt.Chart(source).mark_area().encode( - alt.X('yearmonth(date):T', - axis=alt.Axis(format='%Y', domain=False, tickSize=0) - ), - alt.Y('sum(count):Q', stack='center', axis=None), - alt.Color('series:N', - scale=alt.Scale(scheme='category20b') - ) + alt.X('yearmonth(date):T').axis(format='%Y', domain=False, tickSize=0), + alt.Y('sum(count):Q').stack('center').axis(None), + alt.Color('series:N').scale(scheme='category20b') ).interactive() From c33b093d7373a552eb8fff765f55ca31ff054e57 Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Sun, 4 Dec 2022 20:46:22 -0800 Subject: [PATCH 08/26] Add test for method based attr setting --- altair/vegalite/v5/tests/test_api.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/altair/vegalite/v5/tests/test_api.py b/altair/vegalite/v5/tests/test_api.py index cfb42fe07..b068bc079 100644 --- a/altair/vegalite/v5/tests/test_api.py +++ b/altair/vegalite/v5/tests/test_api.py @@ -964,3 +964,18 @@ def test_validate_dataset(): jsn = chart.to_json() assert jsn + + +def test_method_based_attr_setting(): + x1 = alt.X(field="foo") + x2 = alt.X().field("foo") + x3 = alt.X() + x3.field = "foo" + assert x1 == x2 == x3 + assert x1["field"] == x2["field"] == x3["field"] + + x1["field"] = "bah" + x2 = x2.field("bah") + x3.field = "bah" + assert x1 == x2 == x3 + assert x1.field != x1["field"] From 34d83f5795b2a417676d14d3d5d8ad67fcbbc29e Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Sun, 4 Dec 2022 21:02:15 -0800 Subject: [PATCH 09/26] Convert timeunit param to method --- altair/examples/bump_chart.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/altair/examples/bump_chart.py b/altair/examples/bump_chart.py index 20b407e68..03f88c8ac 100644 --- a/altair/examples/bump_chart.py +++ b/altair/examples/bump_chart.py @@ -15,7 +15,7 @@ source = stocks.groupby([pd.Grouper(key="date", freq="6M"),"symbol"]).mean().reset_index() alt.Chart(source).mark_line(point=True).encode( - x=alt.X("date:O", timeUnit="yearmonth").title("date"), + x=alt.X("date:O").timeUnit("yearmonth").title("date"), y="rank:O", color=alt.Color("symbol:N") ).transform_window( From adddf46af5f3018e0681c4e5d2e33d4e5a3c3a9c Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Sun, 4 Dec 2022 21:32:46 -0800 Subject: [PATCH 10/26] Convert a few additional gallery examples --- altair/examples/errorbars_with_ci.py | 8 ++++---- altair/examples/errorbars_with_std.py | 8 ++++---- altair/examples/falkensee.py | 6 +++--- altair/examples/gapminder_bubble_plot.py | 4 ++-- altair/examples/groupby-map.py | 6 ++---- altair/examples/grouped_bar_chart2.py | 8 +++++--- altair/examples/grouped_bar_chart_with_error_bars.py | 2 +- altair/examples/hexbins.py | 12 +++++++----- altair/examples/histogram_heatmap.py | 6 +++--- altair/examples/histogram_responsive.py | 9 ++++----- altair/examples/histogram_scatterplot.py | 4 ++-- .../examples/histogram_with_a_global_mean_overlay.py | 2 +- altair/examples/horizon_graph.py | 10 +++++----- 13 files changed, 43 insertions(+), 42 deletions(-) diff --git a/altair/examples/errorbars_with_ci.py b/altair/examples/errorbars_with_ci.py index 55c706ecc..af950a45e 100644 --- a/altair/examples/errorbars_with_ci.py +++ b/altair/examples/errorbars_with_ci.py @@ -12,13 +12,13 @@ source = data.barley() error_bars = alt.Chart(source).mark_errorbar(extent='ci').encode( - x=alt.X('yield:Q', scale=alt.Scale(zero=False)), - y=alt.Y('variety:N') + alt.X('yield').scale(zero=False), + alt.Y('variety') ) points = alt.Chart(source).mark_point(filled=True, color='black').encode( - x=alt.X('yield:Q', aggregate='mean'), - y=alt.Y('variety:N'), + x=alt.X('mean(yield)'), + y=alt.Y('variety'), ) error_bars + points diff --git a/altair/examples/errorbars_with_std.py b/altair/examples/errorbars_with_std.py index 167bc7283..d20c154b9 100644 --- a/altair/examples/errorbars_with_std.py +++ b/altair/examples/errorbars_with_std.py @@ -11,13 +11,13 @@ source = data.barley() error_bars = alt.Chart(source).mark_errorbar(extent='stdev').encode( - x=alt.X('yield:Q', scale=alt.Scale(zero=False)), - y=alt.Y('variety:N') + x=alt.X('yield').scale(zero=False), + y=alt.Y('variety') ) points = alt.Chart(source).mark_point(filled=True, color='black').encode( - x=alt.X('yield:Q', aggregate='mean'), - y=alt.Y('variety:N'), + x=alt.X('mean(yield)'), + y=alt.Y('variety'), ) error_bars + points diff --git a/altair/examples/falkensee.py b/altair/examples/falkensee.py index 463e70ada..b5d01b86e 100644 --- a/altair/examples/falkensee.py +++ b/altair/examples/falkensee.py @@ -58,8 +58,8 @@ line = alt.Chart(source).mark_line(color="#333").encode( - x=alt.X("year:T", axis=alt.Axis(format="%Y"), title="Year"), - y=alt.Y("population", title="Population"), + alt.X("year:T").axis(format="%Y").title("Year"), + alt.Y("population").title("Population"), ) point = line.mark_point(color="#333") @@ -67,7 +67,7 @@ rect = alt.Chart(source2).mark_rect().encode( x="start:T", x2="end:T", - color=alt.Color("event:N", title="Event") + color=alt.Color("event:N").title("Event") ) (rect + line + point).properties( diff --git a/altair/examples/gapminder_bubble_plot.py b/altair/examples/gapminder_bubble_plot.py index 381f81017..839212885 100644 --- a/altair/examples/gapminder_bubble_plot.py +++ b/altair/examples/gapminder_bubble_plot.py @@ -12,7 +12,7 @@ source = data.gapminder_health_income.url alt.Chart(source).mark_circle().encode( - alt.X('income:Q', scale=alt.Scale(type='log')), - alt.Y('health:Q', scale=alt.Scale(zero=False)), + alt.X('income:Q').scale(type='log'), + alt.Y('health:Q').scale(zero=False), size='population:Q' ) diff --git a/altair/examples/groupby-map.py b/altair/examples/groupby-map.py index adb4e0256..20f0817e6 100644 --- a/altair/examples/groupby-map.py +++ b/altair/examples/groupby-map.py @@ -20,7 +20,7 @@ ).project('albersUsa') # Airports grouped by state -points = alt.Chart(airports).transform_aggregate( +points = alt.Chart(airports, title='Number of airports in US').transform_aggregate( latitude='mean(latitude)', longitude='mean(longitude)', count='count()', @@ -28,11 +28,9 @@ ).mark_circle().encode( longitude='longitude:Q', latitude='latitude:Q', - size=alt.Size('count:Q', title='Number of Airports'), + size=alt.Size('count:Q').title('Number of Airports'), color=alt.value('steelblue'), tooltip=['state:N','count:Q'] -).properties( - title='Number of airports in US' ) background + points diff --git a/altair/examples/grouped_bar_chart2.py b/altair/examples/grouped_bar_chart2.py index 74e955113..671f83e44 100644 --- a/altair/examples/grouped_bar_chart2.py +++ b/altair/examples/grouped_bar_chart2.py @@ -8,9 +8,11 @@ import altair as alt import pandas as pd -source = pd.DataFrame({"Category":list("AAABBBCCC"), - "Group":list("xyzxyzxyz"), - "Value":[0.1, 0.6, 0.9, 0.7, 0.2, 1.1, 0.6, 0.1, 0.2]}) +source = pd.DataFrame({ + "Category":list("AAABBBCCC"), + "Group":list("xyzxyzxyz"), + "Value":[0.1, 0.6, 0.9, 0.7, 0.2, 1.1, 0.6, 0.1, 0.2] +}) alt.Chart(source).mark_bar().encode( x="Category:N", diff --git a/altair/examples/grouped_bar_chart_with_error_bars.py b/altair/examples/grouped_bar_chart_with_error_bars.py index c1eab965d..4ef796f12 100644 --- a/altair/examples/grouped_bar_chart_with_error_bars.py +++ b/altair/examples/grouped_bar_chart_with_error_bars.py @@ -11,7 +11,7 @@ bars = alt.Chart().mark_bar().encode( x='year:O', - y=alt.Y('mean(yield):Q', title='Mean Yield'), + y=alt.Y('mean(yield):Q').title('Mean Yield'), color='year:N', ) diff --git a/altair/examples/hexbins.py b/altair/examples/hexbins.py index a8d91ac74..26f3890a0 100644 --- a/altair/examples/hexbins.py +++ b/altair/examples/hexbins.py @@ -24,13 +24,15 @@ hexagon = "M0,-2.3094010768L2,-1.1547005384 2,1.1547005384 0,2.3094010768 -2,1.1547005384 -2,-1.1547005384Z" alt.Chart(source).mark_point(size=size**2, shape=hexagon).encode( - x=alt.X('xFeaturePos:Q', axis=alt.Axis(title='Month', - grid=False, tickOpacity=0, domainOpacity=0)), - y=alt.Y('day(' + yField + '):O', axis=alt.Axis(title='Weekday', - labelPadding=20, tickOpacity=0, domainOpacity=0)), + alt.X('xFeaturePos:Q') + .title('Month') + .axis(grid=False, tickOpacity=0, domainOpacity=0), + alt.Y('day(' + yField + '):O') + .title('Weekday') + .axis(labelPadding=20, tickOpacity=0, domainOpacity=0), stroke=alt.value('black'), strokeWidth=alt.value(0.2), - fill=alt.Color('mean(temp_max):Q', scale=alt.Scale(scheme='darkblue')), + fill=alt.Color('mean(temp_max):Q').scale(scheme='darkblue'), tooltip=['month(' + xField + '):O', 'day(' + yField + '):O', 'mean(temp_max):Q'] ).transform_calculate( # This field is required for the hexagonal X-Offset diff --git a/altair/examples/histogram_heatmap.py b/altair/examples/histogram_heatmap.py index e284449f3..c697d1dd7 100644 --- a/altair/examples/histogram_heatmap.py +++ b/altair/examples/histogram_heatmap.py @@ -10,7 +10,7 @@ source = data.movies.url alt.Chart(source).mark_rect().encode( - alt.X('IMDB_Rating:Q', bin=alt.Bin(maxbins=60)), - alt.Y('Rotten_Tomatoes_Rating:Q', bin=alt.Bin(maxbins=40)), - alt.Color('count():Q', scale=alt.Scale(scheme='greenblue')) + alt.X('IMDB_Rating:Q').bin(maxbins=60), + alt.Y('Rotten_Tomatoes_Rating:Q').bin(maxbins=40), + alt.Color('count():Q').scale(scheme='greenblue') ) diff --git a/altair/examples/histogram_responsive.py b/altair/examples/histogram_responsive.py index 8e3cfdc48..e8ce16cb6 100644 --- a/altair/examples/histogram_responsive.py +++ b/altair/examples/histogram_responsive.py @@ -24,12 +24,11 @@ alt.vconcat( base.encode( - alt.X('time:Q', - bin=alt.Bin(maxbins=30, extent=brush), - scale=alt.Scale(domain=brush) - ) + alt.X('time:Q') + .bin(maxbins=30, extent=brush) + .scale(domain=brush) ), base.encode( - alt.X('time:Q', bin=alt.Bin(maxbins=30)), + alt.X('time:Q').bin(maxbins=30), ).add_params(brush) ) diff --git a/altair/examples/histogram_scatterplot.py b/altair/examples/histogram_scatterplot.py index 482eee760..6286b615e 100644 --- a/altair/examples/histogram_scatterplot.py +++ b/altair/examples/histogram_scatterplot.py @@ -10,7 +10,7 @@ source = data.movies.url alt.Chart(source).mark_circle().encode( - alt.X('IMDB_Rating:Q', bin=True), - alt.Y('Rotten_Tomatoes_Rating:Q', bin=True), + alt.X('IMDB_Rating:Q').bin(), + alt.Y('Rotten_Tomatoes_Rating:Q').bin(), size='count()' ) diff --git a/altair/examples/histogram_with_a_global_mean_overlay.py b/altair/examples/histogram_with_a_global_mean_overlay.py index f2cc9a390..bcb91a216 100644 --- a/altair/examples/histogram_with_a_global_mean_overlay.py +++ b/altair/examples/histogram_with_a_global_mean_overlay.py @@ -12,7 +12,7 @@ base = alt.Chart(source) bar = base.mark_bar().encode( - x=alt.X('IMDB_Rating:Q', bin=True, axis=None), + alt.X('IMDB_Rating:Q').bin().axis(None), y='count()' ) diff --git a/altair/examples/horizon_graph.py b/altair/examples/horizon_graph.py index 833595789..d2f534a73 100644 --- a/altair/examples/horizon_graph.py +++ b/altair/examples/horizon_graph.py @@ -22,18 +22,18 @@ area1 = alt.Chart(source).mark_area( clip=True, - interpolate='monotone' + interpolate='monotone', + opacity=0.6 ).encode( - alt.X('x', scale=alt.Scale(zero=False, nice=False)), - alt.Y('y', scale=alt.Scale(domain=[0, 50]), title='y'), - opacity=alt.value(0.6) + alt.X('x').scale(zero=False, nice=False), + alt.Y('y').scale(domain=[0, 50]).title('y'), ).properties( width=500, height=75 ) area2 = area1.encode( - alt.Y('ny:Q', scale=alt.Scale(domain=[0, 50])) + alt.Y('ny:Q').scale(domain=[0, 50]) ).transform_calculate( "ny", alt.datum.y - 50 ) From 7db01fcdaf8df72d6d4396b8276b48e168c3fade Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Mon, 5 Dec 2022 08:58:32 -0800 Subject: [PATCH 11/26] Convert a few additional gallery examples --- altair/examples/interactive_cross_highlight.py | 18 +++++------------- .../interactive_layered_crossfilter.py | 7 ++----- altair/examples/interactive_legend.py | 6 +++--- altair/vegalite/v5/schema/channels.py | 1 + tools/generate_schema_wrapper.py | 2 +- 5 files changed, 12 insertions(+), 22 deletions(-) diff --git a/altair/examples/interactive_cross_highlight.py b/altair/examples/interactive_cross_highlight.py index a167c0d20..f862cb973 100644 --- a/altair/examples/interactive_cross_highlight.py +++ b/altair/examples/interactive_cross_highlight.py @@ -14,30 +14,22 @@ pts = alt.selection(type="point", encodings=['x']) rect = alt.Chart(data.movies.url).mark_rect().encode( - alt.X('IMDB_Rating:Q', bin=True), - alt.Y('Rotten_Tomatoes_Rating:Q', bin=True), - alt.Color('count()', - scale=alt.Scale(scheme='greenblue'), - legend=alt.Legend(title='Total Records') - ) + alt.X('IMDB_Rating:Q').bin(), + alt.Y('Rotten_Tomatoes_Rating:Q').bin(), + alt.Color('count()').scale(scheme='greenblue').title('Total Records') ) circ = rect.mark_point().encode( alt.ColorValue('grey'), - alt.Size('count()', - legend=alt.Legend(title='Records in Selection') - ) + alt.Size('count()').title('Records in Selection') ).transform_filter( pts ) -bar = alt.Chart(source).mark_bar().encode( +bar = alt.Chart(source, width=550, height=200).mark_bar().encode( x='Major_Genre:N', y='count()', color=alt.condition(pts, alt.ColorValue("steelblue"), alt.ColorValue("grey")) -).properties( - width=550, - height=200 ).add_params(pts) alt.vconcat( diff --git a/altair/examples/interactive_layered_crossfilter.py b/altair/examples/interactive_layered_crossfilter.py index 6a945b22d..831365996 100644 --- a/altair/examples/interactive_layered_crossfilter.py +++ b/altair/examples/interactive_layered_crossfilter.py @@ -18,12 +18,9 @@ # Define the base chart, with the common parts of the # background and highlights -base = alt.Chart().mark_bar().encode( - x=alt.X(alt.repeat('column'), type='quantitative', bin=alt.Bin(maxbins=20)), +base = alt.Chart(width=160, height=130).mark_bar().encode( + x=alt.X(alt.repeat('column')).bin(maxbins=20), y='count()' -).properties( - width=160, - height=130 ) # gray background with selection diff --git a/altair/examples/interactive_legend.py b/altair/examples/interactive_legend.py index bd8b14b1a..80c47cf11 100644 --- a/altair/examples/interactive_legend.py +++ b/altair/examples/interactive_legend.py @@ -14,9 +14,9 @@ selection = alt.selection_point(fields=['series'], bind='legend') alt.Chart(source).mark_area().encode( - alt.X('yearmonth(date):T', axis=alt.Axis(domain=False, format='%Y', tickSize=0)), - alt.Y('sum(count):Q', stack='center', axis=None), - alt.Color('series:N', scale=alt.Scale(scheme='category20b')), + alt.X('yearmonth(date):T').axis(domain=False, format='%Y', tickSize=0), + alt.Y('sum(count):Q').stack('center').axis(None), + alt.Color('series:N').scale(scheme='category20b'), opacity=alt.condition(selection, alt.value(1), alt.value(0.2)) ).add_params( selection diff --git a/altair/vegalite/v5/schema/channels.py b/altair/vegalite/v5/schema/channels.py index 34bb21ab3..f9152c16b 100644 --- a/altair/vegalite/v5/schema/channels.py +++ b/altair/vegalite/v5/schema/channels.py @@ -90,6 +90,7 @@ def to_dict(self, validate=True, ignore=(), context=None): ignore=ignore, context=context) + @with_property_setters class Angle(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDefnumber): """Angle schema wrapper diff --git a/tools/generate_schema_wrapper.py b/tools/generate_schema_wrapper.py index 29207934b..2b768d2c7 100644 --- a/tools/generate_schema_wrapper.py +++ b/tools/generate_schema_wrapper.py @@ -5,7 +5,7 @@ import sys import json import re -from os.path import abspath, join, dirname +from os.path import abspath, join, dirname, pardir import textwrap from urllib import request From 8992c96120b21ad532d9848b1a8e5acbb7a91102 Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Mon, 5 Dec 2022 09:00:28 -0800 Subject: [PATCH 12/26] Update relative imports syntax --- altair/utils/schemapi.py | 2 +- tools/schemapi/schemapi.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/altair/utils/schemapi.py b/altair/utils/schemapi.py index 5daeebc1d..733f799fe 100644 --- a/altair/utils/schemapi.py +++ b/altair/utils/schemapi.py @@ -11,7 +11,7 @@ import numpy as np import pandas as pd -from .. import vegalite +from altair import vegalite # If DEBUG_MODE is True, then schema objects are converted to dict and diff --git a/tools/schemapi/schemapi.py b/tools/schemapi/schemapi.py index 5faceec78..f05567da6 100644 --- a/tools/schemapi/schemapi.py +++ b/tools/schemapi/schemapi.py @@ -9,7 +9,7 @@ import numpy as np import pandas as pd -from ..altair import vegalite +from altair import vegalite # If DEBUG_MODE is True, then schema objects are converted to dict and From 93640d430f27e9bd9c14765dce544db10fd2833e Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Mon, 5 Dec 2022 09:10:56 -0800 Subject: [PATCH 13/26] Remove unused import --- tools/generate_schema_wrapper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/generate_schema_wrapper.py b/tools/generate_schema_wrapper.py index 2b768d2c7..29207934b 100644 --- a/tools/generate_schema_wrapper.py +++ b/tools/generate_schema_wrapper.py @@ -5,7 +5,7 @@ import sys import json import re -from os.path import abspath, join, dirname, pardir +from os.path import abspath, join, dirname import textwrap from urllib import request From 734f003eea6d8f9caefd485de66fd91e5c2aa5ad Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Mon, 5 Dec 2022 09:15:46 -0800 Subject: [PATCH 14/26] Only generate new schema for the latest version of vega lite to avoid backported changes that we do not test on older versions --- tools/generate_schema_wrapper.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/generate_schema_wrapper.py b/tools/generate_schema_wrapper.py index 29207934b..df6e93444 100644 --- a/tools/generate_schema_wrapper.py +++ b/tools/generate_schema_wrapper.py @@ -26,8 +26,10 @@ # Map of version name to github branch name. SCHEMA_VERSION = { + # Uncomment old vega-lite versions here when there are breaking changing + # that we don't want to backport "vega": {"v5": "v5.21.0"}, - "vega-lite": {"v3": "v3.4.0", "v4": "v4.17.0", "v5": "v5.2.0"}, + "vega-lite": {"v5": "v5.2.0"}, } reLink = re.compile(r"(?<=\[)([^\]]+)(?=\]\([^\)]+\))", re.M) From f323915f99a390e9f28b9f05194b7e9542be8202 Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Wed, 7 Dec 2022 09:08:03 -0800 Subject: [PATCH 15/26] Add another set of gallery examples --- altair/examples/interval_selection.py | 7 ++----- altair/examples/iowa_electricity.py | 20 ++++++------------- altair/examples/isotype.py | 15 ++++++++------ altair/examples/isotype_emoji.py | 11 ++++++---- altair/examples/isotype_grid.py | 6 +++--- altair/examples/lasagna_plot.py | 12 +++++------ altair/examples/layered_area_chart.py | 2 +- altair/examples/layered_bar_chart.py | 2 +- .../examples/layered_chart_with_dual_axis.py | 10 ++++------ altair/examples/layered_heatmap_text.py | 9 ++++----- altair/examples/layered_histogram.py | 4 ++-- .../examples/line_chart_with_color_datum.py | 14 +++++++------ altair/examples/line_chart_with_cumsum.py | 4 ++-- .../examples/line_chart_with_custom_legend.py | 10 +++++----- altair/examples/line_percent.py | 4 ++-- altair/examples/line_with_ci.py | 2 +- ...abeled => line_with_last_value_labeled.py} | 6 +++--- altair/examples/line_with_log_scale.py | 7 ++----- altair/examples/london_tube.py | 18 +++++------------ 19 files changed, 72 insertions(+), 91 deletions(-) rename altair/examples/{line_with_last_value_labeled => line_with_last_value_labeled.py} (86%) diff --git a/altair/examples/interval_selection.py b/altair/examples/interval_selection.py index 509c200b8..f0aa303e9 100644 --- a/altair/examples/interval_selection.py +++ b/altair/examples/interval_selection.py @@ -13,16 +13,13 @@ brush = alt.selection(type='interval', encodings=['x']) -base = alt.Chart(source).mark_area().encode( +base = alt.Chart(source, width=600, height=200).mark_area().encode( x = 'date:T', y = 'price:Q' -).properties( - width=600, - height=200 ) upper = base.encode( - alt.X('date:T', scale=alt.Scale(domain=brush)) + alt.X('date:T').scale(domain=brush) ) lower = base.properties( diff --git a/altair/examples/iowa_electricity.py b/altair/examples/iowa_electricity.py index 0f2081d99..252cb0423 100644 --- a/altair/examples/iowa_electricity.py +++ b/altair/examples/iowa_electricity.py @@ -10,18 +10,10 @@ source = data.iowa_electricity() alt.Chart(source, title="Iowa's renewable energy boom").mark_area().encode( - x=alt.X( - "year:T", - title="Year" - ), - y=alt.Y( - "net_generation:Q", - stack="normalize", - title="Share of net generation", - axis=alt.Axis(format=".0%"), - ), - color=alt.Color( - "source:N", - legend=alt.Legend(title="Electricity source"), - ) + alt.X("year:T").title("Year"), + alt.Y("net_generation:Q") + .title("Share of net generation") + .stack("normalize") + .axis(format=".0%"), + alt.Color("source:N").title("Electricity source") ) diff --git a/altair/examples/isotype.py b/altair/examples/isotype.py index 23da6f4b3..92850b729 100644 --- a/altair/examples/isotype.py +++ b/altair/examples/isotype.py @@ -67,12 +67,15 @@ ) alt.Chart(source).mark_point(filled=True, opacity=1, size=100).encode( - alt.X('x:O', axis=None), - alt.Y('animal:O', axis=None), - alt.Row('country:N', header=alt.Header(title='')), - alt.Shape('animal:N', legend=None, scale=shape_scale), - alt.Color('animal:N', legend=None, scale=color_scale), + alt.X('x:O').axis(None), + alt.Y('animal:O').axis(None), + alt.Row('country:N').header(title=''), + alt.Shape('animal:N').legend(None).scale(shape_scale), + alt.Color('animal:N').legend(None).scale(color_scale), ).transform_window( x='rank()', groupby=['country', 'animal'] -).properties(width=550, height=140) +).properties( + width=550, + height=140 +) diff --git a/altair/examples/isotype_emoji.py b/altair/examples/isotype_emoji.py index 92ab0f3ef..313af8e82 100644 --- a/altair/examples/isotype_emoji.py +++ b/altair/examples/isotype_emoji.py @@ -51,13 +51,16 @@ alt.Chart(source).mark_text(size=45, baseline='middle').encode( - alt.X('x:O', axis=None), - alt.Y('animal:O', axis=None), - alt.Row('country:N', header=alt.Header(title='')), + alt.X('x:O').axis(None), + alt.Y('animal:O').axis(None), + alt.Row('country:N').title(''), alt.Text('emoji:N') ).transform_calculate( emoji="{'cattle': '🐄', 'pigs': '🐖', 'sheep': '🐏'}[datum.animal]" ).transform_window( x='rank()', groupby=['country', 'animal'] -).properties(width=550, height=140) +).properties( + width=550, + height=140 +) diff --git a/altair/examples/isotype_grid.py b/altair/examples/isotype_grid.py index f90e9e8a8..d0a9b6d4b 100644 --- a/altair/examples/isotype_grid.py +++ b/altair/examples/isotype_grid.py @@ -27,9 +27,9 @@ filled=True, size=50 ).encode( - x=alt.X("col:O", axis=None), - y=alt.Y("row:O", axis=None), - shape=alt.ShapeValue(person) + alt.X("col:O").axis(None), + alt.Y("row:O").axis(None), + alt.ShapeValue(person) ).properties( width=400, height=400 diff --git a/altair/examples/lasagna_plot.py b/altair/examples/lasagna_plot.py index 6f603b8e1..0da7c44fd 100644 --- a/altair/examples/lasagna_plot.py +++ b/altair/examples/lasagna_plot.py @@ -17,17 +17,15 @@ alt.Chart(source, width=300, height=100).transform_filter( alt.datum.symbol != "GOOG" ).mark_rect().encode( - x=alt.X( - "yearmonthdate(date):O", - axis=alt.Axis( + alt.X("yearmonthdate(date):O") + .title("Time") + .axis( format="%Y", labelAngle=0, labelOverlap=False, labelColor=color_condition, tickColor=color_condition, ), - title="Time", - ), - y=alt.Y("symbol:N", title=None), - color=alt.Color("sum(price)", title="Price"), + alt.Y("symbol:N").title(None), + alt.Color("sum(price)").title("Price") ) diff --git a/altair/examples/layered_area_chart.py b/altair/examples/layered_area_chart.py index fe9e42c2c..83eb51b75 100644 --- a/altair/examples/layered_area_chart.py +++ b/altair/examples/layered_area_chart.py @@ -11,6 +11,6 @@ alt.Chart(source).mark_area(opacity=0.3).encode( x="year:T", - y=alt.Y("net_generation:Q", stack=None), + y=alt.Y("net_generation:Q").stack(None), color="source:N" ) diff --git a/altair/examples/layered_bar_chart.py b/altair/examples/layered_bar_chart.py index 48d221e3b..ba485fea7 100644 --- a/altair/examples/layered_bar_chart.py +++ b/altair/examples/layered_bar_chart.py @@ -11,6 +11,6 @@ alt.Chart(source).mark_bar(opacity=0.7).encode( x='year:O', - y=alt.Y('net_generation:Q', stack=None), + y=alt.Y('net_generation:Q').stack(None), color="source", ) diff --git a/altair/examples/layered_chart_with_dual_axis.py b/altair/examples/layered_chart_with_dual_axis.py index 8ef8f099b..d14fbca57 100644 --- a/altair/examples/layered_chart_with_dual_axis.py +++ b/altair/examples/layered_chart_with_dual_axis.py @@ -11,20 +11,18 @@ source = data.seattle_weather() base = alt.Chart(source).encode( - alt.X('month(date):T', axis=alt.Axis(title=None)) + alt.X('month(date):T').axis(title=None) ) area = base.mark_area(opacity=0.3, color='#57A44C').encode( - alt.Y('average(temp_max)', - axis=alt.Axis(title='Avg. Temperature (°C)', titleColor='#57A44C')), + alt.Y('average(temp_max)').title('Avg. Temperature (°C)', titleColor='#57A44C'), alt.Y2('average(temp_min)') ) line = base.mark_line(stroke='#5276A7', interpolate='monotone').encode( - alt.Y('average(precipitation)', - axis=alt.Axis(title='Precipitation (inches)', titleColor='#5276A7')) + alt.Y('average(precipitation)').title('Precipitation (inches)', titleColor='#5276A7') ) alt.layer(area, line).resolve_scale( - y = 'independent' + y='independent' ) diff --git a/altair/examples/layered_heatmap_text.py b/altair/examples/layered_heatmap_text.py index dc912ed8b..7a61c08cb 100644 --- a/altair/examples/layered_heatmap_text.py +++ b/altair/examples/layered_heatmap_text.py @@ -22,15 +22,14 @@ # Configure heatmap heatmap = base.mark_rect().encode( - color=alt.Color('mean_horsepower:Q', - scale=alt.Scale(scheme='viridis'), - legend=alt.Legend(title="Mean of Horsepower"), - ) + alt.Color('mean_horsepower:Q') + .scale(scheme='viridis') + .title("Mean of Horsepower") ) # Configure text text = base.mark_text(baseline='middle').encode( - text=alt.Text('mean_horsepower:Q', format=".0f"), + alt.Text('mean_horsepower:Q', format=".0f"), color=alt.condition( alt.datum.mean_horsepower > 150, alt.value('black'), diff --git a/altair/examples/layered_histogram.py b/altair/examples/layered_histogram.py index f1af32625..62c7dccf6 100644 --- a/altair/examples/layered_histogram.py +++ b/altair/examples/layered_histogram.py @@ -23,7 +23,7 @@ opacity=0.3, binSpacing=0 ).encode( - alt.X('Measurement:Q', bin=alt.Bin(maxbins=100)), - alt.Y('count()', stack=None), + alt.X('Measurement:Q').bin(maxbins=100), + alt.Y('count()').stack(None), alt.Color('Experiment:N') ) diff --git a/altair/examples/line_chart_with_color_datum.py b/altair/examples/line_chart_with_color_datum.py index 17d3a1cec..77cad9574 100644 --- a/altair/examples/line_chart_with_color_datum.py +++ b/altair/examples/line_chart_with_color_datum.py @@ -1,7 +1,7 @@ """ Line Chart with Datum for Color ------------------------------- -An example of using ``datum`` and ``repeat`` to color a multi-series line chart. +An example of using ``repeat`` inside ``datum`` to color a multi-series line chart. This is adapted from this corresponding Vega-Lite Example: `Repeat and Layer to Show Different Movie Measures `_. """ @@ -13,9 +13,11 @@ source = data.movies() alt.Chart(source).mark_line().encode( - x=alt.X("IMDB_Rating", bin=True), - y=alt.Y( - alt.repeat("layer"), aggregate="mean", title="Mean of US and Worldwide Gross" - ), + alt.X("IMDB_Rating").bin(True), + alt.Y(alt.repeat("layer")) + .aggregate("mean") + .title("Mean of US and Worldwide Gross"), color=alt.datum(alt.repeat("layer")), -).repeat(layer=["US_Gross", "Worldwide_Gross"]) +).repeat( + layer=["US_Gross", "Worldwide_Gross"] +) diff --git a/altair/examples/line_chart_with_cumsum.py b/altair/examples/line_chart_with_cumsum.py index 2b21b0845..ef3144fe1 100644 --- a/altair/examples/line_chart_with_cumsum.py +++ b/altair/examples/line_chart_with_cumsum.py @@ -9,7 +9,7 @@ source = data.wheat() -alt.Chart(source).mark_line().transform_window( +alt.Chart(source, width=600).mark_line().transform_window( # Sort the data chronologically sort=[{'field': 'year'}], # Include all previous records before the current record and none after @@ -21,4 +21,4 @@ x='year:O', # Plot the calculated field created by the transformation y='cumulative_wheat:Q' -).properties(width=600) \ No newline at end of file +) diff --git a/altair/examples/line_chart_with_custom_legend.py b/altair/examples/line_chart_with_custom_legend.py index 992128232..2ee60088e 100644 --- a/altair/examples/line_chart_with_custom_legend.py +++ b/altair/examples/line_chart_with_custom_legend.py @@ -12,7 +12,7 @@ source = data.stocks() base = alt.Chart(source).encode( - color=alt.Color("symbol", legend=None) + alt.Color("symbol").legend(None) ).transform_filter( "datum.symbol !== 'IBM'" ).properties( @@ -23,8 +23,8 @@ last_price = base.mark_circle().encode( - x=alt.X("last_date['date']:T"), - y=alt.Y("last_date['price']:Q") + alt.X("last_date['date']:T"), + alt.Y("last_date['price']:Q") ).transform_aggregate( last_date="argmax(date)", groupby=["symbol"] @@ -33,8 +33,8 @@ company_name = last_price.mark_text(align="left", dx=4).encode(text="symbol") chart = (line + last_price + company_name).encode( - x=alt.X(title="date"), - y=alt.Y(title="price") + x=alt.X().title("date"), + y=alt.Y().title("price") ) chart diff --git a/altair/examples/line_percent.py b/altair/examples/line_percent.py index fd23572de..52e047034 100644 --- a/altair/examples/line_percent.py +++ b/altair/examples/line_percent.py @@ -11,8 +11,8 @@ alt.Chart(source).mark_line().encode( alt.X('year:O'), - alt.Y('perc:Q', axis=alt.Axis(format='%')), - color='sex:N' + alt.Y('perc:Q').axis(format='%'), + alt.Color('sex:N') ).transform_filter( alt.datum.job == 'Welder' ) diff --git a/altair/examples/line_with_ci.py b/altair/examples/line_with_ci.py index 5db97915a..744f453d0 100644 --- a/altair/examples/line_with_ci.py +++ b/altair/examples/line_with_ci.py @@ -16,7 +16,7 @@ band = alt.Chart(source).mark_errorband(extent='ci').encode( x='Year', - y=alt.Y('Miles_per_Gallon', title='Miles/Gallon'), + y=alt.Y('Miles_per_Gallon').title('Miles/Gallon'), ) band + line diff --git a/altair/examples/line_with_last_value_labeled b/altair/examples/line_with_last_value_labeled.py similarity index 86% rename from altair/examples/line_with_last_value_labeled rename to altair/examples/line_with_last_value_labeled.py index 8793cab29..1bc108a08 100644 --- a/altair/examples/line_with_last_value_labeled +++ b/altair/examples/line_with_last_value_labeled.py @@ -14,7 +14,7 @@ chart = alt.Chart(source).transform_filter( alt.datum.symbol != "IBM" # A reducation of the dataset to clarify our example. Not required. ).encode( - color=alt.Color("symbol", legend=None) + alt.Color("symbol").legend(None) ) # Draw the line @@ -25,8 +25,8 @@ # Use the `argmax` aggregate to limit the dataset to the final value label = chart.encode( - x=alt.X('max(date):T'), - y=alt.Y('price:Q', aggregate=alt.ArgmaxDef(argmax='date')), + x='max(date):T', + y=alt.Y('price:Q').aggregate(argmax='date'), text='symbol' ) diff --git a/altair/examples/line_with_log_scale.py b/altair/examples/line_with_log_scale.py index b45fcd92e..740a670cb 100644 --- a/altair/examples/line_with_log_scale.py +++ b/altair/examples/line_with_log_scale.py @@ -11,8 +11,5 @@ alt.Chart(source).mark_line().encode( x='year:O', - y=alt.Y( - 'sum(people)', - scale=alt.Scale(type="log") # Here the scale is applied - ) -) \ No newline at end of file + y=alt.Y('sum(people)').scale(type="log") +) diff --git a/altair/examples/london_tube.py b/altair/examples/london_tube.py index 3a39e6aef..b19ef9acc 100644 --- a/altair/examples/london_tube.py +++ b/altair/examples/london_tube.py @@ -13,14 +13,11 @@ tubelines = alt.topo_feature(data.londonTubeLines.url, 'line') centroids = data.londonCentroids.url -background = alt.Chart(boroughs).mark_geoshape( +background = alt.Chart(boroughs, width=700, height=500).mark_geoshape( stroke='white', strokeWidth=2 ).encode( color=alt.value('#eee'), -).properties( - width=700, - height=500 ) labels = alt.Chart(centroids).mark_text().encode( @@ -45,15 +42,10 @@ filled=False, strokeWidth=2 ).encode( - alt.Color( - 'id:N', - legend=alt.Legend( - title=None, - orient='bottom-right', - offset=0 - ), - scale=line_scale - ) + alt.Color('id:N') + .title(None) + .legend(orient='bottom-right', offset=0) + .scale(line_scale) ) background + labels + lines From 52e6adab896fb15fc7d65b840135a28522b7bffd Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Wed, 7 Dec 2022 20:03:28 -0800 Subject: [PATCH 16/26] Add another set of gallery examples --- altair/examples/mosaic_with_labels.py | 18 ++++++------ altair/examples/multifeature_scatter_plot.py | 4 +-- altair/examples/multiline_highlight.py | 6 ++-- altair/examples/multiline_tooltip.py | 6 ++-- altair/examples/multiple_interactions.py | 24 ++++++++++------ altair/examples/natural_disasters.py | 26 ++++++++--------- .../examples/normalized_stacked_area_chart.py | 2 +- .../examples/normalized_stacked_bar_chart.py | 2 +- altair/examples/parallel_coordinates.py | 6 ++-- altair/examples/percentage_of_total.py | 8 ++++-- altair/examples/pie_chart.py | 4 +-- altair/examples/pie_chart_with_labels.py | 3 +- altair/examples/poly_fit_regression.py | 3 +- altair/examples/pyramid.py | 15 ++++++---- altair/examples/radial_chart.py | 4 +-- altair/examples/ranged_dot_plot.py | 7 +---- altair/examples/ridgeline_plot.py | 28 ++++++++----------- 17 files changed, 87 insertions(+), 79 deletions(-) diff --git a/altair/examples/mosaic_with_labels.py b/altair/examples/mosaic_with_labels.py index 2db0baff2..d77ed05ab 100644 --- a/altair/examples/mosaic_with_labels.py +++ b/altair/examples/mosaic_with_labels.py @@ -52,29 +52,27 @@ rect = base.mark_rect().encode( - x=alt.X("nx:Q", axis=None), + x=alt.X("nx:Q").axis(None), x2="nx2", y="ny:Q", y2="ny2", - color=alt.Color("Origin:N", legend=None), - opacity=alt.Opacity("Cylinders:Q", legend=None), + color=alt.Color("Origin:N").legend(None), + opacity=alt.Opacity("Cylinders:Q").legend(None), tooltip=["Origin:N", "Cylinders:Q"], ) text = base.mark_text(baseline="middle").encode( - x=alt.X("xc:Q", axis=None), y=alt.Y("yc:Q", title="Cylinders"), text="Cylinders:N" + alt.X("xc:Q").axis(None), + alt.Y("yc:Q").title("Cylinders"), + text="Cylinders:N" ) - mosaic = rect + text origin_labels = base.mark_text(baseline="middle", align="center").encode( - x=alt.X( - "min(xc):Q", - axis=alt.Axis(title="Origin", orient="top"), - ), - color=alt.Color("Origin", legend=None), + alt.X("min(xc):Q").title("Origin").axis(orient="top"), + alt.Color("Origin").legend(None), text="Origin", ) diff --git a/altair/examples/multifeature_scatter_plot.py b/altair/examples/multifeature_scatter_plot.py index 40e189bbf..164b647bd 100644 --- a/altair/examples/multifeature_scatter_plot.py +++ b/altair/examples/multifeature_scatter_plot.py @@ -10,8 +10,8 @@ source = data.iris() alt.Chart(source).mark_circle().encode( - alt.X('sepalLength', scale=alt.Scale(zero=False)), - alt.Y('sepalWidth', scale=alt.Scale(zero=False, padding=1)), + alt.X('sepalLength').scale(zero=False), + alt.Y('sepalWidth').scale(zero=False, padding=1), color='species', size='petalWidth' ) diff --git a/altair/examples/multiline_highlight.py b/altair/examples/multiline_highlight.py index a6a172c4f..0e3f7781b 100644 --- a/altair/examples/multiline_highlight.py +++ b/altair/examples/multiline_highlight.py @@ -12,8 +12,10 @@ source = data.stocks() -highlight = alt.selection(type='point', on='mouseover', - fields=['symbol'], nearest=True) +highlight = alt.selection( + type='point', on='mouseover', + fields=['symbol'], nearest=True +) base = alt.Chart(source).encode( x='date:T', diff --git a/altair/examples/multiline_tooltip.py b/altair/examples/multiline_tooltip.py index 0a242e74e..4dfa8d2c0 100644 --- a/altair/examples/multiline_tooltip.py +++ b/altair/examples/multiline_tooltip.py @@ -18,8 +18,10 @@ import numpy as np np.random.seed(42) -source = pd.DataFrame(np.cumsum(np.random.randn(100, 3), 0).round(2), - columns=['A', 'B', 'C'], index=pd.RangeIndex(100, name='x')) +source = pd.DataFrame( + np.cumsum(np.random.randn(100, 3), 0).round(2), + columns=['A', 'B', 'C'], index=pd.RangeIndex(100, name='x') +) source = source.reset_index().melt('x', var_name='category', value_name='y') # Create a selection that chooses the nearest point & selects based on x-value diff --git a/altair/examples/multiple_interactions.py b/altair/examples/multiple_interactions.py index e11905018..3f85ab5aa 100644 --- a/altair/examples/multiple_interactions.py +++ b/altair/examples/multiple_interactions.py @@ -19,9 +19,11 @@ format=alt.DataFormat(parse={"Release_Date":"date"}) ) ratings = ['G', 'NC-17', 'PG', 'PG-13', 'R'] -genres = ['Action', 'Adventure', 'Black Comedy', 'Comedy', - 'Concert/Performance', 'Documentary', 'Drama', 'Horror', 'Musical', - 'Romantic Comedy', 'Thriller/Suspense', 'Western'] +genres = [ + 'Action', 'Adventure', 'Black Comedy', 'Comedy', + 'Concert/Performance', 'Documentary', 'Drama', 'Horror', 'Musical', + 'Romantic Comedy', 'Thriller/Suspense', 'Western' +] base = alt.Chart(movies, width=200, height=200).mark_point(filled=True).transform_calculate( Rounded_IMDB_Rating = "floor(datum.IMDB_Rating)", @@ -32,14 +34,18 @@ ).transform_filter( alt.FieldOneOfPredicate(field='MPAA_Rating', oneOf=ratings) ).encode( - x=alt.X('Worldwide_Gross:Q', scale=alt.Scale(domain=(100000,10**9), clamp=True)), + x=alt.X('Worldwide_Gross:Q').scale(domain=(100000,10**9), clamp=True), y='IMDB_Rating:Q', tooltip="Title:N" ) # A slider filter year_slider = alt.binding_range(min=1969, max=2018, step=1) -slider_selection = alt.selection_point(bind=year_slider, fields=['Release_Year'], name="Release Year_") +slider_selection = alt.selection_point( + bind=year_slider, + fields=['Release_Year'], + name="Release Year_" +) filter_year = base.add_params( @@ -62,9 +68,11 @@ rating_radio = alt.binding_radio(options=ratings) rating_select = alt.selection_point(fields=['MPAA_Rating'], bind=rating_radio, name="Rating") -rating_color_condition = alt.condition(rating_select, - alt.Color('MPAA_Rating:N', legend=None), - alt.value('lightgray')) +rating_color_condition = alt.condition( + rating_select, + alt.Color('MPAA_Rating:N').legend(None), + alt.value('lightgray') +) highlight_ratings = base.add_params( rating_select diff --git a/altair/examples/natural_disasters.py b/altair/examples/natural_disasters.py index 031c1e987..31b50a151 100644 --- a/altair/examples/natural_disasters.py +++ b/altair/examples/natural_disasters.py @@ -17,20 +17,20 @@ strokeWidth=1, strokeOpacity=0.4 ).encode( - x=alt.X('Year:T', title=None, scale=alt.Scale(domain=['1899','2018'])), - y=alt.Y( - 'Entity:N', - sort=alt.EncodingSortField(field="Deaths", op="sum", order='descending'), - title=None - ), - size=alt.Size('Deaths:Q', - scale=alt.Scale(range=[0, 2500]), - legend=alt.Legend(title='Deaths', clipHeight=30, format='s') - ), - color=alt.Color('Entity:N', legend=None), + alt.X('Year:T') + .title(None) + .scale(domain=['1899','2018']), + alt.Y('Entity:N') + .title(None) + .sort(field="Deaths", op="sum", order='descending'), + alt.Size('Deaths:Q') + .scale(range=[0, 2500]) + .title('Deaths') + .legend(clipHeight=30, format='s'), + alt.Color('Entity:N').legend(None), tooltip=[ - "Entity:N", - alt.Tooltip("Year:T", format='%Y'), + "Entity:N", + alt.Tooltip("Year:T", format='%Y'), alt.Tooltip("Deaths:Q", format='~s') ], ).properties( diff --git a/altair/examples/normalized_stacked_area_chart.py b/altair/examples/normalized_stacked_area_chart.py index a6bfec365..5973d7174 100644 --- a/altair/examples/normalized_stacked_area_chart.py +++ b/altair/examples/normalized_stacked_area_chart.py @@ -11,6 +11,6 @@ alt.Chart(source).mark_area().encode( x="year:T", - y=alt.Y("net_generation:Q", stack="normalize"), + y=alt.Y("net_generation:Q").stack("normalize"), color="source:N" ) diff --git a/altair/examples/normalized_stacked_bar_chart.py b/altair/examples/normalized_stacked_bar_chart.py index 307a452d2..71e48b9a1 100644 --- a/altair/examples/normalized_stacked_bar_chart.py +++ b/altair/examples/normalized_stacked_bar_chart.py @@ -10,7 +10,7 @@ source = data.barley() alt.Chart(source).mark_bar().encode( - x=alt.X('sum(yield)', stack="normalize"), + x=alt.X('sum(yield)').stack("normalize"), y='variety', color='site' ) diff --git a/altair/examples/parallel_coordinates.py b/altair/examples/parallel_coordinates.py index c46bc0129..f5d7cbd6e 100644 --- a/altair/examples/parallel_coordinates.py +++ b/altair/examples/parallel_coordinates.py @@ -15,8 +15,8 @@ source = data.iris() -alt.Chart(source).transform_window( - index='count()' +alt.Chart(source, width=500).transform_window( + index='count()' ).transform_fold( ['petalLength', 'petalWidth', 'sepalLength', 'sepalWidth'] ).mark_line().encode( @@ -25,4 +25,4 @@ color='species:N', detail='index:N', opacity=alt.value(0.5) -).properties(width=500) +) diff --git a/altair/examples/percentage_of_total.py b/altair/examples/percentage_of_total.py index 462353fde..addb9fd84 100644 --- a/altair/examples/percentage_of_total.py +++ b/altair/examples/percentage_of_total.py @@ -8,14 +8,16 @@ import altair as alt import pandas as pd -source = pd.DataFrame({'Activity': ['Sleeping', 'Eating', 'TV', 'Work', 'Exercise'], - 'Time': [8, 2, 4, 8, 2]}) +source = pd.DataFrame({ + 'Activity': ['Sleeping', 'Eating', 'TV', 'Work', 'Exercise'], + 'Time': [8, 2, 4, 8, 2] +}) alt.Chart(source).transform_joinaggregate( TotalTime='sum(Time)', ).transform_calculate( PercentOfTotal="datum.Time / datum.TotalTime" ).mark_bar().encode( - alt.X('PercentOfTotal:Q', axis=alt.Axis(format='.0%')), + alt.X('PercentOfTotal:Q').axis(format='.0%'), y='Activity:N' ) diff --git a/altair/examples/pie_chart.py b/altair/examples/pie_chart.py index 230127a93..afc7515cb 100644 --- a/altair/examples/pie_chart.py +++ b/altair/examples/pie_chart.py @@ -13,6 +13,6 @@ source = pd.DataFrame({"category": [1, 2, 3, 4, 5, 6], "value": [4, 6, 10, 3, 7, 8]}) alt.Chart(source).mark_arc().encode( - theta=alt.Theta(field="value", type="quantitative"), - color=alt.Color(field="category", type="nominal"), + theta="value", + color="category" ) diff --git a/altair/examples/pie_chart_with_labels.py b/altair/examples/pie_chart_with_labels.py index 15a3fb188..d82860853 100644 --- a/altair/examples/pie_chart_with_labels.py +++ b/altair/examples/pie_chart_with_labels.py @@ -15,7 +15,8 @@ ) base = alt.Chart(source).encode( - theta=alt.Theta("value:Q", stack=True), color=alt.Color("category:N", legend=None) + alt.Theta("value:Q").stack(True), + alt.Color("category:N").legend(None) ) pie = base.mark_arc(outerRadius=120) diff --git a/altair/examples/poly_fit_regression.py b/altair/examples/poly_fit_regression.py index 77163c940..8842b9d98 100644 --- a/altair/examples/poly_fit_regression.py +++ b/altair/examples/poly_fit_regression.py @@ -20,7 +20,8 @@ degree_list = [1, 3, 5] base = alt.Chart(source).mark_circle(color="black").encode( - alt.X("x"), alt.Y("y") + alt.X("x"), + alt.Y("y") ) polynomial_fit = [ diff --git a/altair/examples/pyramid.py b/altair/examples/pyramid.py index 676d77e88..82aa854d0 100644 --- a/altair/examples/pyramid.py +++ b/altair/examples/pyramid.py @@ -11,10 +11,13 @@ color = ["#416D9D", "#674028", "#DEAC58"] df = pd.DataFrame({'category': category, 'value': [75, 10, 15]}) -alt.Chart(df).mark_arc(outerRadius=80).encode( - alt.Theta('value:Q', scale=alt.Scale(range=[2.356, 8.639])), - alt.Color('category:N', - scale=alt.Scale(domain=category, range=color), - legend=alt.Legend(title=None, orient='none', legendX=160, legendY=50)), +alt.Chart(df, width=150, height=150).mark_arc(outerRadius=80).encode( + alt.Theta('value:Q').scale(range=[2.356, 8.639]), + alt.Color('category:N') + .title(None) + .scale(domain=category, range=color) + .legend(orient='none', legendX=160, legendY=50), order='value:Q' -).properties(width=150, height=150).configure_view(strokeOpacity=0) +).configure_view( + strokeOpacity=0 +) diff --git a/altair/examples/radial_chart.py b/altair/examples/radial_chart.py index 3240d092f..1f844c945 100644 --- a/altair/examples/radial_chart.py +++ b/altair/examples/radial_chart.py @@ -13,8 +13,8 @@ source = pd.DataFrame({"values": [12, 23, 47, 6, 52, 19]}) base = alt.Chart(source).encode( - theta=alt.Theta("values:Q", stack=True), - radius=alt.Radius("values", scale=alt.Scale(type="sqrt", zero=True, rangeMin=20)), + alt.Theta("values:Q").stack(True), + alt.Radius("values").scale(type="sqrt", zero=True, rangeMin=20), color="values:N", ) diff --git a/altair/examples/ranged_dot_plot.py b/altair/examples/ranged_dot_plot.py index d7efcf77c..340eeed32 100644 --- a/altair/examples/ranged_dot_plot.py +++ b/altair/examples/ranged_dot_plot.py @@ -32,12 +32,7 @@ ).encode( x='life_expect:Q', y='country:N', - color=alt.Color('year:O', - scale=alt.Scale( - domain=[1955, 2000], - range=['#e6959c', '#911a24'] - ) - ) + color=alt.Color('year:O').scale(domain=[1955, 2000], range=['#e6959c', '#911a24']) ).interactive() (line + points) diff --git a/altair/examples/ridgeline_plot.py b/altair/examples/ridgeline_plot.py index 54c1d6ff5..a04d6c566 100644 --- a/altair/examples/ridgeline_plot.py +++ b/altair/examples/ridgeline_plot.py @@ -34,23 +34,19 @@ stroke='lightgray', strokeWidth=0.5 ).encode( - alt.X('bin_min:Q', bin='binned', title='Maximum Daily Temperature (C)'), - alt.Y( - 'value:Q', - scale=alt.Scale(range=[step, -step * overlap]), - axis=None - ), - alt.Fill( - 'mean_temp:Q', - legend=None, - scale=alt.Scale(domain=[30, 5], scheme='redyellowblue') - ) + alt.X('bin_min:Q') + .bin(True) + .title('Maximum Daily Temperature (C)'), + alt.Y('value:Q') + .axis(None) + .scale(range=[step, -step * overlap]), + alt.Fill('mean_temp:Q') + .legend(None) + .scale(domain=[30, 5], scheme='redyellowblue') ).facet( - row=alt.Row( - 'Month:T', - title=None, - header=alt.Header(labelAngle=0, labelAlign='right', format='%B') - ) + alt.Row('Month:T') + .title(None) + .header(labelAngle=0, labelAlign='right', format='%B') ).properties( title='Seattle Weather', bounds='flush' From ffcca0cc9e3045fa49da664a7cc395d05d8388ab Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Wed, 14 Dec 2022 21:47:34 -0800 Subject: [PATCH 17/26] Add last set of gallery examples --- altair/examples/scatter_linked_table.py | 30 ++++++++++------- altair/examples/scatter_marginal_hist.py | 26 +++++++-------- .../scatter_with_layered_histogram.py | 20 +++++------ altair/examples/scatter_with_minimap.py | 9 ++--- altair/examples/scatter_with_rolling_mean.py | 5 ++- .../examples/seattle_weather_interactive.py | 17 +++++----- altair/examples/select_detail.py | 4 +-- .../examples/simple_scatter_with_errorbars.py | 4 +-- altair/examples/sorted_error_bars_with_ci.py | 13 +++----- .../examples/stacked_bar_chart_with_text.py | 4 +-- altair/examples/stem_and_leaf.py | 10 +++--- altair/examples/strip_plot_jitter.py | 4 +-- altair/examples/top_k_items.py | 6 ++-- altair/examples/top_k_letters.py | 2 +- altair/examples/top_k_with_others.py | 10 +++--- altair/examples/trellis_area_sort_array.py | 2 +- altair/examples/trellis_histogram.py | 2 +- altair/examples/us_employment.py | 4 +-- altair/examples/us_population_over_time.py | 16 ++++----- .../examples/us_population_over_time_facet.py | 10 ++---- .../us_population_pyramid_over_time.py | 22 +++++++------ altair/examples/us_state_capitals.py | 2 +- altair/examples/violin_plot.py | 33 +++++++------------ altair/examples/wheat_wages.py | 28 ++++++++-------- altair/examples/wilkinson-dot-plot.py | 12 +++---- altair/examples/wind_vector_map.py | 25 ++++++-------- altair/examples/window_rank.py | 2 +- 27 files changed, 147 insertions(+), 175 deletions(-) diff --git a/altair/examples/scatter_linked_table.py b/altair/examples/scatter_linked_table.py index 167946824..a822d4ef3 100644 --- a/altair/examples/scatter_linked_table.py +++ b/altair/examples/scatter_linked_table.py @@ -1,7 +1,7 @@ """ Brushing Scatter Plot to Show Data on a Table --------------------------------------------- -A scatter plot of the cars dataset, with data tables for horsepower, MPG, and origin. +A scatter plot of the cars dataset, with data tables for horsepower, MPG, and origin. The tables update to reflect the selection on the scatter plot. """ # category: scatter plots @@ -12,32 +12,36 @@ source = data.cars() # Brush for selection -brush = alt.selection(type='interval') +brush = alt.selection_interval() # Scatter Plot points = alt.Chart(source).mark_point().encode( x='Horsepower:Q', y='Miles_per_Gallon:Q', - color=alt.condition(brush, 'Cylinders:O', alt.value('grey')) + color=alt.condition(brush, alt.value('steelblue'), alt.value('grey')) ).add_params(brush) # Base chart for data tables -ranked_text = alt.Chart(source).mark_text().encode( - y=alt.Y('row_number:O',axis=None) -).transform_window( - row_number='row_number()' +ranked_text = alt.Chart(source).mark_text(align='right').encode( + y=alt.Y('row_number:O').axis(None) ).transform_filter( brush ).transform_window( - rank='rank(row_number)' + row_number='row_number()' ).transform_filter( - alt.datum.rank<20 + 'datum.row_number < 15' ) # Data Tables -horsepower = ranked_text.encode(text='Horsepower:N').properties(title='Horsepower') -mpg = ranked_text.encode(text='Miles_per_Gallon:N').properties(title='MPG') -origin = ranked_text.encode(text='Origin:N').properties(title='Origin') +horsepower = ranked_text.encode(text='Horsepower:N').properties( + title=alt.TitleParams(text='Horsepower', align='right') +) +mpg = ranked_text.encode(text='Miles_per_Gallon:N').properties( + title=alt.TitleParams(text='MPG', align='right') +) +origin = ranked_text.encode(text='Origin:N').properties( + title=alt.TitleParams(text='Origin', align='right') +) text = alt.hconcat(horsepower, mpg, origin) # Combine data tables # Build chart @@ -46,4 +50,6 @@ text ).resolve_legend( color="independent" +).configure_view( + stroke=None ) diff --git a/altair/examples/scatter_marginal_hist.py b/altair/examples/scatter_marginal_hist.py index 52455dcc0..02ddc37fe 100644 --- a/altair/examples/scatter_marginal_hist.py +++ b/altair/examples/scatter_marginal_hist.py @@ -19,31 +19,29 @@ bar_args = {'opacity': .3, 'binSpacing': 0} points = base.mark_circle().encode( - alt.X('sepalLength', scale=xscale), - alt.Y('sepalWidth', scale=yscale), + alt.X('sepalLength').scale(xscale), + alt.Y('sepalWidth').scale(yscale), color='species', ) top_hist = base.mark_bar(**bar_args).encode( - alt.X('sepalLength:Q', + alt.X('sepalLength:Q') # when using bins, the axis scale is set through # the bin extent, so we do not specify the scale here # (which would be ignored anyway) - bin=alt.Bin(maxbins=20, extent=xscale.domain), - stack=None, - title='' - ), - alt.Y('count()', stack=None, title=''), + .bin(maxbins=20, extent=xscale.domain) + .stack(None) + .title(''), + alt.Y('count()').stack(None).title(''), alt.Color('species:N'), ).properties(height=60) right_hist = base.mark_bar(**bar_args).encode( - alt.Y('sepalWidth:Q', - bin=alt.Bin(maxbins=20, extent=yscale.domain), - stack=None, - title='', - ), - alt.X('count()', stack=None, title=''), + alt.Y('sepalWidth:Q') + .bin(maxbins=20, extent=yscale.domain) + .stack(None) + .title(''), + alt.X('count()').stack(None).title(''), alt.Color('species:N'), ).properties(width=60) diff --git a/altair/examples/scatter_with_layered_histogram.py b/altair/examples/scatter_with_layered_histogram.py index 2268b055c..995766ead 100644 --- a/altair/examples/scatter_with_layered_histogram.py +++ b/altair/examples/scatter_with_layered_histogram.py @@ -37,8 +37,8 @@ ).add_params(selector) points = base.mark_point(filled=True, size=200).encode( - x=alt.X('mean(height):Q', scale=alt.Scale(domain=[0,84])), - y=alt.Y('mean(weight):Q', scale=alt.Scale(domain=[0,250])), + x=alt.X('mean(height):Q').scale(domain=[0,84]), + y=alt.Y('mean(weight):Q').scale(domain=[0,250]), color=alt.condition( selector, 'gender:N', @@ -47,17 +47,15 @@ ) hists = base.mark_bar(opacity=0.5, thickness=100).encode( - x=alt.X('age', - bin=alt.Bin(step=5), # step keeps bin size the same - scale=alt.Scale(domain=[0,100])), - y=alt.Y('count()', - stack=None, - scale=alt.Scale(domain=[0,350])), - color=alt.Color('gender:N', - scale=color_scale) + x=alt.X('age') + .bin(step=5) # step keeps bin size the same + .scale(domain=[0,100]), + y=alt.Y('count()') + .stack(None) + .scale(domain=[0,350]), + color=alt.Color('gender:N', scale=color_scale) ).transform_filter( selector ) - points | hists diff --git a/altair/examples/scatter_with_minimap.py b/altair/examples/scatter_with_minimap.py index a18a599cd..0ad0c634c 100644 --- a/altair/examples/scatter_with_minimap.py +++ b/altair/examples/scatter_with_minimap.py @@ -34,13 +34,8 @@ alt.Chart(source) .mark_point() .encode( - x=alt.X( - "date:T", scale=alt.Scale(domain={"param": zoom.name, "encoding": "x"}) - ), - y=alt.Y( - "temp_max:Q", - scale=alt.Scale(domain={"param": zoom.name, "encoding": "y"}), - ), + alt.X("date:T").scale(domain={"param": zoom.name, "encoding": "x"}), + alt.Y("temp_max:Q").scale(domain={"param": zoom.name, "encoding": "y"}), color="weather", ) .properties(width=600, height=400, title="Seattle weather -- detail view") diff --git a/altair/examples/scatter_with_rolling_mean.py b/altair/examples/scatter_with_rolling_mean.py index cf0b36cc1..914e32e4e 100644 --- a/altair/examples/scatter_with_rolling_mean.py +++ b/altair/examples/scatter_with_rolling_mean.py @@ -23,9 +23,8 @@ ) points = alt.Chart(source).mark_point().encode( - x='date:T', - y=alt.Y('temp_max:Q', - axis=alt.Axis(title='Max Temp')) + x='date:T', + y=alt.Y('temp_max:Q').title('Max Temp') ) points + line diff --git a/altair/examples/seattle_weather_interactive.py b/altair/examples/seattle_weather_interactive.py index 798cc4780..46b7448e4 100644 --- a/altair/examples/seattle_weather_interactive.py +++ b/altair/examples/seattle_weather_interactive.py @@ -11,8 +11,10 @@ source = data.seattle_weather() -scale = alt.Scale(domain=['sun', 'fog', 'drizzle', 'rain', 'snow'], - range=['#e7ba52', '#a7a7a7', '#aec7e8', '#1f77b4', '#9467bd']) +scale = alt.Scale( + domain=['sun', 'fog', 'drizzle', 'rain', 'snow'], + range=['#e7ba52', '#a7a7a7', '#aec7e8', '#1f77b4', '#9467bd'] +) color = alt.Color('weather:N', scale=scale) # We create two selections: @@ -23,13 +25,12 @@ # Top panel is scatter plot of temperature vs time points = alt.Chart().mark_point().encode( - alt.X('monthdate(date):T', title='Date'), - alt.Y('temp_max:Q', - title='Maximum Daily Temperature (C)', - scale=alt.Scale(domain=[-5, 40]) - ), + alt.X('monthdate(date):T').title('Date'), + alt.Y('temp_max:Q') + .title('Maximum Daily Temperature (C)') + .scale(domain=[-5, 40]), + alt.Size('precipitation:Q').scale(range=[5, 200]), color=alt.condition(brush, color, alt.value('lightgray')), - size=alt.Size('precipitation:Q', scale=alt.Scale(range=[5, 200])) ).properties( width=550, height=300 diff --git a/altair/examples/select_detail.py b/altair/examples/select_detail.py index a6b558df7..4dead24c5 100644 --- a/altair/examples/select_detail.py +++ b/altair/examples/select_detail.py @@ -56,8 +56,8 @@ timeseries = base.mark_line().encode( x='time', - y=alt.Y('value', scale=alt.Scale(domain=(-15, 15))), - color=alt.Color('id:O', legend=None) + y=alt.Y('value').scale(domain=(-15, 15)), + color=alt.Color('id:O').legend(None) ).transform_filter( selector ) diff --git a/altair/examples/simple_scatter_with_errorbars.py b/altair/examples/simple_scatter_with_errorbars.py index 691f3d893..434e6adca 100644 --- a/altair/examples/simple_scatter_with_errorbars.py +++ b/altair/examples/simple_scatter_with_errorbars.py @@ -29,8 +29,8 @@ size=50, color='black' ).encode( - x=alt.X('x', scale=alt.Scale(domain=(0, 6))), - y=alt.Y('y', scale=alt.Scale(zero=False)) + alt.X('x').scale(domain=(0, 6)), + alt.Y('y').scale(zero=False) ) # generate the error bars diff --git a/altair/examples/sorted_error_bars_with_ci.py b/altair/examples/sorted_error_bars_with_ci.py index 2baac1e1d..ebda26a99 100644 --- a/altair/examples/sorted_error_bars_with_ci.py +++ b/altair/examples/sorted_error_bars_with_ci.py @@ -14,14 +14,11 @@ filled=True, color='black' ).encode( - x=alt.X('mean(yield)', title='Barley Yield'), - y=alt.Y( - 'variety', - sort=alt.EncodingSortField( - field='yield', - op='mean', - order='descending' - ) + x=alt.X('mean(yield)').title('Barley Yield'), + y=alt.Y('variety').sort( + field='yield', + op='mean', + order='descending' ) ).properties( width=400, diff --git a/altair/examples/stacked_bar_chart_with_text.py b/altair/examples/stacked_bar_chart_with_text.py index 180d20871..f2641e4e2 100644 --- a/altair/examples/stacked_bar_chart_with_text.py +++ b/altair/examples/stacked_bar_chart_with_text.py @@ -12,13 +12,13 @@ source=data.barley() bars = alt.Chart(source).mark_bar().encode( - x=alt.X('sum(yield):Q', stack='zero'), + x=alt.X('sum(yield):Q').stack('zero'), y=alt.Y('variety:N'), color=alt.Color('site') ) text = alt.Chart(source).mark_text(dx=-15, dy=3, color='white').encode( - x=alt.X('sum(yield):Q', stack='zero'), + x=alt.X('sum(yield):Q').stack('zero'), y=alt.Y('variety:N'), detail='site:N', text=alt.Text('sum(yield):Q', format='.1f') diff --git a/altair/examples/stem_and_leaf.py b/altair/examples/stem_and_leaf.py index cd8f7179e..9436d8eb2 100644 --- a/altair/examples/stem_and_leaf.py +++ b/altair/examples/stem_and_leaf.py @@ -27,10 +27,12 @@ baseline='middle', dx=-5 ).encode( - alt.X('position:Q', title='', - axis=alt.Axis(ticks=False, labels=False, grid=False) - ), - alt.Y('stem:N', title='', axis=alt.Axis(tickSize=0)), + alt.X('position:Q') + .title('') + .axis(ticks=False, labels=False, grid=False), + alt.Y('stem:N') + .title('') + .axis(tickSize=0), text='leaf:N', ).configure_axis( labelFontSize=20 diff --git a/altair/examples/strip_plot_jitter.py b/altair/examples/strip_plot_jitter.py index e0b7d1645..edf572b02 100644 --- a/altair/examples/strip_plot_jitter.py +++ b/altair/examples/strip_plot_jitter.py @@ -19,7 +19,7 @@ y="Major_Genre:N", x="IMDB_Rating:Q", yOffset="jitter:Q", - color=alt.Color('Major_Genre:N', legend=None) + color=alt.Color('Major_Genre:N').legend(None) ).transform_calculate( # Generate Gaussian jitter with a Box-Muller transform jitter="sqrt(-2*log(random()))*cos(2*PI*random())" @@ -29,7 +29,7 @@ # Generate uniform jitter jitter='random()' ).encode( - y=alt.Y('Major_Genre:N', axis=None) + alt.Y('Major_Genre:N').axis(None) ).properties( title='Uniformly distributed jitter' ) diff --git a/altair/examples/top_k_items.py b/altair/examples/top_k_items.py index 0c8ade36c..49285670e 100644 --- a/altair/examples/top_k_items.py +++ b/altair/examples/top_k_items.py @@ -15,9 +15,9 @@ alt.Chart( source, ).mark_bar().encode( - x=alt.X('Title:N', sort='-y'), - y=alt.Y('IMDB_Rating:Q'), - color=alt.Color('IMDB_Rating:Q') + alt.X('Title:N').sort('-y'), + alt.Y('IMDB_Rating:Q'), + alt.Color('IMDB_Rating:Q') ).transform_window( rank='rank(IMDB_Rating)', diff --git a/altair/examples/top_k_letters.py b/altair/examples/top_k_letters.py index b08fcc309..ac56b02a8 100644 --- a/altair/examples/top_k_letters.py +++ b/altair/examples/top_k_letters.py @@ -35,6 +35,6 @@ ).transform_filter( alt.datum.rank < 10 ).mark_bar().encode( - y=alt.Y('letters:N', sort='-x'), + y=alt.Y('letters:N').sort('-x'), x='count:Q', ) diff --git a/altair/examples/top_k_with_others.py b/altair/examples/top_k_with_others.py index 28cda2423..5a177e160 100644 --- a/altair/examples/top_k_with_others.py +++ b/altair/examples/top_k_with_others.py @@ -12,12 +12,10 @@ source = data.movies.url alt.Chart(source).mark_bar().encode( - x=alt.X("aggregate_gross:Q", aggregate="mean", title=None), - y=alt.Y( - "ranked_director:N", - sort=alt.Sort(op="mean", field="aggregate_gross", order="descending"), - title=None, - ), + alt.X("aggregate_gross:Q").aggregate("mean").title(None), + alt.Y("ranked_director:N") + .sort(op="mean", field="aggregate_gross", order="descending") + .title(None) ).transform_aggregate( aggregate_gross='mean(Worldwide_Gross)', groupby=["Director"], diff --git a/altair/examples/trellis_area_sort_array.py b/altair/examples/trellis_area_sort_array.py index a8c74532e..2dab32fde 100644 --- a/altair/examples/trellis_area_sort_array.py +++ b/altair/examples/trellis_area_sort_array.py @@ -17,5 +17,5 @@ x='date:T', y='price:Q', color='symbol:N', - row=alt.Row('symbol:N', sort=['MSFT', 'AAPL', 'IBM', 'AMZN']) + row=alt.Row('symbol:N').sort(['MSFT', 'AAPL', 'IBM', 'AMZN']) ).properties(height=50, width=400) diff --git a/altair/examples/trellis_histogram.py b/altair/examples/trellis_histogram.py index c124f2caf..8c45ccf20 100644 --- a/altair/examples/trellis_histogram.py +++ b/altair/examples/trellis_histogram.py @@ -11,7 +11,7 @@ source = data.cars() alt.Chart(source).mark_bar().encode( - alt.X("Horsepower:Q", bin=True), + alt.X("Horsepower:Q").bin(), y='count()', row='Origin' ) diff --git a/altair/examples/us_employment.py b/altair/examples/us_employment.py index c62b45e17..2dada0833 100644 --- a/altair/examples/us_employment.py +++ b/altair/examples/us_employment.py @@ -26,8 +26,8 @@ source, title="The U.S. employment crash during the Great Recession" ).mark_bar().encode( - x=alt.X("month:T", title=""), - y=alt.Y("nonfarm_change:Q", title="Change in non-farm employment (in thousands)"), + alt.X("month:T").title(""), + alt.Y("nonfarm_change:Q").title("Change in non-farm employment (in thousands)"), color=alt.condition( alt.datum.nonfarm_change > 0, alt.value("steelblue"), diff --git a/altair/examples/us_population_over_time.py b/altair/examples/us_population_over_time.py index 52e5290a0..75c4fa01c 100644 --- a/altair/examples/us_population_over_time.py +++ b/altair/examples/us_population_over_time.py @@ -15,18 +15,16 @@ name="Year", fields=["year"], bind=alt.binding_range(min=1900, max=2000, step=10, name="Year"), - init={"year": 2000}, + value={"year": 2000}, ) alt.Chart(source).mark_bar().encode( - x=alt.X("sex:N", axis=alt.Axis(labels=False, title=None, ticks=False)), - y=alt.Y("people:Q", scale=alt.Scale(domain=(0, 12000000)), title="Population"), - color=alt.Color( - "sex:N", - scale=alt.Scale(domain=("Male", "Female"), range=["steelblue", "salmon"]), - title="Sex", - ), - column=alt.Column("age:O", title="Age"), + alt.X("sex:N").title('').axis(labels=False, ticks=False), + alt.Y("people:Q").scale(domain=(0, 12000000)).title("Population"), + alt.Color("sex:N") + .scale(domain=("Male", "Female"), range=["steelblue", "salmon"]) + .title("Sex"), + alt.Column("age:O").title("Age") ).properties( width=20, title="U.S. Population by Age and Sex" diff --git a/altair/examples/us_population_over_time_facet.py b/altair/examples/us_population_over_time_facet.py index fc8001981..6444e0d80 100644 --- a/altair/examples/us_population_over_time_facet.py +++ b/altair/examples/us_population_over_time_facet.py @@ -12,14 +12,10 @@ alt.Chart(source).mark_area().encode( x='age:O', - y=alt.Y( - 'sum(people):Q', - title='Population', - axis=alt.Axis(format='~s') - ), - facet=alt.Facet('year:O', columns=5), + y=alt.Y('sum(people):Q').title('Population').axis(format='~s'), + facet=alt.Facet('year:O').columns(5), ).properties( title='US Age Distribution By Year', width=90, height=80 -) \ No newline at end of file +) diff --git a/altair/examples/us_population_pyramid_over_time.py b/altair/examples/us_population_pyramid_over_time.py index 4857adf6a..f7418413d 100644 --- a/altair/examples/us_population_pyramid_over_time.py +++ b/altair/examples/us_population_pyramid_over_time.py @@ -32,24 +32,26 @@ left = base.transform_filter( alt.datum.gender == 'Female' ).encode( - y=alt.Y('age:O', axis=None), - x=alt.X('sum(people):Q', - title='population', - sort=alt.SortOrder('descending')), - color=alt.Color('gender:N', scale=color_scale, legend=None) + alt.Y('age:O').axis(None), + alt.X('sum(people):Q') + .title('population') + .sort('descending'), + alt.Color('gender:N') + .scale(color_scale) + .legend(None) ).mark_bar().properties(title='Female') middle = base.encode( - y=alt.Y('age:O', axis=None), - text=alt.Text('age:Q'), + alt.Y('age:O').axis(None), + alt.Text('age:Q'), ).mark_text().properties(width=20) right = base.transform_filter( alt.datum.gender == 'Male' ).encode( - y=alt.Y('age:O', axis=None), - x=alt.X('sum(people):Q', title='population'), - color=alt.Color('gender:N', scale=color_scale, legend=None) + alt.Y('age:O').axis(None), + alt.X('sum(people):Q').title('population'), + alt.Color('gender:N').scale(color_scale).legend(None) ).mark_bar().properties(title='Male') alt.concat(left, middle, right, spacing=5) diff --git a/altair/examples/us_state_capitals.py b/altair/examples/us_state_capitals.py index 9296b9994..00dfdaea6 100644 --- a/altair/examples/us_state_capitals.py +++ b/altair/examples/us_state_capitals.py @@ -31,7 +31,7 @@ ) text = base.mark_text(dy=-5, align='right').encode( - alt.Text('city', type='nominal'), + alt.Text('city:N'), opacity=alt.condition(~hover, alt.value(0), alt.value(1)) ) diff --git a/altair/examples/violin_plot.py b/altair/examples/violin_plot.py index 09977b86e..d09274d1e 100644 --- a/altair/examples/violin_plot.py +++ b/altair/examples/violin_plot.py @@ -7,33 +7,22 @@ import altair as alt from vega_datasets import data -alt.Chart(data.cars()).transform_density( +alt.Chart(data.cars(), width=100).transform_density( 'Miles_per_Gallon', as_=['Miles_per_Gallon', 'density'], extent=[5, 50], groupby=['Origin'] ).mark_area(orient='horizontal').encode( - y='Miles_per_Gallon:Q', - color='Origin:N', - x=alt.X( - 'density:Q', - stack='center', - impute=None, - title=None, - axis=alt.Axis(labels=False, values=[0],grid=False, ticks=True), - ), - column=alt.Column( - 'Origin:N', - header=alt.Header( - titleOrient='bottom', - labelOrient='bottom', - labelPadding=0, - ), - ) -).properties( - width=100 -).configure_facet( - spacing=0 + alt.X('density:Q') + .stack('center') + .impute(None) + .title(None) + .axis(labels=False, values=[0], grid=False, ticks=True), + alt.Y('Miles_per_Gallon:Q'), + alt.Color('Origin:N'), + alt.Column('Origin:N') + .spacing(0) + .header(titleOrient='bottom', labelOrient='bottom', labelPadding=0) ).configure_view( stroke=None ) diff --git a/altair/examples/wheat_wages.py b/altair/examples/wheat_wages.py index dd168b1fc..81153712d 100644 --- a/altair/examples/wheat_wages.py +++ b/altair/examples/wheat_wages.py @@ -22,31 +22,31 @@ ) bars = base_wheat.mark_bar(**{"fill": "#aaa", "stroke": "#999"}).encode( - x=alt.X("year:Q", axis=alt.Axis(format='d', tickCount=5)), - y=alt.Y("wheat:Q", axis=alt.Axis(zindex=1)), - x2=alt.X2("year_end") + alt.X("year:Q").axis(format='d', tickCount=5), + alt.Y("wheat:Q").axis(zindex=1), + alt.X2("year_end") ) area = base_wheat.mark_area(**{"color": "#a4cedb", "opacity": 0.7}).encode( - x=alt.X("year:Q"), - y=alt.Y("wages:Q") + alt.X("year:Q"), + alt.Y("wages:Q") ) area_line_1 = area.mark_line(**{"color": "#000", "opacity": 0.7}) area_line_2 = area.mark_line(**{"yOffset": -2, "color": "#EE8182"}) top_bars = base_monarchs.mark_bar(stroke="#000").encode( - x=alt.X("start:Q"), - x2=alt.X2("end"), - y=alt.Y("y:Q"), - y2=alt.Y2("offset"), - fill=alt.Fill("commonwealth:N", legend=None, scale=alt.Scale(range=["black", "white"])) + alt.X("start:Q"), + alt.X2("end"), + alt.Y("y:Q"), + alt.Y2("offset"), + alt.Fill("commonwealth:N").legend(None).scale(range=["black", "white"]) ) top_text = base_monarchs.mark_text(**{"yOffset": 14, "fontSize": 9, "fontStyle": "italic"}).encode( - x=alt.X("x:Q"), - y=alt.Y("off2:Q"), - text=alt.Text("name:N") + alt.X("x:Q"), + alt.Y("off2:Q"), + alt.Text("name:N") ) (bars + area + area_line_1 + area_line_2 + top_bars + top_text).properties( @@ -55,4 +55,4 @@ title=None, gridColor="white", gridOpacity=0.25, domain=False ).configure_view( stroke="transparent" -) \ No newline at end of file +) diff --git a/altair/examples/wilkinson-dot-plot.py b/altair/examples/wilkinson-dot-plot.py index d8a9889f0..55e31296c 100644 --- a/altair/examples/wilkinson-dot-plot.py +++ b/altair/examples/wilkinson-dot-plot.py @@ -16,12 +16,10 @@ } ) -alt.Chart(source).mark_circle(opacity=1).transform_window( - id='rank()', +alt.Chart(source, height=100).mark_circle(opacity=1).transform_window( + id='rank()', groupby=['data'] ).encode( - alt.X('data:O'), - alt.Y('id:O', - axis=None, - sort='descending') -).properties(height=100) + alt.X('data:O'), + alt.Y('id:O').axis(None).sort('descending') +) diff --git a/altair/examples/wind_vector_map.py b/altair/examples/wind_vector_map.py index 1235ec33a..56dcd674b 100644 --- a/altair/examples/wind_vector_map.py +++ b/altair/examples/wind_vector_map.py @@ -14,20 +14,15 @@ df_wind = data.windvectors() data_world = alt.topo_feature(data.world_110m.url, "countries") -wedge = ( - alt.Chart(df_wind) - .mark_point(shape="wedge", filled=True) - .encode( - latitude="latitude", - longitude="longitude", - color=alt.Color( - "dir", scale=alt.Scale(domain=[0, 360], scheme="rainbow"), legend=None - ), - angle=alt.Angle("dir", scale=alt.Scale(domain=[0, 360], range=[180, 540])), - size=alt.Size("speed", scale=alt.Scale(rangeMax=500)), - ) - .project("equalEarth") -) +wedge = alt.Chart(df_wind).mark_point(shape="wedge", filled=True).encode( + alt.Latitude("latitude"), + alt.Longitude("longitude"), + alt.Color("dir") + .scale(domain=[0, 360], scheme="rainbow") + .legend(None), + alt.Angle("dir").scale(domain=[0, 360], range=[180, 540]), + alt.Size("speed").scale(rangeMax=500) +).project("equalEarth") xmin, xmax, ymin, ymax = ( df_wind.longitude.min(), @@ -59,4 +54,4 @@ .project(type="equalEarth", fit=extent) ) -base + wedge \ No newline at end of file +base + wedge diff --git a/altair/examples/window_rank.py b/altair/examples/window_rank.py index 1e33fac06..35796dffe 100644 --- a/altair/examples/window_rank.py +++ b/altair/examples/window_rank.py @@ -31,7 +31,7 @@ ) alt.Chart(source).mark_line().encode( - x="matchday:O", y="rank:O", color=alt.Color("team:N", scale=color_scale) + x="matchday:O", y="rank:O", color=alt.Color("team:N").scale(color_scale) ).transform_window( rank="rank()", sort=[ From 557d0c8139890016a01519d9161ae515bf7bf21b Mon Sep 17 00:00:00 2001 From: Christopher Davis Date: Fri, 23 Dec 2022 08:44:52 -0600 Subject: [PATCH 18/26] Type hints for tab completion --- altair/vegalite/v5/schema/channels.py | 3971 ++++++++++++++++++++++++- tools/generate_schema_wrapper.py | 9 + tools/schemapi/codegen.py | 65 +- tools/schemapi/utils.py | 24 +- 4 files changed, 4052 insertions(+), 17 deletions(-) diff --git a/altair/vegalite/v5/schema/channels.py b/altair/vegalite/v5/schema/channels.py index f9152c16b..2f352d331 100644 --- a/altair/vegalite/v5/schema/channels.py +++ b/altair/vegalite/v5/schema/channels.py @@ -5,6 +5,7 @@ import pandas as pd from altair.utils.schemapi import Undefined, with_property_setters from altair.utils import parse_shorthand +from typing import overload class FieldChannelMixin(object): @@ -322,6 +323,105 @@ class Angle(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDef _class_is_valid_at_instantiation = False _encoding_name = "angle" + @overload + def aggregate(self, _: str, **kwds) -> 'Angle': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Angle': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Angle': + ... + + def bandPosition(self, _: float, **kwds) -> 'Angle': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Angle': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Angle': + ... + + @overload + def bin(self, _: type(None), **kwds) -> 'Angle': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'Angle': + ... + + @overload + def condition(self, _: list, **kwds) -> 'Angle': + ... + + @overload + def field(self, _: str, **kwds) -> 'Angle': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Angle': + ... + + @overload + def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, columns=Undefined, cornerRadius=Undefined, description=Undefined, direction=Undefined, fillColor=Undefined, format=Undefined, formatType=Undefined, gradientLength=Undefined, gradientOpacity=Undefined, gradientStrokeColor=Undefined, gradientStrokeWidth=Undefined, gradientThickness=Undefined, gridAlign=Undefined, labelAlign=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, legendX=Undefined, legendY=Undefined, offset=Undefined, orient=Undefined, padding=Undefined, rowPadding=Undefined, strokeColor=Undefined, symbolDash=Undefined, symbolDashOffset=Undefined, symbolFillColor=Undefined, symbolLimit=Undefined, symbolOffset=Undefined, symbolOpacity=Undefined, symbolSize=Undefined, symbolStrokeColor=Undefined, symbolStrokeWidth=Undefined, symbolType=Undefined, tickCount=Undefined, tickMinStep=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titleOrient=Undefined, titlePadding=Undefined, type=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'Angle': + ... + + @overload + def legend(self, _: type(None), **kwds) -> 'Angle': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'Angle': + ... + + @overload + def scale(self, _: type(None), **kwds) -> 'Angle': + ... + + @overload + def sort(self, **kwds) -> 'Angle': + ... + + @overload + def sort(self, **kwds) -> 'Angle': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Angle': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Angle': + ... + + @overload + def sort(self, _: type(None), **kwds) -> 'Angle': + ... + + @overload + def timeUnit(self, **kwds) -> 'Angle': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Angle': + ... + + @overload + def title(self, **kwds) -> 'Angle': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Angle': + ... + + def type(self, _: str, **kwds) -> 'Angle': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, legend=Undefined, scale=Undefined, sort=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -449,6 +549,30 @@ class AngleDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefnum """ _class_is_valid_at_instantiation = False _encoding_name = "angle" + + def bandPosition(self, _: float, **kwds) -> 'AngleDatum': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'AngleDatum': + ... + + @overload + def condition(self, _: list, **kwds) -> 'AngleDatum': + ... + + @overload + def title(self, **kwds) -> 'AngleDatum': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'AngleDatum': + ... + + def type(self, _: str, **kwds) -> 'AngleDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Undefined, type=Undefined, **kwds): super(AngleDatum, self).__init__(datum=datum, bandPosition=bandPosition, condition=condition, @@ -475,6 +599,19 @@ class AngleValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDat _class_is_valid_at_instantiation = False _encoding_name = "angle" + @overload + def condition(self, **kwds) -> 'AngleValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'AngleValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'AngleValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(AngleValue, self).__init__(value=value, condition=condition, **kwds) @@ -710,6 +847,105 @@ class Color(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDef _class_is_valid_at_instantiation = False _encoding_name = "color" + @overload + def aggregate(self, _: str, **kwds) -> 'Color': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Color': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Color': + ... + + def bandPosition(self, _: float, **kwds) -> 'Color': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Color': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Color': + ... + + @overload + def bin(self, _: type(None), **kwds) -> 'Color': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'Color': + ... + + @overload + def condition(self, _: list, **kwds) -> 'Color': + ... + + @overload + def field(self, _: str, **kwds) -> 'Color': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Color': + ... + + @overload + def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, columns=Undefined, cornerRadius=Undefined, description=Undefined, direction=Undefined, fillColor=Undefined, format=Undefined, formatType=Undefined, gradientLength=Undefined, gradientOpacity=Undefined, gradientStrokeColor=Undefined, gradientStrokeWidth=Undefined, gradientThickness=Undefined, gridAlign=Undefined, labelAlign=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, legendX=Undefined, legendY=Undefined, offset=Undefined, orient=Undefined, padding=Undefined, rowPadding=Undefined, strokeColor=Undefined, symbolDash=Undefined, symbolDashOffset=Undefined, symbolFillColor=Undefined, symbolLimit=Undefined, symbolOffset=Undefined, symbolOpacity=Undefined, symbolSize=Undefined, symbolStrokeColor=Undefined, symbolStrokeWidth=Undefined, symbolType=Undefined, tickCount=Undefined, tickMinStep=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titleOrient=Undefined, titlePadding=Undefined, type=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'Color': + ... + + @overload + def legend(self, _: type(None), **kwds) -> 'Color': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'Color': + ... + + @overload + def scale(self, _: type(None), **kwds) -> 'Color': + ... + + @overload + def sort(self, **kwds) -> 'Color': + ... + + @overload + def sort(self, **kwds) -> 'Color': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Color': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Color': + ... + + @overload + def sort(self, _: type(None), **kwds) -> 'Color': + ... + + @overload + def timeUnit(self, **kwds) -> 'Color': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Color': + ... + + @overload + def title(self, **kwds) -> 'Color': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Color': + ... + + def type(self, _: str, **kwds) -> 'Color': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, legend=Undefined, scale=Undefined, sort=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -837,6 +1073,30 @@ class ColorDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefGra """ _class_is_valid_at_instantiation = False _encoding_name = "color" + + def bandPosition(self, _: float, **kwds) -> 'ColorDatum': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'ColorDatum': + ... + + @overload + def condition(self, _: list, **kwds) -> 'ColorDatum': + ... + + @overload + def title(self, **kwds) -> 'ColorDatum': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'ColorDatum': + ... + + def type(self, _: str, **kwds) -> 'ColorDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Undefined, type=Undefined, **kwds): super(ColorDatum, self).__init__(datum=datum, bandPosition=bandPosition, condition=condition, @@ -864,6 +1124,19 @@ class ColorValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDat _class_is_valid_at_instantiation = False _encoding_name = "color" + @overload + def condition(self, **kwds) -> 'ColorValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'ColorValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'ColorValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(ColorValue, self).__init__(value=value, condition=condition, **kwds) @@ -1082,6 +1355,94 @@ class Column(FieldChannelMixin, core.RowColumnEncodingFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "column" + @overload + def aggregate(self, _: str, **kwds) -> 'Column': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Column': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Column': + ... + + def align(self, _: str, **kwds) -> 'Column': + ... + + def bandPosition(self, _: float, **kwds) -> 'Column': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Column': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Column': + ... + + @overload + def bin(self, _: type(None), **kwds) -> 'Column': + ... + + def center(self, _: bool, **kwds) -> 'Column': + ... + + @overload + def field(self, _: str, **kwds) -> 'Column': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Column': + ... + + @overload + def header(self, format=Undefined, formatType=Undefined, labelAlign=Undefined, labelAnchor=Undefined, labelAngle=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelLineHeight=Undefined, labelOrient=Undefined, labelPadding=Undefined, labels=Undefined, orient=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleAngle=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOrient=Undefined, titlePadding=Undefined, **kwds) -> 'Column': + ... + + @overload + def header(self, _: type(None), **kwds) -> 'Column': + ... + + @overload + def sort(self, **kwds) -> 'Column': + ... + + @overload + def sort(self, _: str, **kwds) -> 'Column': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Column': + ... + + @overload + def sort(self, _: type(None), **kwds) -> 'Column': + ... + + def spacing(self, _: float, **kwds) -> 'Column': + ... + + @overload + def timeUnit(self, **kwds) -> 'Column': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Column': + ... + + @overload + def title(self, **kwds) -> 'Column': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Column': + ... + + def type(self, _: str, **kwds) -> 'Column': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, align=Undefined, bandPosition=Undefined, bin=Undefined, center=Undefined, field=Undefined, header=Undefined, sort=Undefined, spacing=Undefined, timeUnit=Undefined, @@ -1297,6 +1658,84 @@ class Description(FieldChannelMixin, core.StringFieldDefWithCondition): _class_is_valid_at_instantiation = False _encoding_name = "description" + @overload + def aggregate(self, _: str, **kwds) -> 'Description': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Description': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Description': + ... + + def bandPosition(self, _: float, **kwds) -> 'Description': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Description': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Description': + ... + + @overload + def bin(self, _: str, **kwds) -> 'Description': + ... + + @overload + def bin(self, _: type(None), **kwds) -> 'Description': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'Description': + ... + + @overload + def condition(self, _: list, **kwds) -> 'Description': + ... + + @overload + def field(self, _: str, **kwds) -> 'Description': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Description': + ... + + @overload + def format(self, _: str, **kwds) -> 'Description': + ... + + @overload + def format(self, _: dict, **kwds) -> 'Description': + ... + + def formatType(self, _: str, **kwds) -> 'Description': + ... + + @overload + def timeUnit(self, **kwds) -> 'Description': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Description': + ... + + @overload + def title(self, **kwds) -> 'Description': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Description': + ... + + def type(self, _: str, **kwds) -> 'Description': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, format=Undefined, formatType=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -1327,6 +1766,19 @@ class DescriptionValue(ValueChannelMixin, core.StringValueDefWithCondition): _class_is_valid_at_instantiation = False _encoding_name = "description" + @overload + def condition(self, **kwds) -> 'DescriptionValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'DescriptionValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'DescriptionValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(DescriptionValue, self).__init__(value=value, condition=condition, **kwds) @@ -1493,6 +1945,65 @@ class Detail(FieldChannelMixin, core.FieldDefWithoutScale): _class_is_valid_at_instantiation = False _encoding_name = "detail" + @overload + def aggregate(self, _: str, **kwds) -> 'Detail': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Detail': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Detail': + ... + + def bandPosition(self, _: float, **kwds) -> 'Detail': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Detail': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Detail': + ... + + @overload + def bin(self, _: str, **kwds) -> 'Detail': + ... + + @overload + def bin(self, _: type(None), **kwds) -> 'Detail': + ... + + @overload + def field(self, _: str, **kwds) -> 'Detail': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Detail': + ... + + @overload + def timeUnit(self, **kwds) -> 'Detail': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Detail': + ... + + @overload + def title(self, **kwds) -> 'Detail': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Detail': + ... + + def type(self, _: str, **kwds) -> 'Detail': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): super(Detail, self).__init__(shorthand=shorthand, aggregate=aggregate, @@ -1752,6 +2263,115 @@ class Facet(FieldChannelMixin, core.FacetEncodingFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "facet" + @overload + def aggregate(self, _: str, **kwds) -> 'Facet': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Facet': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Facet': + ... + + @overload + def align(self, _: str, **kwds) -> 'Facet': + ... + + @overload + def align(self, column=Undefined, row=Undefined, **kwds) -> 'Facet': + ... + + def bandPosition(self, _: float, **kwds) -> 'Facet': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Facet': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Facet': + ... + + @overload + def bin(self, _: type(None), **kwds) -> 'Facet': + ... + + def bounds(self, _: str, **kwds) -> 'Facet': + ... + + @overload + def center(self, _: bool, **kwds) -> 'Facet': + ... + + @overload + def center(self, column=Undefined, row=Undefined, **kwds) -> 'Facet': + ... + + def columns(self, _: float, **kwds) -> 'Facet': + ... + + @overload + def field(self, _: str, **kwds) -> 'Facet': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Facet': + ... + + @overload + def header(self, format=Undefined, formatType=Undefined, labelAlign=Undefined, labelAnchor=Undefined, labelAngle=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelLineHeight=Undefined, labelOrient=Undefined, labelPadding=Undefined, labels=Undefined, orient=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleAngle=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOrient=Undefined, titlePadding=Undefined, **kwds) -> 'Facet': + ... + + @overload + def header(self, _: type(None), **kwds) -> 'Facet': + ... + + @overload + def sort(self, **kwds) -> 'Facet': + ... + + @overload + def sort(self, _: str, **kwds) -> 'Facet': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Facet': + ... + + @overload + def sort(self, _: type(None), **kwds) -> 'Facet': + ... + + @overload + def spacing(self, _: float, **kwds) -> 'Facet': + ... + + @overload + def spacing(self, column=Undefined, row=Undefined, **kwds) -> 'Facet': + ... + + @overload + def timeUnit(self, **kwds) -> 'Facet': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Facet': + ... + + @overload + def title(self, **kwds) -> 'Facet': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Facet': + ... + + def type(self, _: str, **kwds) -> 'Facet': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, align=Undefined, bandPosition=Undefined, bin=Undefined, bounds=Undefined, center=Undefined, columns=Undefined, field=Undefined, header=Undefined, sort=Undefined, @@ -1993,6 +2613,105 @@ class Fill(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDefG _class_is_valid_at_instantiation = False _encoding_name = "fill" + @overload + def aggregate(self, _: str, **kwds) -> 'Fill': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Fill': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Fill': + ... + + def bandPosition(self, _: float, **kwds) -> 'Fill': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Fill': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Fill': + ... + + @overload + def bin(self, _: type(None), **kwds) -> 'Fill': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'Fill': + ... + + @overload + def condition(self, _: list, **kwds) -> 'Fill': + ... + + @overload + def field(self, _: str, **kwds) -> 'Fill': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Fill': + ... + + @overload + def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, columns=Undefined, cornerRadius=Undefined, description=Undefined, direction=Undefined, fillColor=Undefined, format=Undefined, formatType=Undefined, gradientLength=Undefined, gradientOpacity=Undefined, gradientStrokeColor=Undefined, gradientStrokeWidth=Undefined, gradientThickness=Undefined, gridAlign=Undefined, labelAlign=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, legendX=Undefined, legendY=Undefined, offset=Undefined, orient=Undefined, padding=Undefined, rowPadding=Undefined, strokeColor=Undefined, symbolDash=Undefined, symbolDashOffset=Undefined, symbolFillColor=Undefined, symbolLimit=Undefined, symbolOffset=Undefined, symbolOpacity=Undefined, symbolSize=Undefined, symbolStrokeColor=Undefined, symbolStrokeWidth=Undefined, symbolType=Undefined, tickCount=Undefined, tickMinStep=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titleOrient=Undefined, titlePadding=Undefined, type=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'Fill': + ... + + @overload + def legend(self, _: type(None), **kwds) -> 'Fill': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'Fill': + ... + + @overload + def scale(self, _: type(None), **kwds) -> 'Fill': + ... + + @overload + def sort(self, **kwds) -> 'Fill': + ... + + @overload + def sort(self, **kwds) -> 'Fill': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Fill': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Fill': + ... + + @overload + def sort(self, _: type(None), **kwds) -> 'Fill': + ... + + @overload + def timeUnit(self, **kwds) -> 'Fill': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Fill': + ... + + @overload + def title(self, **kwds) -> 'Fill': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Fill': + ... + + def type(self, _: str, **kwds) -> 'Fill': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, legend=Undefined, scale=Undefined, sort=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -2120,6 +2839,30 @@ class FillDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefGrad """ _class_is_valid_at_instantiation = False _encoding_name = "fill" + + def bandPosition(self, _: float, **kwds) -> 'FillDatum': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'FillDatum': + ... + + @overload + def condition(self, _: list, **kwds) -> 'FillDatum': + ... + + @overload + def title(self, **kwds) -> 'FillDatum': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'FillDatum': + ... + + def type(self, _: str, **kwds) -> 'FillDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Undefined, type=Undefined, **kwds): super(FillDatum, self).__init__(datum=datum, bandPosition=bandPosition, condition=condition, @@ -2147,6 +2890,19 @@ class FillValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDatu _class_is_valid_at_instantiation = False _encoding_name = "fill" + @overload + def condition(self, **kwds) -> 'FillValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'FillValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'FillValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(FillValue, self).__init__(value=value, condition=condition, **kwds) @@ -2382,6 +3138,105 @@ class FillOpacity(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFi _class_is_valid_at_instantiation = False _encoding_name = "fillOpacity" + @overload + def aggregate(self, _: str, **kwds) -> 'FillOpacity': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'FillOpacity': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'FillOpacity': + ... + + def bandPosition(self, _: float, **kwds) -> 'FillOpacity': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'FillOpacity': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'FillOpacity': + ... + + @overload + def bin(self, _: type(None), **kwds) -> 'FillOpacity': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'FillOpacity': + ... + + @overload + def condition(self, _: list, **kwds) -> 'FillOpacity': + ... + + @overload + def field(self, _: str, **kwds) -> 'FillOpacity': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'FillOpacity': + ... + + @overload + def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, columns=Undefined, cornerRadius=Undefined, description=Undefined, direction=Undefined, fillColor=Undefined, format=Undefined, formatType=Undefined, gradientLength=Undefined, gradientOpacity=Undefined, gradientStrokeColor=Undefined, gradientStrokeWidth=Undefined, gradientThickness=Undefined, gridAlign=Undefined, labelAlign=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, legendX=Undefined, legendY=Undefined, offset=Undefined, orient=Undefined, padding=Undefined, rowPadding=Undefined, strokeColor=Undefined, symbolDash=Undefined, symbolDashOffset=Undefined, symbolFillColor=Undefined, symbolLimit=Undefined, symbolOffset=Undefined, symbolOpacity=Undefined, symbolSize=Undefined, symbolStrokeColor=Undefined, symbolStrokeWidth=Undefined, symbolType=Undefined, tickCount=Undefined, tickMinStep=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titleOrient=Undefined, titlePadding=Undefined, type=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'FillOpacity': + ... + + @overload + def legend(self, _: type(None), **kwds) -> 'FillOpacity': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'FillOpacity': + ... + + @overload + def scale(self, _: type(None), **kwds) -> 'FillOpacity': + ... + + @overload + def sort(self, **kwds) -> 'FillOpacity': + ... + + @overload + def sort(self, **kwds) -> 'FillOpacity': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'FillOpacity': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'FillOpacity': + ... + + @overload + def sort(self, _: type(None), **kwds) -> 'FillOpacity': + ... + + @overload + def timeUnit(self, **kwds) -> 'FillOpacity': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'FillOpacity': + ... + + @overload + def title(self, **kwds) -> 'FillOpacity': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'FillOpacity': + ... + + def type(self, _: str, **kwds) -> 'FillOpacity': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, legend=Undefined, scale=Undefined, sort=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -2509,6 +3364,30 @@ class FillOpacityDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatum """ _class_is_valid_at_instantiation = False _encoding_name = "fillOpacity" + + def bandPosition(self, _: float, **kwds) -> 'FillOpacityDatum': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'FillOpacityDatum': + ... + + @overload + def condition(self, _: list, **kwds) -> 'FillOpacityDatum': + ... + + @overload + def title(self, **kwds) -> 'FillOpacityDatum': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'FillOpacityDatum': + ... + + def type(self, _: str, **kwds) -> 'FillOpacityDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Undefined, type=Undefined, **kwds): super(FillOpacityDatum, self).__init__(datum=datum, bandPosition=bandPosition, @@ -2535,6 +3414,19 @@ class FillOpacityValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFiel _class_is_valid_at_instantiation = False _encoding_name = "fillOpacity" + @overload + def condition(self, **kwds) -> 'FillOpacityValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'FillOpacityValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'FillOpacityValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(FillOpacityValue, self).__init__(value=value, condition=condition, **kwds) @@ -2744,6 +3636,84 @@ class Href(FieldChannelMixin, core.StringFieldDefWithCondition): _class_is_valid_at_instantiation = False _encoding_name = "href" + @overload + def aggregate(self, _: str, **kwds) -> 'Href': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Href': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Href': + ... + + def bandPosition(self, _: float, **kwds) -> 'Href': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Href': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Href': + ... + + @overload + def bin(self, _: str, **kwds) -> 'Href': + ... + + @overload + def bin(self, _: type(None), **kwds) -> 'Href': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'Href': + ... + + @overload + def condition(self, _: list, **kwds) -> 'Href': + ... + + @overload + def field(self, _: str, **kwds) -> 'Href': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Href': + ... + + @overload + def format(self, _: str, **kwds) -> 'Href': + ... + + @overload + def format(self, _: dict, **kwds) -> 'Href': + ... + + def formatType(self, _: str, **kwds) -> 'Href': + ... + + @overload + def timeUnit(self, **kwds) -> 'Href': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Href': + ... + + @overload + def title(self, **kwds) -> 'Href': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Href': + ... + + def type(self, _: str, **kwds) -> 'Href': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, format=Undefined, formatType=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -2774,6 +3744,19 @@ class HrefValue(ValueChannelMixin, core.StringValueDefWithCondition): _class_is_valid_at_instantiation = False _encoding_name = "href" + @overload + def condition(self, **kwds) -> 'HrefValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'HrefValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'HrefValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(HrefValue, self).__init__(value=value, condition=condition, **kwds) @@ -2940,6 +3923,65 @@ class Key(FieldChannelMixin, core.FieldDefWithoutScale): _class_is_valid_at_instantiation = False _encoding_name = "key" + @overload + def aggregate(self, _: str, **kwds) -> 'Key': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Key': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Key': + ... + + def bandPosition(self, _: float, **kwds) -> 'Key': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Key': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Key': + ... + + @overload + def bin(self, _: str, **kwds) -> 'Key': + ... + + @overload + def bin(self, _: type(None), **kwds) -> 'Key': + ... + + @overload + def field(self, _: str, **kwds) -> 'Key': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Key': + ... + + @overload + def timeUnit(self, **kwds) -> 'Key': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Key': + ... + + @overload + def title(self, **kwds) -> 'Key': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Key': + ... + + def type(self, _: str, **kwds) -> 'Key': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): super(Key, self).__init__(shorthand=shorthand, aggregate=aggregate, bandPosition=bandPosition, @@ -3108,6 +4150,52 @@ class Latitude(FieldChannelMixin, core.LatLongFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "latitude" + @overload + def aggregate(self, _: str, **kwds) -> 'Latitude': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Latitude': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Latitude': + ... + + def bandPosition(self, _: float, **kwds) -> 'Latitude': + ... + + def bin(self, _: type(None), **kwds) -> 'Latitude': + ... + + @overload + def field(self, _: str, **kwds) -> 'Latitude': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Latitude': + ... + + @overload + def timeUnit(self, **kwds) -> 'Latitude': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Latitude': + ... + + @overload + def title(self, **kwds) -> 'Latitude': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Latitude': + ... + + def type(self, _: str, **kwds) -> 'Latitude': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): super(Latitude, self).__init__(shorthand=shorthand, aggregate=aggregate, @@ -3223,6 +4311,22 @@ class LatitudeDatum(DatumChannelMixin, core.DatumDef): """ _class_is_valid_at_instantiation = False _encoding_name = "latitude" + + def bandPosition(self, _: float, **kwds) -> 'LatitudeDatum': + ... + + @overload + def title(self, **kwds) -> 'LatitudeDatum': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'LatitudeDatum': + ... + + def type(self, _: str, **kwds) -> 'LatitudeDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, title=Undefined, type=Undefined, **kwds): super(LatitudeDatum, self).__init__(datum=datum, bandPosition=bandPosition, title=title, type=type, **kwds) @@ -3322,6 +4426,49 @@ class Latitude2(FieldChannelMixin, core.SecondaryFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "latitude2" + @overload + def aggregate(self, _: str, **kwds) -> 'Latitude2': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Latitude2': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Latitude2': + ... + + def bandPosition(self, _: float, **kwds) -> 'Latitude2': + ... + + def bin(self, _: type(None), **kwds) -> 'Latitude2': + ... + + @overload + def field(self, _: str, **kwds) -> 'Latitude2': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Latitude2': + ... + + @overload + def timeUnit(self, **kwds) -> 'Latitude2': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Latitude2': + ... + + @overload + def title(self, **kwds) -> 'Latitude2': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Latitude2': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, timeUnit=Undefined, title=Undefined, **kwds): super(Latitude2, self).__init__(shorthand=shorthand, aggregate=aggregate, @@ -3437,6 +4584,22 @@ class Latitude2Datum(DatumChannelMixin, core.DatumDef): """ _class_is_valid_at_instantiation = False _encoding_name = "latitude2" + + def bandPosition(self, _: float, **kwds) -> 'Latitude2Datum': + ... + + @overload + def title(self, **kwds) -> 'Latitude2Datum': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Latitude2Datum': + ... + + def type(self, _: str, **kwds) -> 'Latitude2Datum': + ... + + def __init__(self, datum, bandPosition=Undefined, title=Undefined, type=Undefined, **kwds): super(Latitude2Datum, self).__init__(datum=datum, bandPosition=bandPosition, title=title, type=type, **kwds) @@ -3461,6 +4624,8 @@ class Latitude2Value(ValueChannelMixin, core.PositionValueDef): _class_is_valid_at_instantiation = False _encoding_name = "latitude2" + + def __init__(self, value, **kwds): super(Latitude2Value, self).__init__(value=value, **kwds) @@ -3626,6 +4791,52 @@ class Longitude(FieldChannelMixin, core.LatLongFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "longitude" + @overload + def aggregate(self, _: str, **kwds) -> 'Longitude': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Longitude': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Longitude': + ... + + def bandPosition(self, _: float, **kwds) -> 'Longitude': + ... + + def bin(self, _: type(None), **kwds) -> 'Longitude': + ... + + @overload + def field(self, _: str, **kwds) -> 'Longitude': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Longitude': + ... + + @overload + def timeUnit(self, **kwds) -> 'Longitude': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Longitude': + ... + + @overload + def title(self, **kwds) -> 'Longitude': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Longitude': + ... + + def type(self, _: str, **kwds) -> 'Longitude': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): super(Longitude, self).__init__(shorthand=shorthand, aggregate=aggregate, @@ -3741,6 +4952,22 @@ class LongitudeDatum(DatumChannelMixin, core.DatumDef): """ _class_is_valid_at_instantiation = False _encoding_name = "longitude" + + def bandPosition(self, _: float, **kwds) -> 'LongitudeDatum': + ... + + @overload + def title(self, **kwds) -> 'LongitudeDatum': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'LongitudeDatum': + ... + + def type(self, _: str, **kwds) -> 'LongitudeDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, title=Undefined, type=Undefined, **kwds): super(LongitudeDatum, self).__init__(datum=datum, bandPosition=bandPosition, title=title, type=type, **kwds) @@ -3840,6 +5067,49 @@ class Longitude2(FieldChannelMixin, core.SecondaryFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "longitude2" + @overload + def aggregate(self, _: str, **kwds) -> 'Longitude2': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Longitude2': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Longitude2': + ... + + def bandPosition(self, _: float, **kwds) -> 'Longitude2': + ... + + def bin(self, _: type(None), **kwds) -> 'Longitude2': + ... + + @overload + def field(self, _: str, **kwds) -> 'Longitude2': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Longitude2': + ... + + @overload + def timeUnit(self, **kwds) -> 'Longitude2': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Longitude2': + ... + + @overload + def title(self, **kwds) -> 'Longitude2': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Longitude2': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, timeUnit=Undefined, title=Undefined, **kwds): super(Longitude2, self).__init__(shorthand=shorthand, aggregate=aggregate, @@ -3955,6 +5225,22 @@ class Longitude2Datum(DatumChannelMixin, core.DatumDef): """ _class_is_valid_at_instantiation = False _encoding_name = "longitude2" + + def bandPosition(self, _: float, **kwds) -> 'Longitude2Datum': + ... + + @overload + def title(self, **kwds) -> 'Longitude2Datum': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Longitude2Datum': + ... + + def type(self, _: str, **kwds) -> 'Longitude2Datum': + ... + + def __init__(self, datum, bandPosition=Undefined, title=Undefined, type=Undefined, **kwds): super(Longitude2Datum, self).__init__(datum=datum, bandPosition=bandPosition, title=title, type=type, **kwds) @@ -3979,6 +5265,8 @@ class Longitude2Value(ValueChannelMixin, core.PositionValueDef): _class_is_valid_at_instantiation = False _encoding_name = "longitude2" + + def __init__(self, value, **kwds): super(Longitude2Value, self).__init__(value=value, **kwds) @@ -4214,6 +5502,105 @@ class Opacity(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldD _class_is_valid_at_instantiation = False _encoding_name = "opacity" + @overload + def aggregate(self, _: str, **kwds) -> 'Opacity': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Opacity': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Opacity': + ... + + def bandPosition(self, _: float, **kwds) -> 'Opacity': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Opacity': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Opacity': + ... + + @overload + def bin(self, _: type(None), **kwds) -> 'Opacity': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'Opacity': + ... + + @overload + def condition(self, _: list, **kwds) -> 'Opacity': + ... + + @overload + def field(self, _: str, **kwds) -> 'Opacity': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Opacity': + ... + + @overload + def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, columns=Undefined, cornerRadius=Undefined, description=Undefined, direction=Undefined, fillColor=Undefined, format=Undefined, formatType=Undefined, gradientLength=Undefined, gradientOpacity=Undefined, gradientStrokeColor=Undefined, gradientStrokeWidth=Undefined, gradientThickness=Undefined, gridAlign=Undefined, labelAlign=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, legendX=Undefined, legendY=Undefined, offset=Undefined, orient=Undefined, padding=Undefined, rowPadding=Undefined, strokeColor=Undefined, symbolDash=Undefined, symbolDashOffset=Undefined, symbolFillColor=Undefined, symbolLimit=Undefined, symbolOffset=Undefined, symbolOpacity=Undefined, symbolSize=Undefined, symbolStrokeColor=Undefined, symbolStrokeWidth=Undefined, symbolType=Undefined, tickCount=Undefined, tickMinStep=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titleOrient=Undefined, titlePadding=Undefined, type=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'Opacity': + ... + + @overload + def legend(self, _: type(None), **kwds) -> 'Opacity': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'Opacity': + ... + + @overload + def scale(self, _: type(None), **kwds) -> 'Opacity': + ... + + @overload + def sort(self, **kwds) -> 'Opacity': + ... + + @overload + def sort(self, **kwds) -> 'Opacity': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Opacity': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Opacity': + ... + + @overload + def sort(self, _: type(None), **kwds) -> 'Opacity': + ... + + @overload + def timeUnit(self, **kwds) -> 'Opacity': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Opacity': + ... + + @overload + def title(self, **kwds) -> 'Opacity': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Opacity': + ... + + def type(self, _: str, **kwds) -> 'Opacity': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, legend=Undefined, scale=Undefined, sort=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -4341,6 +5728,30 @@ class OpacityDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefn """ _class_is_valid_at_instantiation = False _encoding_name = "opacity" + + def bandPosition(self, _: float, **kwds) -> 'OpacityDatum': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'OpacityDatum': + ... + + @overload + def condition(self, _: list, **kwds) -> 'OpacityDatum': + ... + + @overload + def title(self, **kwds) -> 'OpacityDatum': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'OpacityDatum': + ... + + def type(self, _: str, **kwds) -> 'OpacityDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Undefined, type=Undefined, **kwds): super(OpacityDatum, self).__init__(datum=datum, bandPosition=bandPosition, condition=condition, @@ -4367,6 +5778,19 @@ class OpacityValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrD _class_is_valid_at_instantiation = False _encoding_name = "opacity" + @overload + def condition(self, **kwds) -> 'OpacityValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'OpacityValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'OpacityValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(OpacityValue, self).__init__(value=value, condition=condition, **kwds) @@ -4534,6 +5958,68 @@ class Order(FieldChannelMixin, core.OrderFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "order" + @overload + def aggregate(self, _: str, **kwds) -> 'Order': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Order': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Order': + ... + + def bandPosition(self, _: float, **kwds) -> 'Order': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Order': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Order': + ... + + @overload + def bin(self, _: str, **kwds) -> 'Order': + ... + + @overload + def bin(self, _: type(None), **kwds) -> 'Order': + ... + + @overload + def field(self, _: str, **kwds) -> 'Order': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Order': + ... + + def sort(self, _: str, **kwds) -> 'Order': + ... + + @overload + def timeUnit(self, **kwds) -> 'Order': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Order': + ... + + @overload + def title(self, **kwds) -> 'Order': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Order': + ... + + def type(self, _: str, **kwds) -> 'Order': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, sort=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -4567,6 +6053,15 @@ class OrderValue(ValueChannelMixin, core.OrderValueDef): _class_is_valid_at_instantiation = False _encoding_name = "order" + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'OrderValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'OrderValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(OrderValue, self).__init__(value=value, condition=condition, **kwds) @@ -4813,6 +6308,105 @@ class Radius(FieldChannelMixin, core.PositionFieldDefBase): _class_is_valid_at_instantiation = False _encoding_name = "radius" + @overload + def aggregate(self, _: str, **kwds) -> 'Radius': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Radius': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Radius': + ... + + def bandPosition(self, _: float, **kwds) -> 'Radius': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Radius': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Radius': + ... + + @overload + def bin(self, _: str, **kwds) -> 'Radius': + ... + + @overload + def bin(self, _: type(None), **kwds) -> 'Radius': + ... + + @overload + def field(self, _: str, **kwds) -> 'Radius': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Radius': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'Radius': + ... + + @overload + def scale(self, _: type(None), **kwds) -> 'Radius': + ... + + @overload + def sort(self, **kwds) -> 'Radius': + ... + + @overload + def sort(self, **kwds) -> 'Radius': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Radius': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Radius': + ... + + @overload + def sort(self, _: type(None), **kwds) -> 'Radius': + ... + + @overload + def stack(self, _: str, **kwds) -> 'Radius': + ... + + @overload + def stack(self, _: type(None), **kwds) -> 'Radius': + ... + + @overload + def stack(self, _: bool, **kwds) -> 'Radius': + ... + + @overload + def timeUnit(self, **kwds) -> 'Radius': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Radius': + ... + + @overload + def title(self, **kwds) -> 'Radius': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Radius': + ... + + def type(self, _: str, **kwds) -> 'Radius': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, scale=Undefined, sort=Undefined, stack=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -4973,6 +6567,42 @@ class RadiusDatum(DatumChannelMixin, core.PositionDatumDefBase): """ _class_is_valid_at_instantiation = False _encoding_name = "radius" + + def bandPosition(self, _: float, **kwds) -> 'RadiusDatum': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'RadiusDatum': + ... + + @overload + def scale(self, _: type(None), **kwds) -> 'RadiusDatum': + ... + + @overload + def stack(self, _: str, **kwds) -> 'RadiusDatum': + ... + + @overload + def stack(self, _: type(None), **kwds) -> 'RadiusDatum': + ... + + @overload + def stack(self, _: bool, **kwds) -> 'RadiusDatum': + ... + + @overload + def title(self, **kwds) -> 'RadiusDatum': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'RadiusDatum': + ... + + def type(self, _: str, **kwds) -> 'RadiusDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, scale=Undefined, stack=Undefined, title=Undefined, type=Undefined, **kwds): super(RadiusDatum, self).__init__(datum=datum, bandPosition=bandPosition, scale=scale, @@ -4998,6 +6628,8 @@ class RadiusValue(ValueChannelMixin, core.PositionValueDef): _class_is_valid_at_instantiation = False _encoding_name = "radius" + + def __init__(self, value, **kwds): super(RadiusValue, self).__init__(value=value, **kwds) @@ -5096,6 +6728,49 @@ class Radius2(FieldChannelMixin, core.SecondaryFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "radius2" + @overload + def aggregate(self, _: str, **kwds) -> 'Radius2': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Radius2': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Radius2': + ... + + def bandPosition(self, _: float, **kwds) -> 'Radius2': + ... + + def bin(self, _: type(None), **kwds) -> 'Radius2': + ... + + @overload + def field(self, _: str, **kwds) -> 'Radius2': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Radius2': + ... + + @overload + def timeUnit(self, **kwds) -> 'Radius2': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Radius2': + ... + + @overload + def title(self, **kwds) -> 'Radius2': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Radius2': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, timeUnit=Undefined, title=Undefined, **kwds): super(Radius2, self).__init__(shorthand=shorthand, aggregate=aggregate, @@ -5211,6 +6886,22 @@ class Radius2Datum(DatumChannelMixin, core.DatumDef): """ _class_is_valid_at_instantiation = False _encoding_name = "radius2" + + def bandPosition(self, _: float, **kwds) -> 'Radius2Datum': + ... + + @overload + def title(self, **kwds) -> 'Radius2Datum': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Radius2Datum': + ... + + def type(self, _: str, **kwds) -> 'Radius2Datum': + ... + + def __init__(self, datum, bandPosition=Undefined, title=Undefined, type=Undefined, **kwds): super(Radius2Datum, self).__init__(datum=datum, bandPosition=bandPosition, title=title, type=type, **kwds) @@ -5235,6 +6926,8 @@ class Radius2Value(ValueChannelMixin, core.PositionValueDef): _class_is_valid_at_instantiation = False _encoding_name = "radius2" + + def __init__(self, value, **kwds): super(Radius2Value, self).__init__(value=value, **kwds) @@ -5453,6 +7146,94 @@ class Row(FieldChannelMixin, core.RowColumnEncodingFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "row" + @overload + def aggregate(self, _: str, **kwds) -> 'Row': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Row': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Row': + ... + + def align(self, _: str, **kwds) -> 'Row': + ... + + def bandPosition(self, _: float, **kwds) -> 'Row': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Row': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Row': + ... + + @overload + def bin(self, _: type(None), **kwds) -> 'Row': + ... + + def center(self, _: bool, **kwds) -> 'Row': + ... + + @overload + def field(self, _: str, **kwds) -> 'Row': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Row': + ... + + @overload + def header(self, format=Undefined, formatType=Undefined, labelAlign=Undefined, labelAnchor=Undefined, labelAngle=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelLineHeight=Undefined, labelOrient=Undefined, labelPadding=Undefined, labels=Undefined, orient=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleAngle=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOrient=Undefined, titlePadding=Undefined, **kwds) -> 'Row': + ... + + @overload + def header(self, _: type(None), **kwds) -> 'Row': + ... + + @overload + def sort(self, **kwds) -> 'Row': + ... + + @overload + def sort(self, _: str, **kwds) -> 'Row': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Row': + ... + + @overload + def sort(self, _: type(None), **kwds) -> 'Row': + ... + + def spacing(self, _: float, **kwds) -> 'Row': + ... + + @overload + def timeUnit(self, **kwds) -> 'Row': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Row': + ... + + @overload + def title(self, **kwds) -> 'Row': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Row': + ... + + def type(self, _: str, **kwds) -> 'Row': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, align=Undefined, bandPosition=Undefined, bin=Undefined, center=Undefined, field=Undefined, header=Undefined, sort=Undefined, spacing=Undefined, timeUnit=Undefined, @@ -5694,6 +7475,105 @@ class Shape(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDef _class_is_valid_at_instantiation = False _encoding_name = "shape" + @overload + def aggregate(self, _: str, **kwds) -> 'Shape': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Shape': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Shape': + ... + + def bandPosition(self, _: float, **kwds) -> 'Shape': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Shape': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Shape': + ... + + @overload + def bin(self, _: type(None), **kwds) -> 'Shape': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'Shape': + ... + + @overload + def condition(self, _: list, **kwds) -> 'Shape': + ... + + @overload + def field(self, _: str, **kwds) -> 'Shape': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Shape': + ... + + @overload + def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, columns=Undefined, cornerRadius=Undefined, description=Undefined, direction=Undefined, fillColor=Undefined, format=Undefined, formatType=Undefined, gradientLength=Undefined, gradientOpacity=Undefined, gradientStrokeColor=Undefined, gradientStrokeWidth=Undefined, gradientThickness=Undefined, gridAlign=Undefined, labelAlign=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, legendX=Undefined, legendY=Undefined, offset=Undefined, orient=Undefined, padding=Undefined, rowPadding=Undefined, strokeColor=Undefined, symbolDash=Undefined, symbolDashOffset=Undefined, symbolFillColor=Undefined, symbolLimit=Undefined, symbolOffset=Undefined, symbolOpacity=Undefined, symbolSize=Undefined, symbolStrokeColor=Undefined, symbolStrokeWidth=Undefined, symbolType=Undefined, tickCount=Undefined, tickMinStep=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titleOrient=Undefined, titlePadding=Undefined, type=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'Shape': + ... + + @overload + def legend(self, _: type(None), **kwds) -> 'Shape': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'Shape': + ... + + @overload + def scale(self, _: type(None), **kwds) -> 'Shape': + ... + + @overload + def sort(self, **kwds) -> 'Shape': + ... + + @overload + def sort(self, **kwds) -> 'Shape': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Shape': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Shape': + ... + + @overload + def sort(self, _: type(None), **kwds) -> 'Shape': + ... + + @overload + def timeUnit(self, **kwds) -> 'Shape': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Shape': + ... + + @overload + def title(self, **kwds) -> 'Shape': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Shape': + ... + + def type(self, _: str, **kwds) -> 'Shape': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, legend=Undefined, scale=Undefined, sort=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -5821,6 +7701,30 @@ class ShapeDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefstr """ _class_is_valid_at_instantiation = False _encoding_name = "shape" + + def bandPosition(self, _: float, **kwds) -> 'ShapeDatum': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'ShapeDatum': + ... + + @overload + def condition(self, _: list, **kwds) -> 'ShapeDatum': + ... + + @overload + def title(self, **kwds) -> 'ShapeDatum': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'ShapeDatum': + ... + + def type(self, _: str, **kwds) -> 'ShapeDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Undefined, type=Undefined, **kwds): super(ShapeDatum, self).__init__(datum=datum, bandPosition=bandPosition, condition=condition, @@ -5848,6 +7752,19 @@ class ShapeValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDat _class_is_valid_at_instantiation = False _encoding_name = "shape" + @overload + def condition(self, **kwds) -> 'ShapeValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'ShapeValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'ShapeValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(ShapeValue, self).__init__(value=value, condition=condition, **kwds) @@ -6083,6 +8000,105 @@ class Size(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDefn _class_is_valid_at_instantiation = False _encoding_name = "size" + @overload + def aggregate(self, _: str, **kwds) -> 'Size': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Size': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Size': + ... + + def bandPosition(self, _: float, **kwds) -> 'Size': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Size': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Size': + ... + + @overload + def bin(self, _: type(None), **kwds) -> 'Size': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'Size': + ... + + @overload + def condition(self, _: list, **kwds) -> 'Size': + ... + + @overload + def field(self, _: str, **kwds) -> 'Size': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Size': + ... + + @overload + def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, columns=Undefined, cornerRadius=Undefined, description=Undefined, direction=Undefined, fillColor=Undefined, format=Undefined, formatType=Undefined, gradientLength=Undefined, gradientOpacity=Undefined, gradientStrokeColor=Undefined, gradientStrokeWidth=Undefined, gradientThickness=Undefined, gridAlign=Undefined, labelAlign=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, legendX=Undefined, legendY=Undefined, offset=Undefined, orient=Undefined, padding=Undefined, rowPadding=Undefined, strokeColor=Undefined, symbolDash=Undefined, symbolDashOffset=Undefined, symbolFillColor=Undefined, symbolLimit=Undefined, symbolOffset=Undefined, symbolOpacity=Undefined, symbolSize=Undefined, symbolStrokeColor=Undefined, symbolStrokeWidth=Undefined, symbolType=Undefined, tickCount=Undefined, tickMinStep=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titleOrient=Undefined, titlePadding=Undefined, type=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'Size': + ... + + @overload + def legend(self, _: type(None), **kwds) -> 'Size': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'Size': + ... + + @overload + def scale(self, _: type(None), **kwds) -> 'Size': + ... + + @overload + def sort(self, **kwds) -> 'Size': + ... + + @overload + def sort(self, **kwds) -> 'Size': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Size': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Size': + ... + + @overload + def sort(self, _: type(None), **kwds) -> 'Size': + ... + + @overload + def timeUnit(self, **kwds) -> 'Size': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Size': + ... + + @overload + def title(self, **kwds) -> 'Size': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Size': + ... + + def type(self, _: str, **kwds) -> 'Size': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, legend=Undefined, scale=Undefined, sort=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -6210,6 +8226,30 @@ class SizeDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefnumb """ _class_is_valid_at_instantiation = False _encoding_name = "size" + + def bandPosition(self, _: float, **kwds) -> 'SizeDatum': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'SizeDatum': + ... + + @overload + def condition(self, _: list, **kwds) -> 'SizeDatum': + ... + + @overload + def title(self, **kwds) -> 'SizeDatum': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'SizeDatum': + ... + + def type(self, _: str, **kwds) -> 'SizeDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Undefined, type=Undefined, **kwds): super(SizeDatum, self).__init__(datum=datum, bandPosition=bandPosition, condition=condition, @@ -6236,6 +8276,19 @@ class SizeValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDatu _class_is_valid_at_instantiation = False _encoding_name = "size" + @overload + def condition(self, **kwds) -> 'SizeValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'SizeValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'SizeValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(SizeValue, self).__init__(value=value, condition=condition, **kwds) @@ -6471,6 +8524,105 @@ class Stroke(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDe _class_is_valid_at_instantiation = False _encoding_name = "stroke" + @overload + def aggregate(self, _: str, **kwds) -> 'Stroke': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Stroke': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Stroke': + ... + + def bandPosition(self, _: float, **kwds) -> 'Stroke': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Stroke': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Stroke': + ... + + @overload + def bin(self, _: type(None), **kwds) -> 'Stroke': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'Stroke': + ... + + @overload + def condition(self, _: list, **kwds) -> 'Stroke': + ... + + @overload + def field(self, _: str, **kwds) -> 'Stroke': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Stroke': + ... + + @overload + def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, columns=Undefined, cornerRadius=Undefined, description=Undefined, direction=Undefined, fillColor=Undefined, format=Undefined, formatType=Undefined, gradientLength=Undefined, gradientOpacity=Undefined, gradientStrokeColor=Undefined, gradientStrokeWidth=Undefined, gradientThickness=Undefined, gridAlign=Undefined, labelAlign=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, legendX=Undefined, legendY=Undefined, offset=Undefined, orient=Undefined, padding=Undefined, rowPadding=Undefined, strokeColor=Undefined, symbolDash=Undefined, symbolDashOffset=Undefined, symbolFillColor=Undefined, symbolLimit=Undefined, symbolOffset=Undefined, symbolOpacity=Undefined, symbolSize=Undefined, symbolStrokeColor=Undefined, symbolStrokeWidth=Undefined, symbolType=Undefined, tickCount=Undefined, tickMinStep=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titleOrient=Undefined, titlePadding=Undefined, type=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'Stroke': + ... + + @overload + def legend(self, _: type(None), **kwds) -> 'Stroke': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'Stroke': + ... + + @overload + def scale(self, _: type(None), **kwds) -> 'Stroke': + ... + + @overload + def sort(self, **kwds) -> 'Stroke': + ... + + @overload + def sort(self, **kwds) -> 'Stroke': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Stroke': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Stroke': + ... + + @overload + def sort(self, _: type(None), **kwds) -> 'Stroke': + ... + + @overload + def timeUnit(self, **kwds) -> 'Stroke': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Stroke': + ... + + @overload + def title(self, **kwds) -> 'Stroke': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Stroke': + ... + + def type(self, _: str, **kwds) -> 'Stroke': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, legend=Undefined, scale=Undefined, sort=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -6598,6 +8750,30 @@ class StrokeDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefGr """ _class_is_valid_at_instantiation = False _encoding_name = "stroke" + + def bandPosition(self, _: float, **kwds) -> 'StrokeDatum': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'StrokeDatum': + ... + + @overload + def condition(self, _: list, **kwds) -> 'StrokeDatum': + ... + + @overload + def title(self, **kwds) -> 'StrokeDatum': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'StrokeDatum': + ... + + def type(self, _: str, **kwds) -> 'StrokeDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Undefined, type=Undefined, **kwds): super(StrokeDatum, self).__init__(datum=datum, bandPosition=bandPosition, condition=condition, @@ -6625,6 +8801,19 @@ class StrokeValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDa _class_is_valid_at_instantiation = False _encoding_name = "stroke" + @overload + def condition(self, **kwds) -> 'StrokeValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'StrokeValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'StrokeValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(StrokeValue, self).__init__(value=value, condition=condition, **kwds) @@ -6860,6 +9049,105 @@ class StrokeDash(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFie _class_is_valid_at_instantiation = False _encoding_name = "strokeDash" + @overload + def aggregate(self, _: str, **kwds) -> 'StrokeDash': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'StrokeDash': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'StrokeDash': + ... + + def bandPosition(self, _: float, **kwds) -> 'StrokeDash': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'StrokeDash': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'StrokeDash': + ... + + @overload + def bin(self, _: type(None), **kwds) -> 'StrokeDash': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'StrokeDash': + ... + + @overload + def condition(self, _: list, **kwds) -> 'StrokeDash': + ... + + @overload + def field(self, _: str, **kwds) -> 'StrokeDash': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'StrokeDash': + ... + + @overload + def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, columns=Undefined, cornerRadius=Undefined, description=Undefined, direction=Undefined, fillColor=Undefined, format=Undefined, formatType=Undefined, gradientLength=Undefined, gradientOpacity=Undefined, gradientStrokeColor=Undefined, gradientStrokeWidth=Undefined, gradientThickness=Undefined, gridAlign=Undefined, labelAlign=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, legendX=Undefined, legendY=Undefined, offset=Undefined, orient=Undefined, padding=Undefined, rowPadding=Undefined, strokeColor=Undefined, symbolDash=Undefined, symbolDashOffset=Undefined, symbolFillColor=Undefined, symbolLimit=Undefined, symbolOffset=Undefined, symbolOpacity=Undefined, symbolSize=Undefined, symbolStrokeColor=Undefined, symbolStrokeWidth=Undefined, symbolType=Undefined, tickCount=Undefined, tickMinStep=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titleOrient=Undefined, titlePadding=Undefined, type=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'StrokeDash': + ... + + @overload + def legend(self, _: type(None), **kwds) -> 'StrokeDash': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'StrokeDash': + ... + + @overload + def scale(self, _: type(None), **kwds) -> 'StrokeDash': + ... + + @overload + def sort(self, **kwds) -> 'StrokeDash': + ... + + @overload + def sort(self, **kwds) -> 'StrokeDash': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'StrokeDash': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'StrokeDash': + ... + + @overload + def sort(self, _: type(None), **kwds) -> 'StrokeDash': + ... + + @overload + def timeUnit(self, **kwds) -> 'StrokeDash': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'StrokeDash': + ... + + @overload + def title(self, **kwds) -> 'StrokeDash': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'StrokeDash': + ... + + def type(self, _: str, **kwds) -> 'StrokeDash': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, legend=Undefined, scale=Undefined, sort=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -6987,6 +9275,30 @@ class StrokeDashDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumD """ _class_is_valid_at_instantiation = False _encoding_name = "strokeDash" + + def bandPosition(self, _: float, **kwds) -> 'StrokeDashDatum': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'StrokeDashDatum': + ... + + @overload + def condition(self, _: list, **kwds) -> 'StrokeDashDatum': + ... + + @overload + def title(self, **kwds) -> 'StrokeDashDatum': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'StrokeDashDatum': + ... + + def type(self, _: str, **kwds) -> 'StrokeDashDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Undefined, type=Undefined, **kwds): super(StrokeDashDatum, self).__init__(datum=datum, bandPosition=bandPosition, @@ -7014,6 +9326,19 @@ class StrokeDashValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropField _class_is_valid_at_instantiation = False _encoding_name = "strokeDash" + @overload + def condition(self, **kwds) -> 'StrokeDashValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'StrokeDashValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'StrokeDashValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(StrokeDashValue, self).__init__(value=value, condition=condition, **kwds) @@ -7249,6 +9574,105 @@ class StrokeOpacity(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkProp _class_is_valid_at_instantiation = False _encoding_name = "strokeOpacity" + @overload + def aggregate(self, _: str, **kwds) -> 'StrokeOpacity': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'StrokeOpacity': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'StrokeOpacity': + ... + + def bandPosition(self, _: float, **kwds) -> 'StrokeOpacity': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'StrokeOpacity': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'StrokeOpacity': + ... + + @overload + def bin(self, _: type(None), **kwds) -> 'StrokeOpacity': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'StrokeOpacity': + ... + + @overload + def condition(self, _: list, **kwds) -> 'StrokeOpacity': + ... + + @overload + def field(self, _: str, **kwds) -> 'StrokeOpacity': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'StrokeOpacity': + ... + + @overload + def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, columns=Undefined, cornerRadius=Undefined, description=Undefined, direction=Undefined, fillColor=Undefined, format=Undefined, formatType=Undefined, gradientLength=Undefined, gradientOpacity=Undefined, gradientStrokeColor=Undefined, gradientStrokeWidth=Undefined, gradientThickness=Undefined, gridAlign=Undefined, labelAlign=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, legendX=Undefined, legendY=Undefined, offset=Undefined, orient=Undefined, padding=Undefined, rowPadding=Undefined, strokeColor=Undefined, symbolDash=Undefined, symbolDashOffset=Undefined, symbolFillColor=Undefined, symbolLimit=Undefined, symbolOffset=Undefined, symbolOpacity=Undefined, symbolSize=Undefined, symbolStrokeColor=Undefined, symbolStrokeWidth=Undefined, symbolType=Undefined, tickCount=Undefined, tickMinStep=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titleOrient=Undefined, titlePadding=Undefined, type=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'StrokeOpacity': + ... + + @overload + def legend(self, _: type(None), **kwds) -> 'StrokeOpacity': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'StrokeOpacity': + ... + + @overload + def scale(self, _: type(None), **kwds) -> 'StrokeOpacity': + ... + + @overload + def sort(self, **kwds) -> 'StrokeOpacity': + ... + + @overload + def sort(self, **kwds) -> 'StrokeOpacity': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'StrokeOpacity': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'StrokeOpacity': + ... + + @overload + def sort(self, _: type(None), **kwds) -> 'StrokeOpacity': + ... + + @overload + def timeUnit(self, **kwds) -> 'StrokeOpacity': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'StrokeOpacity': + ... + + @overload + def title(self, **kwds) -> 'StrokeOpacity': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'StrokeOpacity': + ... + + def type(self, _: str, **kwds) -> 'StrokeOpacity': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, legend=Undefined, scale=Undefined, sort=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -7376,6 +9800,30 @@ class StrokeOpacityDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDat """ _class_is_valid_at_instantiation = False _encoding_name = "strokeOpacity" + + def bandPosition(self, _: float, **kwds) -> 'StrokeOpacityDatum': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'StrokeOpacityDatum': + ... + + @overload + def condition(self, _: list, **kwds) -> 'StrokeOpacityDatum': + ... + + @overload + def title(self, **kwds) -> 'StrokeOpacityDatum': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'StrokeOpacityDatum': + ... + + def type(self, _: str, **kwds) -> 'StrokeOpacityDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Undefined, type=Undefined, **kwds): super(StrokeOpacityDatum, self).__init__(datum=datum, bandPosition=bandPosition, @@ -7402,6 +9850,19 @@ class StrokeOpacityValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFi _class_is_valid_at_instantiation = False _encoding_name = "strokeOpacity" + @overload + def condition(self, **kwds) -> 'StrokeOpacityValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'StrokeOpacityValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'StrokeOpacityValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(StrokeOpacityValue, self).__init__(value=value, condition=condition, **kwds) @@ -7637,6 +10098,105 @@ class StrokeWidth(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFi _class_is_valid_at_instantiation = False _encoding_name = "strokeWidth" + @overload + def aggregate(self, _: str, **kwds) -> 'StrokeWidth': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'StrokeWidth': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'StrokeWidth': + ... + + def bandPosition(self, _: float, **kwds) -> 'StrokeWidth': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'StrokeWidth': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'StrokeWidth': + ... + + @overload + def bin(self, _: type(None), **kwds) -> 'StrokeWidth': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'StrokeWidth': + ... + + @overload + def condition(self, _: list, **kwds) -> 'StrokeWidth': + ... + + @overload + def field(self, _: str, **kwds) -> 'StrokeWidth': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'StrokeWidth': + ... + + @overload + def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, columns=Undefined, cornerRadius=Undefined, description=Undefined, direction=Undefined, fillColor=Undefined, format=Undefined, formatType=Undefined, gradientLength=Undefined, gradientOpacity=Undefined, gradientStrokeColor=Undefined, gradientStrokeWidth=Undefined, gradientThickness=Undefined, gridAlign=Undefined, labelAlign=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, legendX=Undefined, legendY=Undefined, offset=Undefined, orient=Undefined, padding=Undefined, rowPadding=Undefined, strokeColor=Undefined, symbolDash=Undefined, symbolDashOffset=Undefined, symbolFillColor=Undefined, symbolLimit=Undefined, symbolOffset=Undefined, symbolOpacity=Undefined, symbolSize=Undefined, symbolStrokeColor=Undefined, symbolStrokeWidth=Undefined, symbolType=Undefined, tickCount=Undefined, tickMinStep=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titleOrient=Undefined, titlePadding=Undefined, type=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'StrokeWidth': + ... + + @overload + def legend(self, _: type(None), **kwds) -> 'StrokeWidth': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'StrokeWidth': + ... + + @overload + def scale(self, _: type(None), **kwds) -> 'StrokeWidth': + ... + + @overload + def sort(self, **kwds) -> 'StrokeWidth': + ... + + @overload + def sort(self, **kwds) -> 'StrokeWidth': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'StrokeWidth': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'StrokeWidth': + ... + + @overload + def sort(self, _: type(None), **kwds) -> 'StrokeWidth': + ... + + @overload + def timeUnit(self, **kwds) -> 'StrokeWidth': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'StrokeWidth': + ... + + @overload + def title(self, **kwds) -> 'StrokeWidth': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'StrokeWidth': + ... + + def type(self, _: str, **kwds) -> 'StrokeWidth': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, legend=Undefined, scale=Undefined, sort=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -7764,6 +10324,30 @@ class StrokeWidthDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatum """ _class_is_valid_at_instantiation = False _encoding_name = "strokeWidth" + + def bandPosition(self, _: float, **kwds) -> 'StrokeWidthDatum': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'StrokeWidthDatum': + ... + + @overload + def condition(self, _: list, **kwds) -> 'StrokeWidthDatum': + ... + + @overload + def title(self, **kwds) -> 'StrokeWidthDatum': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'StrokeWidthDatum': + ... + + def type(self, _: str, **kwds) -> 'StrokeWidthDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Undefined, type=Undefined, **kwds): super(StrokeWidthDatum, self).__init__(datum=datum, bandPosition=bandPosition, @@ -7790,6 +10374,19 @@ class StrokeWidthValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFiel _class_is_valid_at_instantiation = False _encoding_name = "strokeWidth" + @overload + def condition(self, **kwds) -> 'StrokeWidthValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'StrokeWidthValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'StrokeWidthValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(StrokeWidthValue, self).__init__(value=value, condition=condition, **kwds) @@ -7999,6 +10596,84 @@ class Text(FieldChannelMixin, core.FieldOrDatumDefWithConditionStringFieldDefTex _class_is_valid_at_instantiation = False _encoding_name = "text" + @overload + def aggregate(self, _: str, **kwds) -> 'Text': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Text': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Text': + ... + + def bandPosition(self, _: float, **kwds) -> 'Text': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Text': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Text': + ... + + @overload + def bin(self, _: str, **kwds) -> 'Text': + ... + + @overload + def bin(self, _: type(None), **kwds) -> 'Text': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'Text': + ... + + @overload + def condition(self, _: list, **kwds) -> 'Text': + ... + + @overload + def field(self, _: str, **kwds) -> 'Text': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Text': + ... + + @overload + def format(self, _: str, **kwds) -> 'Text': + ... + + @overload + def format(self, _: dict, **kwds) -> 'Text': + ... + + def formatType(self, _: str, **kwds) -> 'Text': + ... + + @overload + def timeUnit(self, **kwds) -> 'Text': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Text': + ... + + @overload + def title(self, **kwds) -> 'Text': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Text': + ... + + def type(self, _: str, **kwds) -> 'Text': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, format=Undefined, formatType=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -8160,6 +10835,41 @@ class TextDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionStringDatumD """ _class_is_valid_at_instantiation = False _encoding_name = "text" + + def bandPosition(self, _: float, **kwds) -> 'TextDatum': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'TextDatum': + ... + + @overload + def condition(self, _: list, **kwds) -> 'TextDatum': + ... + + @overload + def format(self, _: str, **kwds) -> 'TextDatum': + ... + + @overload + def format(self, _: dict, **kwds) -> 'TextDatum': + ... + + def formatType(self, _: str, **kwds) -> 'TextDatum': + ... + + @overload + def title(self, **kwds) -> 'TextDatum': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'TextDatum': + ... + + def type(self, _: str, **kwds) -> 'TextDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, condition=Undefined, format=Undefined, formatType=Undefined, title=Undefined, type=Undefined, **kwds): super(TextDatum, self).__init__(datum=datum, bandPosition=bandPosition, condition=condition, @@ -8187,6 +10897,19 @@ class TextValue(ValueChannelMixin, core.ValueDefWithConditionStringFieldDefText) _class_is_valid_at_instantiation = False _encoding_name = "text" + @overload + def condition(self, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, empty=Undefined, field=Undefined, format=Undefined, formatType=Undefined, param=Undefined, test=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds) -> 'TextValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'TextValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'TextValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(TextValue, self).__init__(value=value, condition=condition, **kwds) @@ -8433,6 +11156,105 @@ class Theta(FieldChannelMixin, core.PositionFieldDefBase): _class_is_valid_at_instantiation = False _encoding_name = "theta" + @overload + def aggregate(self, _: str, **kwds) -> 'Theta': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Theta': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Theta': + ... + + def bandPosition(self, _: float, **kwds) -> 'Theta': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Theta': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Theta': + ... + + @overload + def bin(self, _: str, **kwds) -> 'Theta': + ... + + @overload + def bin(self, _: type(None), **kwds) -> 'Theta': + ... + + @overload + def field(self, _: str, **kwds) -> 'Theta': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Theta': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'Theta': + ... + + @overload + def scale(self, _: type(None), **kwds) -> 'Theta': + ... + + @overload + def sort(self, **kwds) -> 'Theta': + ... + + @overload + def sort(self, **kwds) -> 'Theta': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Theta': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Theta': + ... + + @overload + def sort(self, _: type(None), **kwds) -> 'Theta': + ... + + @overload + def stack(self, _: str, **kwds) -> 'Theta': + ... + + @overload + def stack(self, _: type(None), **kwds) -> 'Theta': + ... + + @overload + def stack(self, _: bool, **kwds) -> 'Theta': + ... + + @overload + def timeUnit(self, **kwds) -> 'Theta': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Theta': + ... + + @overload + def title(self, **kwds) -> 'Theta': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Theta': + ... + + def type(self, _: str, **kwds) -> 'Theta': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, scale=Undefined, sort=Undefined, stack=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -8592,6 +11414,42 @@ class ThetaDatum(DatumChannelMixin, core.PositionDatumDefBase): """ _class_is_valid_at_instantiation = False _encoding_name = "theta" + + def bandPosition(self, _: float, **kwds) -> 'ThetaDatum': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'ThetaDatum': + ... + + @overload + def scale(self, _: type(None), **kwds) -> 'ThetaDatum': + ... + + @overload + def stack(self, _: str, **kwds) -> 'ThetaDatum': + ... + + @overload + def stack(self, _: type(None), **kwds) -> 'ThetaDatum': + ... + + @overload + def stack(self, _: bool, **kwds) -> 'ThetaDatum': + ... + + @overload + def title(self, **kwds) -> 'ThetaDatum': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'ThetaDatum': + ... + + def type(self, _: str, **kwds) -> 'ThetaDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, scale=Undefined, stack=Undefined, title=Undefined, type=Undefined, **kwds): super(ThetaDatum, self).__init__(datum=datum, bandPosition=bandPosition, scale=scale, @@ -8617,6 +11475,8 @@ class ThetaValue(ValueChannelMixin, core.PositionValueDef): _class_is_valid_at_instantiation = False _encoding_name = "theta" + + def __init__(self, value, **kwds): super(ThetaValue, self).__init__(value=value, **kwds) @@ -8715,6 +11575,49 @@ class Theta2(FieldChannelMixin, core.SecondaryFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "theta2" + @overload + def aggregate(self, _: str, **kwds) -> 'Theta2': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Theta2': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Theta2': + ... + + def bandPosition(self, _: float, **kwds) -> 'Theta2': + ... + + def bin(self, _: type(None), **kwds) -> 'Theta2': + ... + + @overload + def field(self, _: str, **kwds) -> 'Theta2': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Theta2': + ... + + @overload + def timeUnit(self, **kwds) -> 'Theta2': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Theta2': + ... + + @overload + def title(self, **kwds) -> 'Theta2': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Theta2': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, timeUnit=Undefined, title=Undefined, **kwds): super(Theta2, self).__init__(shorthand=shorthand, aggregate=aggregate, @@ -8830,6 +11733,22 @@ class Theta2Datum(DatumChannelMixin, core.DatumDef): """ _class_is_valid_at_instantiation = False _encoding_name = "theta2" + + def bandPosition(self, _: float, **kwds) -> 'Theta2Datum': + ... + + @overload + def title(self, **kwds) -> 'Theta2Datum': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Theta2Datum': + ... + + def type(self, _: str, **kwds) -> 'Theta2Datum': + ... + + def __init__(self, datum, bandPosition=Undefined, title=Undefined, type=Undefined, **kwds): super(Theta2Datum, self).__init__(datum=datum, bandPosition=bandPosition, title=title, type=type, **kwds) @@ -8854,6 +11773,8 @@ class Theta2Value(ValueChannelMixin, core.PositionValueDef): _class_is_valid_at_instantiation = False _encoding_name = "theta2" + + def __init__(self, value, **kwds): super(Theta2Value, self).__init__(value=value, **kwds) @@ -9063,6 +11984,84 @@ class Tooltip(FieldChannelMixin, core.StringFieldDefWithCondition): _class_is_valid_at_instantiation = False _encoding_name = "tooltip" + @overload + def aggregate(self, _: str, **kwds) -> 'Tooltip': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Tooltip': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Tooltip': + ... + + def bandPosition(self, _: float, **kwds) -> 'Tooltip': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Tooltip': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Tooltip': + ... + + @overload + def bin(self, _: str, **kwds) -> 'Tooltip': + ... + + @overload + def bin(self, _: type(None), **kwds) -> 'Tooltip': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'Tooltip': + ... + + @overload + def condition(self, _: list, **kwds) -> 'Tooltip': + ... + + @overload + def field(self, _: str, **kwds) -> 'Tooltip': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Tooltip': + ... + + @overload + def format(self, _: str, **kwds) -> 'Tooltip': + ... + + @overload + def format(self, _: dict, **kwds) -> 'Tooltip': + ... + + def formatType(self, _: str, **kwds) -> 'Tooltip': + ... + + @overload + def timeUnit(self, **kwds) -> 'Tooltip': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Tooltip': + ... + + @overload + def title(self, **kwds) -> 'Tooltip': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Tooltip': + ... + + def type(self, _: str, **kwds) -> 'Tooltip': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, format=Undefined, formatType=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -9093,6 +12092,19 @@ class TooltipValue(ValueChannelMixin, core.StringValueDefWithCondition): _class_is_valid_at_instantiation = False _encoding_name = "tooltip" + @overload + def condition(self, **kwds) -> 'TooltipValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'TooltipValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'TooltipValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(TooltipValue, self).__init__(value=value, condition=condition, **kwds) @@ -9296,11 +12308,89 @@ class Url(FieldChannelMixin, core.StringFieldDefWithCondition): ``type`` as they must have exactly the same type as their primary channels (e.g., ``x``, ``y`` ). - **See also:** `type `__ - documentation. - """ - _class_is_valid_at_instantiation = False - _encoding_name = "url" + **See also:** `type `__ + documentation. + """ + _class_is_valid_at_instantiation = False + _encoding_name = "url" + + @overload + def aggregate(self, _: str, **kwds) -> 'Url': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Url': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Url': + ... + + def bandPosition(self, _: float, **kwds) -> 'Url': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Url': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Url': + ... + + @overload + def bin(self, _: str, **kwds) -> 'Url': + ... + + @overload + def bin(self, _: type(None), **kwds) -> 'Url': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'Url': + ... + + @overload + def condition(self, _: list, **kwds) -> 'Url': + ... + + @overload + def field(self, _: str, **kwds) -> 'Url': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Url': + ... + + @overload + def format(self, _: str, **kwds) -> 'Url': + ... + + @overload + def format(self, _: dict, **kwds) -> 'Url': + ... + + def formatType(self, _: str, **kwds) -> 'Url': + ... + + @overload + def timeUnit(self, **kwds) -> 'Url': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Url': + ... + + @overload + def title(self, **kwds) -> 'Url': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Url': + ... + + def type(self, _: str, **kwds) -> 'Url': + ... + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, format=Undefined, formatType=Undefined, @@ -9332,6 +12422,19 @@ class UrlValue(ValueChannelMixin, core.StringValueDefWithCondition): _class_is_valid_at_instantiation = False _encoding_name = "url" + @overload + def condition(self, **kwds) -> 'UrlValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'UrlValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'UrlValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(UrlValue, self).__init__(value=value, condition=condition, **kwds) @@ -9595,6 +12698,121 @@ class X(FieldChannelMixin, core.PositionFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "x" + @overload + def aggregate(self, _: str, **kwds) -> 'X': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'X': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'X': + ... + + @overload + def axis(self, aria=Undefined, bandPosition=Undefined, description=Undefined, domain=Undefined, domainCap=Undefined, domainColor=Undefined, domainDash=Undefined, domainDashOffset=Undefined, domainOpacity=Undefined, domainWidth=Undefined, format=Undefined, formatType=Undefined, grid=Undefined, gridCap=Undefined, gridColor=Undefined, gridDash=Undefined, gridDashOffset=Undefined, gridOpacity=Undefined, gridWidth=Undefined, labelAlign=Undefined, labelAngle=Undefined, labelBaseline=Undefined, labelBound=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFlush=Undefined, labelFlushOffset=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelLineHeight=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, labels=Undefined, maxExtent=Undefined, minExtent=Undefined, offset=Undefined, orient=Undefined, position=Undefined, style=Undefined, tickBand=Undefined, tickCap=Undefined, tickColor=Undefined, tickCount=Undefined, tickDash=Undefined, tickDashOffset=Undefined, tickExtra=Undefined, tickMinStep=Undefined, tickOffset=Undefined, tickOpacity=Undefined, tickRound=Undefined, tickSize=Undefined, tickWidth=Undefined, ticks=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleAngle=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titlePadding=Undefined, titleX=Undefined, titleY=Undefined, translate=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'X': + ... + + @overload + def axis(self, _: type(None), **kwds) -> 'X': + ... + + def bandPosition(self, _: float, **kwds) -> 'X': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'X': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'X': + ... + + @overload + def bin(self, _: str, **kwds) -> 'X': + ... + + @overload + def bin(self, _: type(None), **kwds) -> 'X': + ... + + @overload + def field(self, _: str, **kwds) -> 'X': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'X': + ... + + @overload + def impute(self, frame=Undefined, keyvals=Undefined, method=Undefined, value=Undefined, **kwds) -> 'X': + ... + + @overload + def impute(self, _: type(None), **kwds) -> 'X': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'X': + ... + + @overload + def scale(self, _: type(None), **kwds) -> 'X': + ... + + @overload + def sort(self, **kwds) -> 'X': + ... + + @overload + def sort(self, **kwds) -> 'X': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'X': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'X': + ... + + @overload + def sort(self, _: type(None), **kwds) -> 'X': + ... + + @overload + def stack(self, _: str, **kwds) -> 'X': + ... + + @overload + def stack(self, _: type(None), **kwds) -> 'X': + ... + + @overload + def stack(self, _: bool, **kwds) -> 'X': + ... + + @overload + def timeUnit(self, **kwds) -> 'X': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'X': + ... + + @overload + def title(self, **kwds) -> 'X': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'X': + ... + + def type(self, _: str, **kwds) -> 'X': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, axis=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, impute=Undefined, scale=Undefined, sort=Undefined, stack=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -9772,6 +12990,58 @@ class XDatum(DatumChannelMixin, core.PositionDatumDef): """ _class_is_valid_at_instantiation = False _encoding_name = "x" + + @overload + def axis(self, aria=Undefined, bandPosition=Undefined, description=Undefined, domain=Undefined, domainCap=Undefined, domainColor=Undefined, domainDash=Undefined, domainDashOffset=Undefined, domainOpacity=Undefined, domainWidth=Undefined, format=Undefined, formatType=Undefined, grid=Undefined, gridCap=Undefined, gridColor=Undefined, gridDash=Undefined, gridDashOffset=Undefined, gridOpacity=Undefined, gridWidth=Undefined, labelAlign=Undefined, labelAngle=Undefined, labelBaseline=Undefined, labelBound=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFlush=Undefined, labelFlushOffset=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelLineHeight=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, labels=Undefined, maxExtent=Undefined, minExtent=Undefined, offset=Undefined, orient=Undefined, position=Undefined, style=Undefined, tickBand=Undefined, tickCap=Undefined, tickColor=Undefined, tickCount=Undefined, tickDash=Undefined, tickDashOffset=Undefined, tickExtra=Undefined, tickMinStep=Undefined, tickOffset=Undefined, tickOpacity=Undefined, tickRound=Undefined, tickSize=Undefined, tickWidth=Undefined, ticks=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleAngle=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titlePadding=Undefined, titleX=Undefined, titleY=Undefined, translate=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'XDatum': + ... + + @overload + def axis(self, _: type(None), **kwds) -> 'XDatum': + ... + + def bandPosition(self, _: float, **kwds) -> 'XDatum': + ... + + @overload + def impute(self, frame=Undefined, keyvals=Undefined, method=Undefined, value=Undefined, **kwds) -> 'XDatum': + ... + + @overload + def impute(self, _: type(None), **kwds) -> 'XDatum': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'XDatum': + ... + + @overload + def scale(self, _: type(None), **kwds) -> 'XDatum': + ... + + @overload + def stack(self, _: str, **kwds) -> 'XDatum': + ... + + @overload + def stack(self, _: type(None), **kwds) -> 'XDatum': + ... + + @overload + def stack(self, _: bool, **kwds) -> 'XDatum': + ... + + @overload + def title(self, **kwds) -> 'XDatum': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'XDatum': + ... + + def type(self, _: str, **kwds) -> 'XDatum': + ... + + def __init__(self, datum, axis=Undefined, bandPosition=Undefined, impute=Undefined, scale=Undefined, stack=Undefined, title=Undefined, type=Undefined, **kwds): super(XDatum, self).__init__(datum=datum, axis=axis, bandPosition=bandPosition, impute=impute, @@ -9797,6 +13067,8 @@ class XValue(ValueChannelMixin, core.PositionValueDef): _class_is_valid_at_instantiation = False _encoding_name = "x" + + def __init__(self, value, **kwds): super(XValue, self).__init__(value=value, **kwds) @@ -9895,6 +13167,49 @@ class X2(FieldChannelMixin, core.SecondaryFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "x2" + @overload + def aggregate(self, _: str, **kwds) -> 'X2': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'X2': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'X2': + ... + + def bandPosition(self, _: float, **kwds) -> 'X2': + ... + + def bin(self, _: type(None), **kwds) -> 'X2': + ... + + @overload + def field(self, _: str, **kwds) -> 'X2': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'X2': + ... + + @overload + def timeUnit(self, **kwds) -> 'X2': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'X2': + ... + + @overload + def title(self, **kwds) -> 'X2': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'X2': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, timeUnit=Undefined, title=Undefined, **kwds): super(X2, self).__init__(shorthand=shorthand, aggregate=aggregate, bandPosition=bandPosition, @@ -10009,6 +13324,22 @@ class X2Datum(DatumChannelMixin, core.DatumDef): """ _class_is_valid_at_instantiation = False _encoding_name = "x2" + + def bandPosition(self, _: float, **kwds) -> 'X2Datum': + ... + + @overload + def title(self, **kwds) -> 'X2Datum': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'X2Datum': + ... + + def type(self, _: str, **kwds) -> 'X2Datum': + ... + + def __init__(self, datum, bandPosition=Undefined, title=Undefined, type=Undefined, **kwds): super(X2Datum, self).__init__(datum=datum, bandPosition=bandPosition, title=title, type=type, **kwds) @@ -10033,6 +13364,8 @@ class X2Value(ValueChannelMixin, core.PositionValueDef): _class_is_valid_at_instantiation = False _encoding_name = "x2" + + def __init__(self, value, **kwds): super(X2Value, self).__init__(value=value, **kwds) @@ -10131,6 +13464,49 @@ class XError(FieldChannelMixin, core.SecondaryFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "xError" + @overload + def aggregate(self, _: str, **kwds) -> 'XError': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'XError': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'XError': + ... + + def bandPosition(self, _: float, **kwds) -> 'XError': + ... + + def bin(self, _: type(None), **kwds) -> 'XError': + ... + + @overload + def field(self, _: str, **kwds) -> 'XError': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'XError': + ... + + @overload + def timeUnit(self, **kwds) -> 'XError': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'XError': + ... + + @overload + def title(self, **kwds) -> 'XError': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'XError': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, timeUnit=Undefined, title=Undefined, **kwds): super(XError, self).__init__(shorthand=shorthand, aggregate=aggregate, @@ -10157,6 +13533,8 @@ class XErrorValue(ValueChannelMixin, core.ValueDefnumber): _class_is_valid_at_instantiation = False _encoding_name = "xError" + + def __init__(self, value, **kwds): super(XErrorValue, self).__init__(value=value, **kwds) @@ -10255,6 +13633,49 @@ class XError2(FieldChannelMixin, core.SecondaryFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "xError2" + @overload + def aggregate(self, _: str, **kwds) -> 'XError2': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'XError2': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'XError2': + ... + + def bandPosition(self, _: float, **kwds) -> 'XError2': + ... + + def bin(self, _: type(None), **kwds) -> 'XError2': + ... + + @overload + def field(self, _: str, **kwds) -> 'XError2': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'XError2': + ... + + @overload + def timeUnit(self, **kwds) -> 'XError2': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'XError2': + ... + + @overload + def title(self, **kwds) -> 'XError2': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'XError2': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, timeUnit=Undefined, title=Undefined, **kwds): super(XError2, self).__init__(shorthand=shorthand, aggregate=aggregate, @@ -10281,6 +13702,8 @@ class XError2Value(ValueChannelMixin, core.ValueDefnumber): _class_is_valid_at_instantiation = False _encoding_name = "xError2" + + def __init__(self, value, **kwds): super(XError2Value, self).__init__(value=value, **kwds) @@ -10497,6 +13920,89 @@ class XOffset(FieldChannelMixin, core.ScaleFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "xOffset" + @overload + def aggregate(self, _: str, **kwds) -> 'XOffset': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'XOffset': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'XOffset': + ... + + def bandPosition(self, _: float, **kwds) -> 'XOffset': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'XOffset': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'XOffset': + ... + + @overload + def bin(self, _: type(None), **kwds) -> 'XOffset': + ... + + @overload + def field(self, _: str, **kwds) -> 'XOffset': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'XOffset': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'XOffset': + ... + + @overload + def scale(self, _: type(None), **kwds) -> 'XOffset': + ... + + @overload + def sort(self, **kwds) -> 'XOffset': + ... + + @overload + def sort(self, **kwds) -> 'XOffset': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'XOffset': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'XOffset': + ... + + @overload + def sort(self, _: type(None), **kwds) -> 'XOffset': + ... + + @overload + def timeUnit(self, **kwds) -> 'XOffset': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'XOffset': + ... + + @overload + def title(self, **kwds) -> 'XOffset': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'XOffset': + ... + + def type(self, _: str, **kwds) -> 'XOffset': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, scale=Undefined, sort=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -10626,6 +14132,30 @@ class XOffsetDatum(DatumChannelMixin, core.ScaleDatumDef): """ _class_is_valid_at_instantiation = False _encoding_name = "xOffset" + + def bandPosition(self, _: float, **kwds) -> 'XOffsetDatum': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'XOffsetDatum': + ... + + @overload + def scale(self, _: type(None), **kwds) -> 'XOffsetDatum': + ... + + @overload + def title(self, **kwds) -> 'XOffsetDatum': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'XOffsetDatum': + ... + + def type(self, _: str, **kwds) -> 'XOffsetDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, scale=Undefined, title=Undefined, type=Undefined, **kwds): super(XOffsetDatum, self).__init__(datum=datum, bandPosition=bandPosition, scale=scale, @@ -10651,6 +14181,8 @@ class XOffsetValue(ValueChannelMixin, core.ValueDefnumber): _class_is_valid_at_instantiation = False _encoding_name = "xOffset" + + def __init__(self, value, **kwds): super(XOffsetValue, self).__init__(value=value, **kwds) @@ -10914,6 +14446,121 @@ class Y(FieldChannelMixin, core.PositionFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "y" + @overload + def aggregate(self, _: str, **kwds) -> 'Y': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Y': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Y': + ... + + @overload + def axis(self, aria=Undefined, bandPosition=Undefined, description=Undefined, domain=Undefined, domainCap=Undefined, domainColor=Undefined, domainDash=Undefined, domainDashOffset=Undefined, domainOpacity=Undefined, domainWidth=Undefined, format=Undefined, formatType=Undefined, grid=Undefined, gridCap=Undefined, gridColor=Undefined, gridDash=Undefined, gridDashOffset=Undefined, gridOpacity=Undefined, gridWidth=Undefined, labelAlign=Undefined, labelAngle=Undefined, labelBaseline=Undefined, labelBound=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFlush=Undefined, labelFlushOffset=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelLineHeight=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, labels=Undefined, maxExtent=Undefined, minExtent=Undefined, offset=Undefined, orient=Undefined, position=Undefined, style=Undefined, tickBand=Undefined, tickCap=Undefined, tickColor=Undefined, tickCount=Undefined, tickDash=Undefined, tickDashOffset=Undefined, tickExtra=Undefined, tickMinStep=Undefined, tickOffset=Undefined, tickOpacity=Undefined, tickRound=Undefined, tickSize=Undefined, tickWidth=Undefined, ticks=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleAngle=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titlePadding=Undefined, titleX=Undefined, titleY=Undefined, translate=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'Y': + ... + + @overload + def axis(self, _: type(None), **kwds) -> 'Y': + ... + + def bandPosition(self, _: float, **kwds) -> 'Y': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Y': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Y': + ... + + @overload + def bin(self, _: str, **kwds) -> 'Y': + ... + + @overload + def bin(self, _: type(None), **kwds) -> 'Y': + ... + + @overload + def field(self, _: str, **kwds) -> 'Y': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Y': + ... + + @overload + def impute(self, frame=Undefined, keyvals=Undefined, method=Undefined, value=Undefined, **kwds) -> 'Y': + ... + + @overload + def impute(self, _: type(None), **kwds) -> 'Y': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'Y': + ... + + @overload + def scale(self, _: type(None), **kwds) -> 'Y': + ... + + @overload + def sort(self, **kwds) -> 'Y': + ... + + @overload + def sort(self, **kwds) -> 'Y': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Y': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Y': + ... + + @overload + def sort(self, _: type(None), **kwds) -> 'Y': + ... + + @overload + def stack(self, _: str, **kwds) -> 'Y': + ... + + @overload + def stack(self, _: type(None), **kwds) -> 'Y': + ... + + @overload + def stack(self, _: bool, **kwds) -> 'Y': + ... + + @overload + def timeUnit(self, **kwds) -> 'Y': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Y': + ... + + @overload + def title(self, **kwds) -> 'Y': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Y': + ... + + def type(self, _: str, **kwds) -> 'Y': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, axis=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, impute=Undefined, scale=Undefined, sort=Undefined, stack=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -11091,6 +14738,58 @@ class YDatum(DatumChannelMixin, core.PositionDatumDef): """ _class_is_valid_at_instantiation = False _encoding_name = "y" + + @overload + def axis(self, aria=Undefined, bandPosition=Undefined, description=Undefined, domain=Undefined, domainCap=Undefined, domainColor=Undefined, domainDash=Undefined, domainDashOffset=Undefined, domainOpacity=Undefined, domainWidth=Undefined, format=Undefined, formatType=Undefined, grid=Undefined, gridCap=Undefined, gridColor=Undefined, gridDash=Undefined, gridDashOffset=Undefined, gridOpacity=Undefined, gridWidth=Undefined, labelAlign=Undefined, labelAngle=Undefined, labelBaseline=Undefined, labelBound=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFlush=Undefined, labelFlushOffset=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelLineHeight=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, labels=Undefined, maxExtent=Undefined, minExtent=Undefined, offset=Undefined, orient=Undefined, position=Undefined, style=Undefined, tickBand=Undefined, tickCap=Undefined, tickColor=Undefined, tickCount=Undefined, tickDash=Undefined, tickDashOffset=Undefined, tickExtra=Undefined, tickMinStep=Undefined, tickOffset=Undefined, tickOpacity=Undefined, tickRound=Undefined, tickSize=Undefined, tickWidth=Undefined, ticks=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleAngle=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titlePadding=Undefined, titleX=Undefined, titleY=Undefined, translate=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'YDatum': + ... + + @overload + def axis(self, _: type(None), **kwds) -> 'YDatum': + ... + + def bandPosition(self, _: float, **kwds) -> 'YDatum': + ... + + @overload + def impute(self, frame=Undefined, keyvals=Undefined, method=Undefined, value=Undefined, **kwds) -> 'YDatum': + ... + + @overload + def impute(self, _: type(None), **kwds) -> 'YDatum': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'YDatum': + ... + + @overload + def scale(self, _: type(None), **kwds) -> 'YDatum': + ... + + @overload + def stack(self, _: str, **kwds) -> 'YDatum': + ... + + @overload + def stack(self, _: type(None), **kwds) -> 'YDatum': + ... + + @overload + def stack(self, _: bool, **kwds) -> 'YDatum': + ... + + @overload + def title(self, **kwds) -> 'YDatum': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'YDatum': + ... + + def type(self, _: str, **kwds) -> 'YDatum': + ... + + def __init__(self, datum, axis=Undefined, bandPosition=Undefined, impute=Undefined, scale=Undefined, stack=Undefined, title=Undefined, type=Undefined, **kwds): super(YDatum, self).__init__(datum=datum, axis=axis, bandPosition=bandPosition, impute=impute, @@ -11116,6 +14815,8 @@ class YValue(ValueChannelMixin, core.PositionValueDef): _class_is_valid_at_instantiation = False _encoding_name = "y" + + def __init__(self, value, **kwds): super(YValue, self).__init__(value=value, **kwds) @@ -11214,6 +14915,49 @@ class Y2(FieldChannelMixin, core.SecondaryFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "y2" + @overload + def aggregate(self, _: str, **kwds) -> 'Y2': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Y2': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Y2': + ... + + def bandPosition(self, _: float, **kwds) -> 'Y2': + ... + + def bin(self, _: type(None), **kwds) -> 'Y2': + ... + + @overload + def field(self, _: str, **kwds) -> 'Y2': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Y2': + ... + + @overload + def timeUnit(self, **kwds) -> 'Y2': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Y2': + ... + + @overload + def title(self, **kwds) -> 'Y2': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Y2': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, timeUnit=Undefined, title=Undefined, **kwds): super(Y2, self).__init__(shorthand=shorthand, aggregate=aggregate, bandPosition=bandPosition, @@ -11328,6 +15072,22 @@ class Y2Datum(DatumChannelMixin, core.DatumDef): """ _class_is_valid_at_instantiation = False _encoding_name = "y2" + + def bandPosition(self, _: float, **kwds) -> 'Y2Datum': + ... + + @overload + def title(self, **kwds) -> 'Y2Datum': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'Y2Datum': + ... + + def type(self, _: str, **kwds) -> 'Y2Datum': + ... + + def __init__(self, datum, bandPosition=Undefined, title=Undefined, type=Undefined, **kwds): super(Y2Datum, self).__init__(datum=datum, bandPosition=bandPosition, title=title, type=type, **kwds) @@ -11352,6 +15112,8 @@ class Y2Value(ValueChannelMixin, core.PositionValueDef): _class_is_valid_at_instantiation = False _encoding_name = "y2" + + def __init__(self, value, **kwds): super(Y2Value, self).__init__(value=value, **kwds) @@ -11450,6 +15212,49 @@ class YError(FieldChannelMixin, core.SecondaryFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "yError" + @overload + def aggregate(self, _: str, **kwds) -> 'YError': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'YError': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'YError': + ... + + def bandPosition(self, _: float, **kwds) -> 'YError': + ... + + def bin(self, _: type(None), **kwds) -> 'YError': + ... + + @overload + def field(self, _: str, **kwds) -> 'YError': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'YError': + ... + + @overload + def timeUnit(self, **kwds) -> 'YError': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'YError': + ... + + @overload + def title(self, **kwds) -> 'YError': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'YError': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, timeUnit=Undefined, title=Undefined, **kwds): super(YError, self).__init__(shorthand=shorthand, aggregate=aggregate, @@ -11476,6 +15281,8 @@ class YErrorValue(ValueChannelMixin, core.ValueDefnumber): _class_is_valid_at_instantiation = False _encoding_name = "yError" + + def __init__(self, value, **kwds): super(YErrorValue, self).__init__(value=value, **kwds) @@ -11574,6 +15381,49 @@ class YError2(FieldChannelMixin, core.SecondaryFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "yError2" + @overload + def aggregate(self, _: str, **kwds) -> 'YError2': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'YError2': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'YError2': + ... + + def bandPosition(self, _: float, **kwds) -> 'YError2': + ... + + def bin(self, _: type(None), **kwds) -> 'YError2': + ... + + @overload + def field(self, _: str, **kwds) -> 'YError2': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'YError2': + ... + + @overload + def timeUnit(self, **kwds) -> 'YError2': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'YError2': + ... + + @overload + def title(self, **kwds) -> 'YError2': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'YError2': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, timeUnit=Undefined, title=Undefined, **kwds): super(YError2, self).__init__(shorthand=shorthand, aggregate=aggregate, @@ -11600,6 +15450,8 @@ class YError2Value(ValueChannelMixin, core.ValueDefnumber): _class_is_valid_at_instantiation = False _encoding_name = "yError2" + + def __init__(self, value, **kwds): super(YError2Value, self).__init__(value=value, **kwds) @@ -11816,6 +15668,89 @@ class YOffset(FieldChannelMixin, core.ScaleFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "yOffset" + @overload + def aggregate(self, _: str, **kwds) -> 'YOffset': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'YOffset': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'YOffset': + ... + + def bandPosition(self, _: float, **kwds) -> 'YOffset': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'YOffset': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'YOffset': + ... + + @overload + def bin(self, _: type(None), **kwds) -> 'YOffset': + ... + + @overload + def field(self, _: str, **kwds) -> 'YOffset': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'YOffset': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'YOffset': + ... + + @overload + def scale(self, _: type(None), **kwds) -> 'YOffset': + ... + + @overload + def sort(self, **kwds) -> 'YOffset': + ... + + @overload + def sort(self, **kwds) -> 'YOffset': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'YOffset': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'YOffset': + ... + + @overload + def sort(self, _: type(None), **kwds) -> 'YOffset': + ... + + @overload + def timeUnit(self, **kwds) -> 'YOffset': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'YOffset': + ... + + @overload + def title(self, **kwds) -> 'YOffset': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'YOffset': + ... + + def type(self, _: str, **kwds) -> 'YOffset': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, scale=Undefined, sort=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -11945,6 +15880,30 @@ class YOffsetDatum(DatumChannelMixin, core.ScaleDatumDef): """ _class_is_valid_at_instantiation = False _encoding_name = "yOffset" + + def bandPosition(self, _: float, **kwds) -> 'YOffsetDatum': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'YOffsetDatum': + ... + + @overload + def scale(self, _: type(None), **kwds) -> 'YOffsetDatum': + ... + + @overload + def title(self, **kwds) -> 'YOffsetDatum': + ... + + @overload + def title(self, _: type(None), **kwds) -> 'YOffsetDatum': + ... + + def type(self, _: str, **kwds) -> 'YOffsetDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, scale=Undefined, title=Undefined, type=Undefined, **kwds): super(YOffsetDatum, self).__init__(datum=datum, bandPosition=bandPosition, scale=scale, @@ -11970,5 +15929,7 @@ class YOffsetValue(ValueChannelMixin, core.ValueDefnumber): _class_is_valid_at_instantiation = False _encoding_name = "yOffset" + + def __init__(self, value, **kwds): super(YOffsetValue, self).__init__(value=value, **kwds) diff --git a/tools/generate_schema_wrapper.py b/tools/generate_schema_wrapper.py index df6e93444..79bceb660 100644 --- a/tools/generate_schema_wrapper.py +++ b/tools/generate_schema_wrapper.py @@ -184,6 +184,8 @@ class {classname}(FieldChannelMixin, core.{basename}): _class_is_valid_at_instantiation = False _encoding_name = "{encodingname}" + {method_code} + {init_code} ''' ) @@ -198,6 +200,8 @@ class {classname}(ValueChannelMixin, core.{basename}): _class_is_valid_at_instantiation = False _encoding_name = "{encodingname}" + {method_code} + {init_code} ''' ) @@ -211,6 +215,9 @@ class {classname}(DatumChannelMixin, core.{basename}): """{docstring}""" _class_is_valid_at_instantiation = False _encoding_name = "{encodingname}" + + {method_code} + {init_code} ''' ) @@ -434,6 +441,7 @@ def generate_vegalite_channel_wrappers(schemafile, version, imports=None): "import pandas as pd", "from altair.utils.schemapi import Undefined, with_property_setters", "from altair.utils import parse_shorthand", + "from typing import overload", ] contents = [HEADER] contents.extend(imports) @@ -488,6 +496,7 @@ def generate_vegalite_channel_wrappers(schemafile, version, imports=None): rootschema=schema, encodingname=prop, nodefault=nodefault, + haspropsetters=True, ) contents.append(gen.schema_class()) return "\n".join(contents) diff --git a/tools/schemapi/codegen.py b/tools/schemapi/codegen.py index 78460e582..f82add11c 100644 --- a/tools/schemapi/codegen.py +++ b/tools/schemapi/codegen.py @@ -111,6 +111,7 @@ def __init__( schemarepr=None, rootschemarepr=None, nodefault=(), + haspropsetters=False, **kwargs, ): self.classname = classname @@ -120,6 +121,7 @@ def __init__( self.schemarepr = schemarepr self.rootschemarepr = rootschemarepr self.nodefault = nodefault + self.haspropsetters = haspropsetters self.kwargs = kwargs def subclasses(self): @@ -148,6 +150,7 @@ def schema_class(self): rootschema=rootschemarepr, docstring=self.docstring(indent=4), init_code=self.init_code(indent=4), + method_code=self.method_code(indent=4), **self.kwargs, ) @@ -177,7 +180,7 @@ def docstring(self, indent=0): return indent_docstring(doc, indent_level=indent, width=100, lstrip=True) def init_code(self, indent=0): - """Return code suitablde for the __init__ function of a Schema class""" + """Return code suitable for the __init__ function of a Schema class""" info = SchemaInfo(self.schema, rootschema=self.rootschema) nonkeyword, required, kwds, invalid_kwds, additional = _get_args(info) @@ -188,6 +191,8 @@ def init_code(self, indent=0): args = ["self"] super_args = [] + self.init_kwds = sorted(kwds) + if nodefault: args.extend(sorted(nodefault)) elif nonkeyword: @@ -217,3 +222,61 @@ def init_code(self, indent=0): if indent: initfunc = ("\n" + indent * " ").join(initfunc.splitlines()) return initfunc + + _equiv_python_types = { + "string": "str", + "number": "float", + "integer": "int", + "object": "dict", + "boolean": "bool", + "array": "list", + "null": "type(None)", + } + + def get_args(self, si): + contents = ["self"] + props = [] + # TODO: do we need to specialize the anyOf code? + if si.is_anyOf(): + props = sorted(list({p for si_sub in si.anyOf for p in si_sub.properties})) + elif si.properties: + props = si.properties + + if props: + contents.extend([p + "=Undefined" for p in props]) + elif si.type: + py_type = self._equiv_python_types[si.type] + contents.append(f"_: {py_type}") + + contents.append("**kwds") + + return contents + + def get_signature(self, attr, sub_si, indent, has_overload=False): + lines = [] + if has_overload: + lines.append("@overload") + args = ", ".join(self.get_args(sub_si)) + lines.append(f"def {attr}({args}) -> '{self.classname}':") + lines.append(indent * " " + "...\n") + return lines + + def setter_hint(self, attr, indent): + si = SchemaInfo(self.schema, self.rootschema).properties[attr] + if si.is_anyOf(): + signatures = [ + self.get_signature(attr, sub_si, indent, has_overload=True) + for sub_si in si.anyOf + ] + return [line for sig in signatures for line in sig] + else: + return self.get_signature(attr, si, indent) + + def method_code(self, indent=0): + """Return code to assist setter methods""" + if not self.haspropsetters: + return None + args = self.init_kwds + type_hints = [hint for a in args for hint in self.setter_hint(a, indent)] + + return ("\n" + indent * " ").join(type_hints) diff --git a/tools/schemapi/utils.py b/tools/schemapi/utils.py index d0b149f3f..d94676136 100644 --- a/tools/schemapi/utils.py +++ b/tools/schemapi/utils.py @@ -192,17 +192,19 @@ def short_description(self): else: return self.medium_description + _simple_types = { + "string": "string", + "number": "float", + "integer": "integer", + "object": "mapping", + "boolean": "boolean", + "array": "list", + "null": "None", + } + @property def medium_description(self): - _simple_types = { - "string": "string", - "number": "float", - "integer": "integer", - "object": "mapping", - "boolean": "boolean", - "array": "list", - "null": "None", - } + if self.is_list(): return "[{0}]".format( ", ".join(self.child(s).short_description for s in self.schema) @@ -236,8 +238,8 @@ def medium_description(self): return "Mapping(required=[{}])".format(", ".join(self.required)) elif self.is_array(): return "List({})".format(self.child(self.items).short_description) - elif self.type in _simple_types: - return _simple_types[self.type] + elif self.type in self._simple_types: + return self._simple_types[self.type] elif not self.type: import warnings From c24aa4a6966efe3eb82766df4b2ae1d51474e3dd Mon Sep 17 00:00:00 2001 From: Christopher Davis Date: Fri, 23 Dec 2022 09:16:02 -0600 Subject: [PATCH 19/26] Fix NoneType notation --- altair/vegalite/v5/schema/channels.py | 360 +++++++++++++------------- tools/generate_schema_wrapper.py | 2 +- tools/schemapi/codegen.py | 2 +- 3 files changed, 182 insertions(+), 182 deletions(-) diff --git a/altair/vegalite/v5/schema/channels.py b/altair/vegalite/v5/schema/channels.py index 2f352d331..0bef47f82 100644 --- a/altair/vegalite/v5/schema/channels.py +++ b/altair/vegalite/v5/schema/channels.py @@ -5,7 +5,7 @@ import pandas as pd from altair.utils.schemapi import Undefined, with_property_setters from altair.utils import parse_shorthand -from typing import overload +from typing import overload, Type class FieldChannelMixin(object): @@ -347,7 +347,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: type(None), **kwds) -> 'Angle': + def bin(self, _: Type[None], **kwds) -> 'Angle': ... @overload @@ -371,7 +371,7 @@ def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, ... @overload - def legend(self, _: type(None), **kwds) -> 'Angle': + def legend(self, _: Type[None], **kwds) -> 'Angle': ... @overload @@ -379,7 +379,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: type(None), **kwds) -> 'Angle': + def scale(self, _: Type[None], **kwds) -> 'Angle': ... @overload @@ -399,7 +399,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Angle': ... @overload - def sort(self, _: type(None), **kwds) -> 'Angle': + def sort(self, _: Type[None], **kwds) -> 'Angle': ... @overload @@ -415,7 +415,7 @@ def title(self, **kwds) -> 'Angle': ... @overload - def title(self, _: type(None), **kwds) -> 'Angle': + def title(self, _: Type[None], **kwds) -> 'Angle': ... def type(self, _: str, **kwds) -> 'Angle': @@ -566,7 +566,7 @@ def title(self, **kwds) -> 'AngleDatum': ... @overload - def title(self, _: type(None), **kwds) -> 'AngleDatum': + def title(self, _: Type[None], **kwds) -> 'AngleDatum': ... def type(self, _: str, **kwds) -> 'AngleDatum': @@ -871,7 +871,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: type(None), **kwds) -> 'Color': + def bin(self, _: Type[None], **kwds) -> 'Color': ... @overload @@ -895,7 +895,7 @@ def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, ... @overload - def legend(self, _: type(None), **kwds) -> 'Color': + def legend(self, _: Type[None], **kwds) -> 'Color': ... @overload @@ -903,7 +903,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: type(None), **kwds) -> 'Color': + def scale(self, _: Type[None], **kwds) -> 'Color': ... @overload @@ -923,7 +923,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Color': ... @overload - def sort(self, _: type(None), **kwds) -> 'Color': + def sort(self, _: Type[None], **kwds) -> 'Color': ... @overload @@ -939,7 +939,7 @@ def title(self, **kwds) -> 'Color': ... @overload - def title(self, _: type(None), **kwds) -> 'Color': + def title(self, _: Type[None], **kwds) -> 'Color': ... def type(self, _: str, **kwds) -> 'Color': @@ -1090,7 +1090,7 @@ def title(self, **kwds) -> 'ColorDatum': ... @overload - def title(self, _: type(None), **kwds) -> 'ColorDatum': + def title(self, _: Type[None], **kwds) -> 'ColorDatum': ... def type(self, _: str, **kwds) -> 'ColorDatum': @@ -1382,7 +1382,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: type(None), **kwds) -> 'Column': + def bin(self, _: Type[None], **kwds) -> 'Column': ... def center(self, _: bool, **kwds) -> 'Column': @@ -1401,7 +1401,7 @@ def header(self, format=Undefined, formatType=Undefined, labelAlign=Undefined, l ... @overload - def header(self, _: type(None), **kwds) -> 'Column': + def header(self, _: Type[None], **kwds) -> 'Column': ... @overload @@ -1417,7 +1417,7 @@ def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Colum ... @overload - def sort(self, _: type(None), **kwds) -> 'Column': + def sort(self, _: Type[None], **kwds) -> 'Column': ... def spacing(self, _: float, **kwds) -> 'Column': @@ -1436,7 +1436,7 @@ def title(self, **kwds) -> 'Column': ... @overload - def title(self, _: type(None), **kwds) -> 'Column': + def title(self, _: Type[None], **kwds) -> 'Column': ... def type(self, _: str, **kwds) -> 'Column': @@ -1686,7 +1686,7 @@ def bin(self, _: str, **kwds) -> 'Description': ... @overload - def bin(self, _: type(None), **kwds) -> 'Description': + def bin(self, _: Type[None], **kwds) -> 'Description': ... @overload @@ -1729,7 +1729,7 @@ def title(self, **kwds) -> 'Description': ... @overload - def title(self, _: type(None), **kwds) -> 'Description': + def title(self, _: Type[None], **kwds) -> 'Description': ... def type(self, _: str, **kwds) -> 'Description': @@ -1973,7 +1973,7 @@ def bin(self, _: str, **kwds) -> 'Detail': ... @overload - def bin(self, _: type(None), **kwds) -> 'Detail': + def bin(self, _: Type[None], **kwds) -> 'Detail': ... @overload @@ -1997,7 +1997,7 @@ def title(self, **kwds) -> 'Detail': ... @overload - def title(self, _: type(None), **kwds) -> 'Detail': + def title(self, _: Type[None], **kwds) -> 'Detail': ... def type(self, _: str, **kwds) -> 'Detail': @@ -2295,7 +2295,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: type(None), **kwds) -> 'Facet': + def bin(self, _: Type[None], **kwds) -> 'Facet': ... def bounds(self, _: str, **kwds) -> 'Facet': @@ -2325,7 +2325,7 @@ def header(self, format=Undefined, formatType=Undefined, labelAlign=Undefined, l ... @overload - def header(self, _: type(None), **kwds) -> 'Facet': + def header(self, _: Type[None], **kwds) -> 'Facet': ... @overload @@ -2341,7 +2341,7 @@ def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Facet ... @overload - def sort(self, _: type(None), **kwds) -> 'Facet': + def sort(self, _: Type[None], **kwds) -> 'Facet': ... @overload @@ -2365,7 +2365,7 @@ def title(self, **kwds) -> 'Facet': ... @overload - def title(self, _: type(None), **kwds) -> 'Facet': + def title(self, _: Type[None], **kwds) -> 'Facet': ... def type(self, _: str, **kwds) -> 'Facet': @@ -2637,7 +2637,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: type(None), **kwds) -> 'Fill': + def bin(self, _: Type[None], **kwds) -> 'Fill': ... @overload @@ -2661,7 +2661,7 @@ def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, ... @overload - def legend(self, _: type(None), **kwds) -> 'Fill': + def legend(self, _: Type[None], **kwds) -> 'Fill': ... @overload @@ -2669,7 +2669,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: type(None), **kwds) -> 'Fill': + def scale(self, _: Type[None], **kwds) -> 'Fill': ... @overload @@ -2689,7 +2689,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Fill': ... @overload - def sort(self, _: type(None), **kwds) -> 'Fill': + def sort(self, _: Type[None], **kwds) -> 'Fill': ... @overload @@ -2705,7 +2705,7 @@ def title(self, **kwds) -> 'Fill': ... @overload - def title(self, _: type(None), **kwds) -> 'Fill': + def title(self, _: Type[None], **kwds) -> 'Fill': ... def type(self, _: str, **kwds) -> 'Fill': @@ -2856,7 +2856,7 @@ def title(self, **kwds) -> 'FillDatum': ... @overload - def title(self, _: type(None), **kwds) -> 'FillDatum': + def title(self, _: Type[None], **kwds) -> 'FillDatum': ... def type(self, _: str, **kwds) -> 'FillDatum': @@ -3162,7 +3162,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: type(None), **kwds) -> 'FillOpacity': + def bin(self, _: Type[None], **kwds) -> 'FillOpacity': ... @overload @@ -3186,7 +3186,7 @@ def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, ... @overload - def legend(self, _: type(None), **kwds) -> 'FillOpacity': + def legend(self, _: Type[None], **kwds) -> 'FillOpacity': ... @overload @@ -3194,7 +3194,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: type(None), **kwds) -> 'FillOpacity': + def scale(self, _: Type[None], **kwds) -> 'FillOpacity': ... @overload @@ -3214,7 +3214,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'FillOpacity': ... @overload - def sort(self, _: type(None), **kwds) -> 'FillOpacity': + def sort(self, _: Type[None], **kwds) -> 'FillOpacity': ... @overload @@ -3230,7 +3230,7 @@ def title(self, **kwds) -> 'FillOpacity': ... @overload - def title(self, _: type(None), **kwds) -> 'FillOpacity': + def title(self, _: Type[None], **kwds) -> 'FillOpacity': ... def type(self, _: str, **kwds) -> 'FillOpacity': @@ -3381,7 +3381,7 @@ def title(self, **kwds) -> 'FillOpacityDatum': ... @overload - def title(self, _: type(None), **kwds) -> 'FillOpacityDatum': + def title(self, _: Type[None], **kwds) -> 'FillOpacityDatum': ... def type(self, _: str, **kwds) -> 'FillOpacityDatum': @@ -3664,7 +3664,7 @@ def bin(self, _: str, **kwds) -> 'Href': ... @overload - def bin(self, _: type(None), **kwds) -> 'Href': + def bin(self, _: Type[None], **kwds) -> 'Href': ... @overload @@ -3707,7 +3707,7 @@ def title(self, **kwds) -> 'Href': ... @overload - def title(self, _: type(None), **kwds) -> 'Href': + def title(self, _: Type[None], **kwds) -> 'Href': ... def type(self, _: str, **kwds) -> 'Href': @@ -3951,7 +3951,7 @@ def bin(self, _: str, **kwds) -> 'Key': ... @overload - def bin(self, _: type(None), **kwds) -> 'Key': + def bin(self, _: Type[None], **kwds) -> 'Key': ... @overload @@ -3975,7 +3975,7 @@ def title(self, **kwds) -> 'Key': ... @overload - def title(self, _: type(None), **kwds) -> 'Key': + def title(self, _: Type[None], **kwds) -> 'Key': ... def type(self, _: str, **kwds) -> 'Key': @@ -4165,7 +4165,7 @@ def aggregate(self, argmin=Undefined, **kwds) -> 'Latitude': def bandPosition(self, _: float, **kwds) -> 'Latitude': ... - def bin(self, _: type(None), **kwds) -> 'Latitude': + def bin(self, _: Type[None], **kwds) -> 'Latitude': ... @overload @@ -4189,7 +4189,7 @@ def title(self, **kwds) -> 'Latitude': ... @overload - def title(self, _: type(None), **kwds) -> 'Latitude': + def title(self, _: Type[None], **kwds) -> 'Latitude': ... def type(self, _: str, **kwds) -> 'Latitude': @@ -4320,7 +4320,7 @@ def title(self, **kwds) -> 'LatitudeDatum': ... @overload - def title(self, _: type(None), **kwds) -> 'LatitudeDatum': + def title(self, _: Type[None], **kwds) -> 'LatitudeDatum': ... def type(self, _: str, **kwds) -> 'LatitudeDatum': @@ -4441,7 +4441,7 @@ def aggregate(self, argmin=Undefined, **kwds) -> 'Latitude2': def bandPosition(self, _: float, **kwds) -> 'Latitude2': ... - def bin(self, _: type(None), **kwds) -> 'Latitude2': + def bin(self, _: Type[None], **kwds) -> 'Latitude2': ... @overload @@ -4465,7 +4465,7 @@ def title(self, **kwds) -> 'Latitude2': ... @overload - def title(self, _: type(None), **kwds) -> 'Latitude2': + def title(self, _: Type[None], **kwds) -> 'Latitude2': ... @@ -4593,7 +4593,7 @@ def title(self, **kwds) -> 'Latitude2Datum': ... @overload - def title(self, _: type(None), **kwds) -> 'Latitude2Datum': + def title(self, _: Type[None], **kwds) -> 'Latitude2Datum': ... def type(self, _: str, **kwds) -> 'Latitude2Datum': @@ -4806,7 +4806,7 @@ def aggregate(self, argmin=Undefined, **kwds) -> 'Longitude': def bandPosition(self, _: float, **kwds) -> 'Longitude': ... - def bin(self, _: type(None), **kwds) -> 'Longitude': + def bin(self, _: Type[None], **kwds) -> 'Longitude': ... @overload @@ -4830,7 +4830,7 @@ def title(self, **kwds) -> 'Longitude': ... @overload - def title(self, _: type(None), **kwds) -> 'Longitude': + def title(self, _: Type[None], **kwds) -> 'Longitude': ... def type(self, _: str, **kwds) -> 'Longitude': @@ -4961,7 +4961,7 @@ def title(self, **kwds) -> 'LongitudeDatum': ... @overload - def title(self, _: type(None), **kwds) -> 'LongitudeDatum': + def title(self, _: Type[None], **kwds) -> 'LongitudeDatum': ... def type(self, _: str, **kwds) -> 'LongitudeDatum': @@ -5082,7 +5082,7 @@ def aggregate(self, argmin=Undefined, **kwds) -> 'Longitude2': def bandPosition(self, _: float, **kwds) -> 'Longitude2': ... - def bin(self, _: type(None), **kwds) -> 'Longitude2': + def bin(self, _: Type[None], **kwds) -> 'Longitude2': ... @overload @@ -5106,7 +5106,7 @@ def title(self, **kwds) -> 'Longitude2': ... @overload - def title(self, _: type(None), **kwds) -> 'Longitude2': + def title(self, _: Type[None], **kwds) -> 'Longitude2': ... @@ -5234,7 +5234,7 @@ def title(self, **kwds) -> 'Longitude2Datum': ... @overload - def title(self, _: type(None), **kwds) -> 'Longitude2Datum': + def title(self, _: Type[None], **kwds) -> 'Longitude2Datum': ... def type(self, _: str, **kwds) -> 'Longitude2Datum': @@ -5526,7 +5526,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: type(None), **kwds) -> 'Opacity': + def bin(self, _: Type[None], **kwds) -> 'Opacity': ... @overload @@ -5550,7 +5550,7 @@ def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, ... @overload - def legend(self, _: type(None), **kwds) -> 'Opacity': + def legend(self, _: Type[None], **kwds) -> 'Opacity': ... @overload @@ -5558,7 +5558,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: type(None), **kwds) -> 'Opacity': + def scale(self, _: Type[None], **kwds) -> 'Opacity': ... @overload @@ -5578,7 +5578,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Opacity': ... @overload - def sort(self, _: type(None), **kwds) -> 'Opacity': + def sort(self, _: Type[None], **kwds) -> 'Opacity': ... @overload @@ -5594,7 +5594,7 @@ def title(self, **kwds) -> 'Opacity': ... @overload - def title(self, _: type(None), **kwds) -> 'Opacity': + def title(self, _: Type[None], **kwds) -> 'Opacity': ... def type(self, _: str, **kwds) -> 'Opacity': @@ -5745,7 +5745,7 @@ def title(self, **kwds) -> 'OpacityDatum': ... @overload - def title(self, _: type(None), **kwds) -> 'OpacityDatum': + def title(self, _: Type[None], **kwds) -> 'OpacityDatum': ... def type(self, _: str, **kwds) -> 'OpacityDatum': @@ -5986,7 +5986,7 @@ def bin(self, _: str, **kwds) -> 'Order': ... @overload - def bin(self, _: type(None), **kwds) -> 'Order': + def bin(self, _: Type[None], **kwds) -> 'Order': ... @overload @@ -6013,7 +6013,7 @@ def title(self, **kwds) -> 'Order': ... @overload - def title(self, _: type(None), **kwds) -> 'Order': + def title(self, _: Type[None], **kwds) -> 'Order': ... def type(self, _: str, **kwds) -> 'Order': @@ -6336,7 +6336,7 @@ def bin(self, _: str, **kwds) -> 'Radius': ... @overload - def bin(self, _: type(None), **kwds) -> 'Radius': + def bin(self, _: Type[None], **kwds) -> 'Radius': ... @overload @@ -6352,7 +6352,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: type(None), **kwds) -> 'Radius': + def scale(self, _: Type[None], **kwds) -> 'Radius': ... @overload @@ -6372,7 +6372,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Radius': ... @overload - def sort(self, _: type(None), **kwds) -> 'Radius': + def sort(self, _: Type[None], **kwds) -> 'Radius': ... @overload @@ -6380,7 +6380,7 @@ def stack(self, _: str, **kwds) -> 'Radius': ... @overload - def stack(self, _: type(None), **kwds) -> 'Radius': + def stack(self, _: Type[None], **kwds) -> 'Radius': ... @overload @@ -6400,7 +6400,7 @@ def title(self, **kwds) -> 'Radius': ... @overload - def title(self, _: type(None), **kwds) -> 'Radius': + def title(self, _: Type[None], **kwds) -> 'Radius': ... def type(self, _: str, **kwds) -> 'Radius': @@ -6576,7 +6576,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: type(None), **kwds) -> 'RadiusDatum': + def scale(self, _: Type[None], **kwds) -> 'RadiusDatum': ... @overload @@ -6584,7 +6584,7 @@ def stack(self, _: str, **kwds) -> 'RadiusDatum': ... @overload - def stack(self, _: type(None), **kwds) -> 'RadiusDatum': + def stack(self, _: Type[None], **kwds) -> 'RadiusDatum': ... @overload @@ -6596,7 +6596,7 @@ def title(self, **kwds) -> 'RadiusDatum': ... @overload - def title(self, _: type(None), **kwds) -> 'RadiusDatum': + def title(self, _: Type[None], **kwds) -> 'RadiusDatum': ... def type(self, _: str, **kwds) -> 'RadiusDatum': @@ -6743,7 +6743,7 @@ def aggregate(self, argmin=Undefined, **kwds) -> 'Radius2': def bandPosition(self, _: float, **kwds) -> 'Radius2': ... - def bin(self, _: type(None), **kwds) -> 'Radius2': + def bin(self, _: Type[None], **kwds) -> 'Radius2': ... @overload @@ -6767,7 +6767,7 @@ def title(self, **kwds) -> 'Radius2': ... @overload - def title(self, _: type(None), **kwds) -> 'Radius2': + def title(self, _: Type[None], **kwds) -> 'Radius2': ... @@ -6895,7 +6895,7 @@ def title(self, **kwds) -> 'Radius2Datum': ... @overload - def title(self, _: type(None), **kwds) -> 'Radius2Datum': + def title(self, _: Type[None], **kwds) -> 'Radius2Datum': ... def type(self, _: str, **kwds) -> 'Radius2Datum': @@ -7173,7 +7173,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: type(None), **kwds) -> 'Row': + def bin(self, _: Type[None], **kwds) -> 'Row': ... def center(self, _: bool, **kwds) -> 'Row': @@ -7192,7 +7192,7 @@ def header(self, format=Undefined, formatType=Undefined, labelAlign=Undefined, l ... @overload - def header(self, _: type(None), **kwds) -> 'Row': + def header(self, _: Type[None], **kwds) -> 'Row': ... @overload @@ -7208,7 +7208,7 @@ def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Row': ... @overload - def sort(self, _: type(None), **kwds) -> 'Row': + def sort(self, _: Type[None], **kwds) -> 'Row': ... def spacing(self, _: float, **kwds) -> 'Row': @@ -7227,7 +7227,7 @@ def title(self, **kwds) -> 'Row': ... @overload - def title(self, _: type(None), **kwds) -> 'Row': + def title(self, _: Type[None], **kwds) -> 'Row': ... def type(self, _: str, **kwds) -> 'Row': @@ -7499,7 +7499,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: type(None), **kwds) -> 'Shape': + def bin(self, _: Type[None], **kwds) -> 'Shape': ... @overload @@ -7523,7 +7523,7 @@ def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, ... @overload - def legend(self, _: type(None), **kwds) -> 'Shape': + def legend(self, _: Type[None], **kwds) -> 'Shape': ... @overload @@ -7531,7 +7531,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: type(None), **kwds) -> 'Shape': + def scale(self, _: Type[None], **kwds) -> 'Shape': ... @overload @@ -7551,7 +7551,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Shape': ... @overload - def sort(self, _: type(None), **kwds) -> 'Shape': + def sort(self, _: Type[None], **kwds) -> 'Shape': ... @overload @@ -7567,7 +7567,7 @@ def title(self, **kwds) -> 'Shape': ... @overload - def title(self, _: type(None), **kwds) -> 'Shape': + def title(self, _: Type[None], **kwds) -> 'Shape': ... def type(self, _: str, **kwds) -> 'Shape': @@ -7718,7 +7718,7 @@ def title(self, **kwds) -> 'ShapeDatum': ... @overload - def title(self, _: type(None), **kwds) -> 'ShapeDatum': + def title(self, _: Type[None], **kwds) -> 'ShapeDatum': ... def type(self, _: str, **kwds) -> 'ShapeDatum': @@ -8024,7 +8024,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: type(None), **kwds) -> 'Size': + def bin(self, _: Type[None], **kwds) -> 'Size': ... @overload @@ -8048,7 +8048,7 @@ def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, ... @overload - def legend(self, _: type(None), **kwds) -> 'Size': + def legend(self, _: Type[None], **kwds) -> 'Size': ... @overload @@ -8056,7 +8056,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: type(None), **kwds) -> 'Size': + def scale(self, _: Type[None], **kwds) -> 'Size': ... @overload @@ -8076,7 +8076,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Size': ... @overload - def sort(self, _: type(None), **kwds) -> 'Size': + def sort(self, _: Type[None], **kwds) -> 'Size': ... @overload @@ -8092,7 +8092,7 @@ def title(self, **kwds) -> 'Size': ... @overload - def title(self, _: type(None), **kwds) -> 'Size': + def title(self, _: Type[None], **kwds) -> 'Size': ... def type(self, _: str, **kwds) -> 'Size': @@ -8243,7 +8243,7 @@ def title(self, **kwds) -> 'SizeDatum': ... @overload - def title(self, _: type(None), **kwds) -> 'SizeDatum': + def title(self, _: Type[None], **kwds) -> 'SizeDatum': ... def type(self, _: str, **kwds) -> 'SizeDatum': @@ -8548,7 +8548,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: type(None), **kwds) -> 'Stroke': + def bin(self, _: Type[None], **kwds) -> 'Stroke': ... @overload @@ -8572,7 +8572,7 @@ def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, ... @overload - def legend(self, _: type(None), **kwds) -> 'Stroke': + def legend(self, _: Type[None], **kwds) -> 'Stroke': ... @overload @@ -8580,7 +8580,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: type(None), **kwds) -> 'Stroke': + def scale(self, _: Type[None], **kwds) -> 'Stroke': ... @overload @@ -8600,7 +8600,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Stroke': ... @overload - def sort(self, _: type(None), **kwds) -> 'Stroke': + def sort(self, _: Type[None], **kwds) -> 'Stroke': ... @overload @@ -8616,7 +8616,7 @@ def title(self, **kwds) -> 'Stroke': ... @overload - def title(self, _: type(None), **kwds) -> 'Stroke': + def title(self, _: Type[None], **kwds) -> 'Stroke': ... def type(self, _: str, **kwds) -> 'Stroke': @@ -8767,7 +8767,7 @@ def title(self, **kwds) -> 'StrokeDatum': ... @overload - def title(self, _: type(None), **kwds) -> 'StrokeDatum': + def title(self, _: Type[None], **kwds) -> 'StrokeDatum': ... def type(self, _: str, **kwds) -> 'StrokeDatum': @@ -9073,7 +9073,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: type(None), **kwds) -> 'StrokeDash': + def bin(self, _: Type[None], **kwds) -> 'StrokeDash': ... @overload @@ -9097,7 +9097,7 @@ def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, ... @overload - def legend(self, _: type(None), **kwds) -> 'StrokeDash': + def legend(self, _: Type[None], **kwds) -> 'StrokeDash': ... @overload @@ -9105,7 +9105,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: type(None), **kwds) -> 'StrokeDash': + def scale(self, _: Type[None], **kwds) -> 'StrokeDash': ... @overload @@ -9125,7 +9125,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'StrokeDash': ... @overload - def sort(self, _: type(None), **kwds) -> 'StrokeDash': + def sort(self, _: Type[None], **kwds) -> 'StrokeDash': ... @overload @@ -9141,7 +9141,7 @@ def title(self, **kwds) -> 'StrokeDash': ... @overload - def title(self, _: type(None), **kwds) -> 'StrokeDash': + def title(self, _: Type[None], **kwds) -> 'StrokeDash': ... def type(self, _: str, **kwds) -> 'StrokeDash': @@ -9292,7 +9292,7 @@ def title(self, **kwds) -> 'StrokeDashDatum': ... @overload - def title(self, _: type(None), **kwds) -> 'StrokeDashDatum': + def title(self, _: Type[None], **kwds) -> 'StrokeDashDatum': ... def type(self, _: str, **kwds) -> 'StrokeDashDatum': @@ -9598,7 +9598,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: type(None), **kwds) -> 'StrokeOpacity': + def bin(self, _: Type[None], **kwds) -> 'StrokeOpacity': ... @overload @@ -9622,7 +9622,7 @@ def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, ... @overload - def legend(self, _: type(None), **kwds) -> 'StrokeOpacity': + def legend(self, _: Type[None], **kwds) -> 'StrokeOpacity': ... @overload @@ -9630,7 +9630,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: type(None), **kwds) -> 'StrokeOpacity': + def scale(self, _: Type[None], **kwds) -> 'StrokeOpacity': ... @overload @@ -9650,7 +9650,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'StrokeOpacity': ... @overload - def sort(self, _: type(None), **kwds) -> 'StrokeOpacity': + def sort(self, _: Type[None], **kwds) -> 'StrokeOpacity': ... @overload @@ -9666,7 +9666,7 @@ def title(self, **kwds) -> 'StrokeOpacity': ... @overload - def title(self, _: type(None), **kwds) -> 'StrokeOpacity': + def title(self, _: Type[None], **kwds) -> 'StrokeOpacity': ... def type(self, _: str, **kwds) -> 'StrokeOpacity': @@ -9817,7 +9817,7 @@ def title(self, **kwds) -> 'StrokeOpacityDatum': ... @overload - def title(self, _: type(None), **kwds) -> 'StrokeOpacityDatum': + def title(self, _: Type[None], **kwds) -> 'StrokeOpacityDatum': ... def type(self, _: str, **kwds) -> 'StrokeOpacityDatum': @@ -10122,7 +10122,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: type(None), **kwds) -> 'StrokeWidth': + def bin(self, _: Type[None], **kwds) -> 'StrokeWidth': ... @overload @@ -10146,7 +10146,7 @@ def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, ... @overload - def legend(self, _: type(None), **kwds) -> 'StrokeWidth': + def legend(self, _: Type[None], **kwds) -> 'StrokeWidth': ... @overload @@ -10154,7 +10154,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: type(None), **kwds) -> 'StrokeWidth': + def scale(self, _: Type[None], **kwds) -> 'StrokeWidth': ... @overload @@ -10174,7 +10174,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'StrokeWidth': ... @overload - def sort(self, _: type(None), **kwds) -> 'StrokeWidth': + def sort(self, _: Type[None], **kwds) -> 'StrokeWidth': ... @overload @@ -10190,7 +10190,7 @@ def title(self, **kwds) -> 'StrokeWidth': ... @overload - def title(self, _: type(None), **kwds) -> 'StrokeWidth': + def title(self, _: Type[None], **kwds) -> 'StrokeWidth': ... def type(self, _: str, **kwds) -> 'StrokeWidth': @@ -10341,7 +10341,7 @@ def title(self, **kwds) -> 'StrokeWidthDatum': ... @overload - def title(self, _: type(None), **kwds) -> 'StrokeWidthDatum': + def title(self, _: Type[None], **kwds) -> 'StrokeWidthDatum': ... def type(self, _: str, **kwds) -> 'StrokeWidthDatum': @@ -10624,7 +10624,7 @@ def bin(self, _: str, **kwds) -> 'Text': ... @overload - def bin(self, _: type(None), **kwds) -> 'Text': + def bin(self, _: Type[None], **kwds) -> 'Text': ... @overload @@ -10667,7 +10667,7 @@ def title(self, **kwds) -> 'Text': ... @overload - def title(self, _: type(None), **kwds) -> 'Text': + def title(self, _: Type[None], **kwds) -> 'Text': ... def type(self, _: str, **kwds) -> 'Text': @@ -10863,7 +10863,7 @@ def title(self, **kwds) -> 'TextDatum': ... @overload - def title(self, _: type(None), **kwds) -> 'TextDatum': + def title(self, _: Type[None], **kwds) -> 'TextDatum': ... def type(self, _: str, **kwds) -> 'TextDatum': @@ -11184,7 +11184,7 @@ def bin(self, _: str, **kwds) -> 'Theta': ... @overload - def bin(self, _: type(None), **kwds) -> 'Theta': + def bin(self, _: Type[None], **kwds) -> 'Theta': ... @overload @@ -11200,7 +11200,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: type(None), **kwds) -> 'Theta': + def scale(self, _: Type[None], **kwds) -> 'Theta': ... @overload @@ -11220,7 +11220,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Theta': ... @overload - def sort(self, _: type(None), **kwds) -> 'Theta': + def sort(self, _: Type[None], **kwds) -> 'Theta': ... @overload @@ -11228,7 +11228,7 @@ def stack(self, _: str, **kwds) -> 'Theta': ... @overload - def stack(self, _: type(None), **kwds) -> 'Theta': + def stack(self, _: Type[None], **kwds) -> 'Theta': ... @overload @@ -11248,7 +11248,7 @@ def title(self, **kwds) -> 'Theta': ... @overload - def title(self, _: type(None), **kwds) -> 'Theta': + def title(self, _: Type[None], **kwds) -> 'Theta': ... def type(self, _: str, **kwds) -> 'Theta': @@ -11423,7 +11423,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: type(None), **kwds) -> 'ThetaDatum': + def scale(self, _: Type[None], **kwds) -> 'ThetaDatum': ... @overload @@ -11431,7 +11431,7 @@ def stack(self, _: str, **kwds) -> 'ThetaDatum': ... @overload - def stack(self, _: type(None), **kwds) -> 'ThetaDatum': + def stack(self, _: Type[None], **kwds) -> 'ThetaDatum': ... @overload @@ -11443,7 +11443,7 @@ def title(self, **kwds) -> 'ThetaDatum': ... @overload - def title(self, _: type(None), **kwds) -> 'ThetaDatum': + def title(self, _: Type[None], **kwds) -> 'ThetaDatum': ... def type(self, _: str, **kwds) -> 'ThetaDatum': @@ -11590,7 +11590,7 @@ def aggregate(self, argmin=Undefined, **kwds) -> 'Theta2': def bandPosition(self, _: float, **kwds) -> 'Theta2': ... - def bin(self, _: type(None), **kwds) -> 'Theta2': + def bin(self, _: Type[None], **kwds) -> 'Theta2': ... @overload @@ -11614,7 +11614,7 @@ def title(self, **kwds) -> 'Theta2': ... @overload - def title(self, _: type(None), **kwds) -> 'Theta2': + def title(self, _: Type[None], **kwds) -> 'Theta2': ... @@ -11742,7 +11742,7 @@ def title(self, **kwds) -> 'Theta2Datum': ... @overload - def title(self, _: type(None), **kwds) -> 'Theta2Datum': + def title(self, _: Type[None], **kwds) -> 'Theta2Datum': ... def type(self, _: str, **kwds) -> 'Theta2Datum': @@ -12012,7 +12012,7 @@ def bin(self, _: str, **kwds) -> 'Tooltip': ... @overload - def bin(self, _: type(None), **kwds) -> 'Tooltip': + def bin(self, _: Type[None], **kwds) -> 'Tooltip': ... @overload @@ -12055,7 +12055,7 @@ def title(self, **kwds) -> 'Tooltip': ... @overload - def title(self, _: type(None), **kwds) -> 'Tooltip': + def title(self, _: Type[None], **kwds) -> 'Tooltip': ... def type(self, _: str, **kwds) -> 'Tooltip': @@ -12342,7 +12342,7 @@ def bin(self, _: str, **kwds) -> 'Url': ... @overload - def bin(self, _: type(None), **kwds) -> 'Url': + def bin(self, _: Type[None], **kwds) -> 'Url': ... @overload @@ -12385,7 +12385,7 @@ def title(self, **kwds) -> 'Url': ... @overload - def title(self, _: type(None), **kwds) -> 'Url': + def title(self, _: Type[None], **kwds) -> 'Url': ... def type(self, _: str, **kwds) -> 'Url': @@ -12715,7 +12715,7 @@ def axis(self, aria=Undefined, bandPosition=Undefined, description=Undefined, do ... @overload - def axis(self, _: type(None), **kwds) -> 'X': + def axis(self, _: Type[None], **kwds) -> 'X': ... def bandPosition(self, _: float, **kwds) -> 'X': @@ -12734,7 +12734,7 @@ def bin(self, _: str, **kwds) -> 'X': ... @overload - def bin(self, _: type(None), **kwds) -> 'X': + def bin(self, _: Type[None], **kwds) -> 'X': ... @overload @@ -12750,7 +12750,7 @@ def impute(self, frame=Undefined, keyvals=Undefined, method=Undefined, value=Und ... @overload - def impute(self, _: type(None), **kwds) -> 'X': + def impute(self, _: Type[None], **kwds) -> 'X': ... @overload @@ -12758,7 +12758,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: type(None), **kwds) -> 'X': + def scale(self, _: Type[None], **kwds) -> 'X': ... @overload @@ -12778,7 +12778,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'X': ... @overload - def sort(self, _: type(None), **kwds) -> 'X': + def sort(self, _: Type[None], **kwds) -> 'X': ... @overload @@ -12786,7 +12786,7 @@ def stack(self, _: str, **kwds) -> 'X': ... @overload - def stack(self, _: type(None), **kwds) -> 'X': + def stack(self, _: Type[None], **kwds) -> 'X': ... @overload @@ -12806,7 +12806,7 @@ def title(self, **kwds) -> 'X': ... @overload - def title(self, _: type(None), **kwds) -> 'X': + def title(self, _: Type[None], **kwds) -> 'X': ... def type(self, _: str, **kwds) -> 'X': @@ -12996,7 +12996,7 @@ def axis(self, aria=Undefined, bandPosition=Undefined, description=Undefined, do ... @overload - def axis(self, _: type(None), **kwds) -> 'XDatum': + def axis(self, _: Type[None], **kwds) -> 'XDatum': ... def bandPosition(self, _: float, **kwds) -> 'XDatum': @@ -13007,7 +13007,7 @@ def impute(self, frame=Undefined, keyvals=Undefined, method=Undefined, value=Und ... @overload - def impute(self, _: type(None), **kwds) -> 'XDatum': + def impute(self, _: Type[None], **kwds) -> 'XDatum': ... @overload @@ -13015,7 +13015,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: type(None), **kwds) -> 'XDatum': + def scale(self, _: Type[None], **kwds) -> 'XDatum': ... @overload @@ -13023,7 +13023,7 @@ def stack(self, _: str, **kwds) -> 'XDatum': ... @overload - def stack(self, _: type(None), **kwds) -> 'XDatum': + def stack(self, _: Type[None], **kwds) -> 'XDatum': ... @overload @@ -13035,7 +13035,7 @@ def title(self, **kwds) -> 'XDatum': ... @overload - def title(self, _: type(None), **kwds) -> 'XDatum': + def title(self, _: Type[None], **kwds) -> 'XDatum': ... def type(self, _: str, **kwds) -> 'XDatum': @@ -13182,7 +13182,7 @@ def aggregate(self, argmin=Undefined, **kwds) -> 'X2': def bandPosition(self, _: float, **kwds) -> 'X2': ... - def bin(self, _: type(None), **kwds) -> 'X2': + def bin(self, _: Type[None], **kwds) -> 'X2': ... @overload @@ -13206,7 +13206,7 @@ def title(self, **kwds) -> 'X2': ... @overload - def title(self, _: type(None), **kwds) -> 'X2': + def title(self, _: Type[None], **kwds) -> 'X2': ... @@ -13333,7 +13333,7 @@ def title(self, **kwds) -> 'X2Datum': ... @overload - def title(self, _: type(None), **kwds) -> 'X2Datum': + def title(self, _: Type[None], **kwds) -> 'X2Datum': ... def type(self, _: str, **kwds) -> 'X2Datum': @@ -13479,7 +13479,7 @@ def aggregate(self, argmin=Undefined, **kwds) -> 'XError': def bandPosition(self, _: float, **kwds) -> 'XError': ... - def bin(self, _: type(None), **kwds) -> 'XError': + def bin(self, _: Type[None], **kwds) -> 'XError': ... @overload @@ -13503,7 +13503,7 @@ def title(self, **kwds) -> 'XError': ... @overload - def title(self, _: type(None), **kwds) -> 'XError': + def title(self, _: Type[None], **kwds) -> 'XError': ... @@ -13648,7 +13648,7 @@ def aggregate(self, argmin=Undefined, **kwds) -> 'XError2': def bandPosition(self, _: float, **kwds) -> 'XError2': ... - def bin(self, _: type(None), **kwds) -> 'XError2': + def bin(self, _: Type[None], **kwds) -> 'XError2': ... @overload @@ -13672,7 +13672,7 @@ def title(self, **kwds) -> 'XError2': ... @overload - def title(self, _: type(None), **kwds) -> 'XError2': + def title(self, _: Type[None], **kwds) -> 'XError2': ... @@ -13944,7 +13944,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: type(None), **kwds) -> 'XOffset': + def bin(self, _: Type[None], **kwds) -> 'XOffset': ... @overload @@ -13960,7 +13960,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: type(None), **kwds) -> 'XOffset': + def scale(self, _: Type[None], **kwds) -> 'XOffset': ... @overload @@ -13980,7 +13980,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'XOffset': ... @overload - def sort(self, _: type(None), **kwds) -> 'XOffset': + def sort(self, _: Type[None], **kwds) -> 'XOffset': ... @overload @@ -13996,7 +13996,7 @@ def title(self, **kwds) -> 'XOffset': ... @overload - def title(self, _: type(None), **kwds) -> 'XOffset': + def title(self, _: Type[None], **kwds) -> 'XOffset': ... def type(self, _: str, **kwds) -> 'XOffset': @@ -14141,7 +14141,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: type(None), **kwds) -> 'XOffsetDatum': + def scale(self, _: Type[None], **kwds) -> 'XOffsetDatum': ... @overload @@ -14149,7 +14149,7 @@ def title(self, **kwds) -> 'XOffsetDatum': ... @overload - def title(self, _: type(None), **kwds) -> 'XOffsetDatum': + def title(self, _: Type[None], **kwds) -> 'XOffsetDatum': ... def type(self, _: str, **kwds) -> 'XOffsetDatum': @@ -14463,7 +14463,7 @@ def axis(self, aria=Undefined, bandPosition=Undefined, description=Undefined, do ... @overload - def axis(self, _: type(None), **kwds) -> 'Y': + def axis(self, _: Type[None], **kwds) -> 'Y': ... def bandPosition(self, _: float, **kwds) -> 'Y': @@ -14482,7 +14482,7 @@ def bin(self, _: str, **kwds) -> 'Y': ... @overload - def bin(self, _: type(None), **kwds) -> 'Y': + def bin(self, _: Type[None], **kwds) -> 'Y': ... @overload @@ -14498,7 +14498,7 @@ def impute(self, frame=Undefined, keyvals=Undefined, method=Undefined, value=Und ... @overload - def impute(self, _: type(None), **kwds) -> 'Y': + def impute(self, _: Type[None], **kwds) -> 'Y': ... @overload @@ -14506,7 +14506,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: type(None), **kwds) -> 'Y': + def scale(self, _: Type[None], **kwds) -> 'Y': ... @overload @@ -14526,7 +14526,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Y': ... @overload - def sort(self, _: type(None), **kwds) -> 'Y': + def sort(self, _: Type[None], **kwds) -> 'Y': ... @overload @@ -14534,7 +14534,7 @@ def stack(self, _: str, **kwds) -> 'Y': ... @overload - def stack(self, _: type(None), **kwds) -> 'Y': + def stack(self, _: Type[None], **kwds) -> 'Y': ... @overload @@ -14554,7 +14554,7 @@ def title(self, **kwds) -> 'Y': ... @overload - def title(self, _: type(None), **kwds) -> 'Y': + def title(self, _: Type[None], **kwds) -> 'Y': ... def type(self, _: str, **kwds) -> 'Y': @@ -14744,7 +14744,7 @@ def axis(self, aria=Undefined, bandPosition=Undefined, description=Undefined, do ... @overload - def axis(self, _: type(None), **kwds) -> 'YDatum': + def axis(self, _: Type[None], **kwds) -> 'YDatum': ... def bandPosition(self, _: float, **kwds) -> 'YDatum': @@ -14755,7 +14755,7 @@ def impute(self, frame=Undefined, keyvals=Undefined, method=Undefined, value=Und ... @overload - def impute(self, _: type(None), **kwds) -> 'YDatum': + def impute(self, _: Type[None], **kwds) -> 'YDatum': ... @overload @@ -14763,7 +14763,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: type(None), **kwds) -> 'YDatum': + def scale(self, _: Type[None], **kwds) -> 'YDatum': ... @overload @@ -14771,7 +14771,7 @@ def stack(self, _: str, **kwds) -> 'YDatum': ... @overload - def stack(self, _: type(None), **kwds) -> 'YDatum': + def stack(self, _: Type[None], **kwds) -> 'YDatum': ... @overload @@ -14783,7 +14783,7 @@ def title(self, **kwds) -> 'YDatum': ... @overload - def title(self, _: type(None), **kwds) -> 'YDatum': + def title(self, _: Type[None], **kwds) -> 'YDatum': ... def type(self, _: str, **kwds) -> 'YDatum': @@ -14930,7 +14930,7 @@ def aggregate(self, argmin=Undefined, **kwds) -> 'Y2': def bandPosition(self, _: float, **kwds) -> 'Y2': ... - def bin(self, _: type(None), **kwds) -> 'Y2': + def bin(self, _: Type[None], **kwds) -> 'Y2': ... @overload @@ -14954,7 +14954,7 @@ def title(self, **kwds) -> 'Y2': ... @overload - def title(self, _: type(None), **kwds) -> 'Y2': + def title(self, _: Type[None], **kwds) -> 'Y2': ... @@ -15081,7 +15081,7 @@ def title(self, **kwds) -> 'Y2Datum': ... @overload - def title(self, _: type(None), **kwds) -> 'Y2Datum': + def title(self, _: Type[None], **kwds) -> 'Y2Datum': ... def type(self, _: str, **kwds) -> 'Y2Datum': @@ -15227,7 +15227,7 @@ def aggregate(self, argmin=Undefined, **kwds) -> 'YError': def bandPosition(self, _: float, **kwds) -> 'YError': ... - def bin(self, _: type(None), **kwds) -> 'YError': + def bin(self, _: Type[None], **kwds) -> 'YError': ... @overload @@ -15251,7 +15251,7 @@ def title(self, **kwds) -> 'YError': ... @overload - def title(self, _: type(None), **kwds) -> 'YError': + def title(self, _: Type[None], **kwds) -> 'YError': ... @@ -15396,7 +15396,7 @@ def aggregate(self, argmin=Undefined, **kwds) -> 'YError2': def bandPosition(self, _: float, **kwds) -> 'YError2': ... - def bin(self, _: type(None), **kwds) -> 'YError2': + def bin(self, _: Type[None], **kwds) -> 'YError2': ... @overload @@ -15420,7 +15420,7 @@ def title(self, **kwds) -> 'YError2': ... @overload - def title(self, _: type(None), **kwds) -> 'YError2': + def title(self, _: Type[None], **kwds) -> 'YError2': ... @@ -15692,7 +15692,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: type(None), **kwds) -> 'YOffset': + def bin(self, _: Type[None], **kwds) -> 'YOffset': ... @overload @@ -15708,7 +15708,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: type(None), **kwds) -> 'YOffset': + def scale(self, _: Type[None], **kwds) -> 'YOffset': ... @overload @@ -15728,7 +15728,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'YOffset': ... @overload - def sort(self, _: type(None), **kwds) -> 'YOffset': + def sort(self, _: Type[None], **kwds) -> 'YOffset': ... @overload @@ -15744,7 +15744,7 @@ def title(self, **kwds) -> 'YOffset': ... @overload - def title(self, _: type(None), **kwds) -> 'YOffset': + def title(self, _: Type[None], **kwds) -> 'YOffset': ... def type(self, _: str, **kwds) -> 'YOffset': @@ -15889,7 +15889,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: type(None), **kwds) -> 'YOffsetDatum': + def scale(self, _: Type[None], **kwds) -> 'YOffsetDatum': ... @overload @@ -15897,7 +15897,7 @@ def title(self, **kwds) -> 'YOffsetDatum': ... @overload - def title(self, _: type(None), **kwds) -> 'YOffsetDatum': + def title(self, _: Type[None], **kwds) -> 'YOffsetDatum': ... def type(self, _: str, **kwds) -> 'YOffsetDatum': diff --git a/tools/generate_schema_wrapper.py b/tools/generate_schema_wrapper.py index 79bceb660..7f17694ec 100644 --- a/tools/generate_schema_wrapper.py +++ b/tools/generate_schema_wrapper.py @@ -441,7 +441,7 @@ def generate_vegalite_channel_wrappers(schemafile, version, imports=None): "import pandas as pd", "from altair.utils.schemapi import Undefined, with_property_setters", "from altair.utils import parse_shorthand", - "from typing import overload", + "from typing import overload, Type", ] contents = [HEADER] contents.extend(imports) diff --git a/tools/schemapi/codegen.py b/tools/schemapi/codegen.py index f82add11c..0984be6c8 100644 --- a/tools/schemapi/codegen.py +++ b/tools/schemapi/codegen.py @@ -230,7 +230,7 @@ def init_code(self, indent=0): "object": "dict", "boolean": "bool", "array": "list", - "null": "type(None)", + "null": "Type[None]", } def get_args(self, si): From 394e3c865a6e4beee649fb1346bc610253654eca Mon Sep 17 00:00:00 2001 From: Christopher Davis Date: Tue, 27 Dec 2022 07:59:20 -0600 Subject: [PATCH 20/26] Replace Type[None] with None --- altair/vegalite/v5/schema/channels.py | 358 +++++++++++++------------- tools/schemapi/codegen.py | 2 +- 2 files changed, 180 insertions(+), 180 deletions(-) diff --git a/altair/vegalite/v5/schema/channels.py b/altair/vegalite/v5/schema/channels.py index 0bef47f82..385becda6 100644 --- a/altair/vegalite/v5/schema/channels.py +++ b/altair/vegalite/v5/schema/channels.py @@ -347,7 +347,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: Type[None], **kwds) -> 'Angle': + def bin(self, _: None, **kwds) -> 'Angle': ... @overload @@ -371,7 +371,7 @@ def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, ... @overload - def legend(self, _: Type[None], **kwds) -> 'Angle': + def legend(self, _: None, **kwds) -> 'Angle': ... @overload @@ -379,7 +379,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: Type[None], **kwds) -> 'Angle': + def scale(self, _: None, **kwds) -> 'Angle': ... @overload @@ -399,7 +399,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Angle': ... @overload - def sort(self, _: Type[None], **kwds) -> 'Angle': + def sort(self, _: None, **kwds) -> 'Angle': ... @overload @@ -415,7 +415,7 @@ def title(self, **kwds) -> 'Angle': ... @overload - def title(self, _: Type[None], **kwds) -> 'Angle': + def title(self, _: None, **kwds) -> 'Angle': ... def type(self, _: str, **kwds) -> 'Angle': @@ -566,7 +566,7 @@ def title(self, **kwds) -> 'AngleDatum': ... @overload - def title(self, _: Type[None], **kwds) -> 'AngleDatum': + def title(self, _: None, **kwds) -> 'AngleDatum': ... def type(self, _: str, **kwds) -> 'AngleDatum': @@ -871,7 +871,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: Type[None], **kwds) -> 'Color': + def bin(self, _: None, **kwds) -> 'Color': ... @overload @@ -895,7 +895,7 @@ def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, ... @overload - def legend(self, _: Type[None], **kwds) -> 'Color': + def legend(self, _: None, **kwds) -> 'Color': ... @overload @@ -903,7 +903,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: Type[None], **kwds) -> 'Color': + def scale(self, _: None, **kwds) -> 'Color': ... @overload @@ -923,7 +923,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Color': ... @overload - def sort(self, _: Type[None], **kwds) -> 'Color': + def sort(self, _: None, **kwds) -> 'Color': ... @overload @@ -939,7 +939,7 @@ def title(self, **kwds) -> 'Color': ... @overload - def title(self, _: Type[None], **kwds) -> 'Color': + def title(self, _: None, **kwds) -> 'Color': ... def type(self, _: str, **kwds) -> 'Color': @@ -1090,7 +1090,7 @@ def title(self, **kwds) -> 'ColorDatum': ... @overload - def title(self, _: Type[None], **kwds) -> 'ColorDatum': + def title(self, _: None, **kwds) -> 'ColorDatum': ... def type(self, _: str, **kwds) -> 'ColorDatum': @@ -1382,7 +1382,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: Type[None], **kwds) -> 'Column': + def bin(self, _: None, **kwds) -> 'Column': ... def center(self, _: bool, **kwds) -> 'Column': @@ -1401,7 +1401,7 @@ def header(self, format=Undefined, formatType=Undefined, labelAlign=Undefined, l ... @overload - def header(self, _: Type[None], **kwds) -> 'Column': + def header(self, _: None, **kwds) -> 'Column': ... @overload @@ -1417,7 +1417,7 @@ def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Colum ... @overload - def sort(self, _: Type[None], **kwds) -> 'Column': + def sort(self, _: None, **kwds) -> 'Column': ... def spacing(self, _: float, **kwds) -> 'Column': @@ -1436,7 +1436,7 @@ def title(self, **kwds) -> 'Column': ... @overload - def title(self, _: Type[None], **kwds) -> 'Column': + def title(self, _: None, **kwds) -> 'Column': ... def type(self, _: str, **kwds) -> 'Column': @@ -1686,7 +1686,7 @@ def bin(self, _: str, **kwds) -> 'Description': ... @overload - def bin(self, _: Type[None], **kwds) -> 'Description': + def bin(self, _: None, **kwds) -> 'Description': ... @overload @@ -1729,7 +1729,7 @@ def title(self, **kwds) -> 'Description': ... @overload - def title(self, _: Type[None], **kwds) -> 'Description': + def title(self, _: None, **kwds) -> 'Description': ... def type(self, _: str, **kwds) -> 'Description': @@ -1973,7 +1973,7 @@ def bin(self, _: str, **kwds) -> 'Detail': ... @overload - def bin(self, _: Type[None], **kwds) -> 'Detail': + def bin(self, _: None, **kwds) -> 'Detail': ... @overload @@ -1997,7 +1997,7 @@ def title(self, **kwds) -> 'Detail': ... @overload - def title(self, _: Type[None], **kwds) -> 'Detail': + def title(self, _: None, **kwds) -> 'Detail': ... def type(self, _: str, **kwds) -> 'Detail': @@ -2295,7 +2295,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: Type[None], **kwds) -> 'Facet': + def bin(self, _: None, **kwds) -> 'Facet': ... def bounds(self, _: str, **kwds) -> 'Facet': @@ -2325,7 +2325,7 @@ def header(self, format=Undefined, formatType=Undefined, labelAlign=Undefined, l ... @overload - def header(self, _: Type[None], **kwds) -> 'Facet': + def header(self, _: None, **kwds) -> 'Facet': ... @overload @@ -2341,7 +2341,7 @@ def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Facet ... @overload - def sort(self, _: Type[None], **kwds) -> 'Facet': + def sort(self, _: None, **kwds) -> 'Facet': ... @overload @@ -2365,7 +2365,7 @@ def title(self, **kwds) -> 'Facet': ... @overload - def title(self, _: Type[None], **kwds) -> 'Facet': + def title(self, _: None, **kwds) -> 'Facet': ... def type(self, _: str, **kwds) -> 'Facet': @@ -2637,7 +2637,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: Type[None], **kwds) -> 'Fill': + def bin(self, _: None, **kwds) -> 'Fill': ... @overload @@ -2661,7 +2661,7 @@ def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, ... @overload - def legend(self, _: Type[None], **kwds) -> 'Fill': + def legend(self, _: None, **kwds) -> 'Fill': ... @overload @@ -2669,7 +2669,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: Type[None], **kwds) -> 'Fill': + def scale(self, _: None, **kwds) -> 'Fill': ... @overload @@ -2689,7 +2689,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Fill': ... @overload - def sort(self, _: Type[None], **kwds) -> 'Fill': + def sort(self, _: None, **kwds) -> 'Fill': ... @overload @@ -2705,7 +2705,7 @@ def title(self, **kwds) -> 'Fill': ... @overload - def title(self, _: Type[None], **kwds) -> 'Fill': + def title(self, _: None, **kwds) -> 'Fill': ... def type(self, _: str, **kwds) -> 'Fill': @@ -2856,7 +2856,7 @@ def title(self, **kwds) -> 'FillDatum': ... @overload - def title(self, _: Type[None], **kwds) -> 'FillDatum': + def title(self, _: None, **kwds) -> 'FillDatum': ... def type(self, _: str, **kwds) -> 'FillDatum': @@ -3162,7 +3162,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: Type[None], **kwds) -> 'FillOpacity': + def bin(self, _: None, **kwds) -> 'FillOpacity': ... @overload @@ -3186,7 +3186,7 @@ def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, ... @overload - def legend(self, _: Type[None], **kwds) -> 'FillOpacity': + def legend(self, _: None, **kwds) -> 'FillOpacity': ... @overload @@ -3194,7 +3194,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: Type[None], **kwds) -> 'FillOpacity': + def scale(self, _: None, **kwds) -> 'FillOpacity': ... @overload @@ -3214,7 +3214,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'FillOpacity': ... @overload - def sort(self, _: Type[None], **kwds) -> 'FillOpacity': + def sort(self, _: None, **kwds) -> 'FillOpacity': ... @overload @@ -3230,7 +3230,7 @@ def title(self, **kwds) -> 'FillOpacity': ... @overload - def title(self, _: Type[None], **kwds) -> 'FillOpacity': + def title(self, _: None, **kwds) -> 'FillOpacity': ... def type(self, _: str, **kwds) -> 'FillOpacity': @@ -3381,7 +3381,7 @@ def title(self, **kwds) -> 'FillOpacityDatum': ... @overload - def title(self, _: Type[None], **kwds) -> 'FillOpacityDatum': + def title(self, _: None, **kwds) -> 'FillOpacityDatum': ... def type(self, _: str, **kwds) -> 'FillOpacityDatum': @@ -3664,7 +3664,7 @@ def bin(self, _: str, **kwds) -> 'Href': ... @overload - def bin(self, _: Type[None], **kwds) -> 'Href': + def bin(self, _: None, **kwds) -> 'Href': ... @overload @@ -3707,7 +3707,7 @@ def title(self, **kwds) -> 'Href': ... @overload - def title(self, _: Type[None], **kwds) -> 'Href': + def title(self, _: None, **kwds) -> 'Href': ... def type(self, _: str, **kwds) -> 'Href': @@ -3951,7 +3951,7 @@ def bin(self, _: str, **kwds) -> 'Key': ... @overload - def bin(self, _: Type[None], **kwds) -> 'Key': + def bin(self, _: None, **kwds) -> 'Key': ... @overload @@ -3975,7 +3975,7 @@ def title(self, **kwds) -> 'Key': ... @overload - def title(self, _: Type[None], **kwds) -> 'Key': + def title(self, _: None, **kwds) -> 'Key': ... def type(self, _: str, **kwds) -> 'Key': @@ -4165,7 +4165,7 @@ def aggregate(self, argmin=Undefined, **kwds) -> 'Latitude': def bandPosition(self, _: float, **kwds) -> 'Latitude': ... - def bin(self, _: Type[None], **kwds) -> 'Latitude': + def bin(self, _: None, **kwds) -> 'Latitude': ... @overload @@ -4189,7 +4189,7 @@ def title(self, **kwds) -> 'Latitude': ... @overload - def title(self, _: Type[None], **kwds) -> 'Latitude': + def title(self, _: None, **kwds) -> 'Latitude': ... def type(self, _: str, **kwds) -> 'Latitude': @@ -4320,7 +4320,7 @@ def title(self, **kwds) -> 'LatitudeDatum': ... @overload - def title(self, _: Type[None], **kwds) -> 'LatitudeDatum': + def title(self, _: None, **kwds) -> 'LatitudeDatum': ... def type(self, _: str, **kwds) -> 'LatitudeDatum': @@ -4441,7 +4441,7 @@ def aggregate(self, argmin=Undefined, **kwds) -> 'Latitude2': def bandPosition(self, _: float, **kwds) -> 'Latitude2': ... - def bin(self, _: Type[None], **kwds) -> 'Latitude2': + def bin(self, _: None, **kwds) -> 'Latitude2': ... @overload @@ -4465,7 +4465,7 @@ def title(self, **kwds) -> 'Latitude2': ... @overload - def title(self, _: Type[None], **kwds) -> 'Latitude2': + def title(self, _: None, **kwds) -> 'Latitude2': ... @@ -4593,7 +4593,7 @@ def title(self, **kwds) -> 'Latitude2Datum': ... @overload - def title(self, _: Type[None], **kwds) -> 'Latitude2Datum': + def title(self, _: None, **kwds) -> 'Latitude2Datum': ... def type(self, _: str, **kwds) -> 'Latitude2Datum': @@ -4806,7 +4806,7 @@ def aggregate(self, argmin=Undefined, **kwds) -> 'Longitude': def bandPosition(self, _: float, **kwds) -> 'Longitude': ... - def bin(self, _: Type[None], **kwds) -> 'Longitude': + def bin(self, _: None, **kwds) -> 'Longitude': ... @overload @@ -4830,7 +4830,7 @@ def title(self, **kwds) -> 'Longitude': ... @overload - def title(self, _: Type[None], **kwds) -> 'Longitude': + def title(self, _: None, **kwds) -> 'Longitude': ... def type(self, _: str, **kwds) -> 'Longitude': @@ -4961,7 +4961,7 @@ def title(self, **kwds) -> 'LongitudeDatum': ... @overload - def title(self, _: Type[None], **kwds) -> 'LongitudeDatum': + def title(self, _: None, **kwds) -> 'LongitudeDatum': ... def type(self, _: str, **kwds) -> 'LongitudeDatum': @@ -5082,7 +5082,7 @@ def aggregate(self, argmin=Undefined, **kwds) -> 'Longitude2': def bandPosition(self, _: float, **kwds) -> 'Longitude2': ... - def bin(self, _: Type[None], **kwds) -> 'Longitude2': + def bin(self, _: None, **kwds) -> 'Longitude2': ... @overload @@ -5106,7 +5106,7 @@ def title(self, **kwds) -> 'Longitude2': ... @overload - def title(self, _: Type[None], **kwds) -> 'Longitude2': + def title(self, _: None, **kwds) -> 'Longitude2': ... @@ -5234,7 +5234,7 @@ def title(self, **kwds) -> 'Longitude2Datum': ... @overload - def title(self, _: Type[None], **kwds) -> 'Longitude2Datum': + def title(self, _: None, **kwds) -> 'Longitude2Datum': ... def type(self, _: str, **kwds) -> 'Longitude2Datum': @@ -5526,7 +5526,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: Type[None], **kwds) -> 'Opacity': + def bin(self, _: None, **kwds) -> 'Opacity': ... @overload @@ -5550,7 +5550,7 @@ def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, ... @overload - def legend(self, _: Type[None], **kwds) -> 'Opacity': + def legend(self, _: None, **kwds) -> 'Opacity': ... @overload @@ -5558,7 +5558,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: Type[None], **kwds) -> 'Opacity': + def scale(self, _: None, **kwds) -> 'Opacity': ... @overload @@ -5578,7 +5578,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Opacity': ... @overload - def sort(self, _: Type[None], **kwds) -> 'Opacity': + def sort(self, _: None, **kwds) -> 'Opacity': ... @overload @@ -5594,7 +5594,7 @@ def title(self, **kwds) -> 'Opacity': ... @overload - def title(self, _: Type[None], **kwds) -> 'Opacity': + def title(self, _: None, **kwds) -> 'Opacity': ... def type(self, _: str, **kwds) -> 'Opacity': @@ -5745,7 +5745,7 @@ def title(self, **kwds) -> 'OpacityDatum': ... @overload - def title(self, _: Type[None], **kwds) -> 'OpacityDatum': + def title(self, _: None, **kwds) -> 'OpacityDatum': ... def type(self, _: str, **kwds) -> 'OpacityDatum': @@ -5986,7 +5986,7 @@ def bin(self, _: str, **kwds) -> 'Order': ... @overload - def bin(self, _: Type[None], **kwds) -> 'Order': + def bin(self, _: None, **kwds) -> 'Order': ... @overload @@ -6013,7 +6013,7 @@ def title(self, **kwds) -> 'Order': ... @overload - def title(self, _: Type[None], **kwds) -> 'Order': + def title(self, _: None, **kwds) -> 'Order': ... def type(self, _: str, **kwds) -> 'Order': @@ -6336,7 +6336,7 @@ def bin(self, _: str, **kwds) -> 'Radius': ... @overload - def bin(self, _: Type[None], **kwds) -> 'Radius': + def bin(self, _: None, **kwds) -> 'Radius': ... @overload @@ -6352,7 +6352,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: Type[None], **kwds) -> 'Radius': + def scale(self, _: None, **kwds) -> 'Radius': ... @overload @@ -6372,7 +6372,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Radius': ... @overload - def sort(self, _: Type[None], **kwds) -> 'Radius': + def sort(self, _: None, **kwds) -> 'Radius': ... @overload @@ -6380,7 +6380,7 @@ def stack(self, _: str, **kwds) -> 'Radius': ... @overload - def stack(self, _: Type[None], **kwds) -> 'Radius': + def stack(self, _: None, **kwds) -> 'Radius': ... @overload @@ -6400,7 +6400,7 @@ def title(self, **kwds) -> 'Radius': ... @overload - def title(self, _: Type[None], **kwds) -> 'Radius': + def title(self, _: None, **kwds) -> 'Radius': ... def type(self, _: str, **kwds) -> 'Radius': @@ -6576,7 +6576,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: Type[None], **kwds) -> 'RadiusDatum': + def scale(self, _: None, **kwds) -> 'RadiusDatum': ... @overload @@ -6584,7 +6584,7 @@ def stack(self, _: str, **kwds) -> 'RadiusDatum': ... @overload - def stack(self, _: Type[None], **kwds) -> 'RadiusDatum': + def stack(self, _: None, **kwds) -> 'RadiusDatum': ... @overload @@ -6596,7 +6596,7 @@ def title(self, **kwds) -> 'RadiusDatum': ... @overload - def title(self, _: Type[None], **kwds) -> 'RadiusDatum': + def title(self, _: None, **kwds) -> 'RadiusDatum': ... def type(self, _: str, **kwds) -> 'RadiusDatum': @@ -6743,7 +6743,7 @@ def aggregate(self, argmin=Undefined, **kwds) -> 'Radius2': def bandPosition(self, _: float, **kwds) -> 'Radius2': ... - def bin(self, _: Type[None], **kwds) -> 'Radius2': + def bin(self, _: None, **kwds) -> 'Radius2': ... @overload @@ -6767,7 +6767,7 @@ def title(self, **kwds) -> 'Radius2': ... @overload - def title(self, _: Type[None], **kwds) -> 'Radius2': + def title(self, _: None, **kwds) -> 'Radius2': ... @@ -6895,7 +6895,7 @@ def title(self, **kwds) -> 'Radius2Datum': ... @overload - def title(self, _: Type[None], **kwds) -> 'Radius2Datum': + def title(self, _: None, **kwds) -> 'Radius2Datum': ... def type(self, _: str, **kwds) -> 'Radius2Datum': @@ -7173,7 +7173,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: Type[None], **kwds) -> 'Row': + def bin(self, _: None, **kwds) -> 'Row': ... def center(self, _: bool, **kwds) -> 'Row': @@ -7192,7 +7192,7 @@ def header(self, format=Undefined, formatType=Undefined, labelAlign=Undefined, l ... @overload - def header(self, _: Type[None], **kwds) -> 'Row': + def header(self, _: None, **kwds) -> 'Row': ... @overload @@ -7208,7 +7208,7 @@ def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Row': ... @overload - def sort(self, _: Type[None], **kwds) -> 'Row': + def sort(self, _: None, **kwds) -> 'Row': ... def spacing(self, _: float, **kwds) -> 'Row': @@ -7227,7 +7227,7 @@ def title(self, **kwds) -> 'Row': ... @overload - def title(self, _: Type[None], **kwds) -> 'Row': + def title(self, _: None, **kwds) -> 'Row': ... def type(self, _: str, **kwds) -> 'Row': @@ -7499,7 +7499,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: Type[None], **kwds) -> 'Shape': + def bin(self, _: None, **kwds) -> 'Shape': ... @overload @@ -7523,7 +7523,7 @@ def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, ... @overload - def legend(self, _: Type[None], **kwds) -> 'Shape': + def legend(self, _: None, **kwds) -> 'Shape': ... @overload @@ -7531,7 +7531,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: Type[None], **kwds) -> 'Shape': + def scale(self, _: None, **kwds) -> 'Shape': ... @overload @@ -7551,7 +7551,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Shape': ... @overload - def sort(self, _: Type[None], **kwds) -> 'Shape': + def sort(self, _: None, **kwds) -> 'Shape': ... @overload @@ -7567,7 +7567,7 @@ def title(self, **kwds) -> 'Shape': ... @overload - def title(self, _: Type[None], **kwds) -> 'Shape': + def title(self, _: None, **kwds) -> 'Shape': ... def type(self, _: str, **kwds) -> 'Shape': @@ -7718,7 +7718,7 @@ def title(self, **kwds) -> 'ShapeDatum': ... @overload - def title(self, _: Type[None], **kwds) -> 'ShapeDatum': + def title(self, _: None, **kwds) -> 'ShapeDatum': ... def type(self, _: str, **kwds) -> 'ShapeDatum': @@ -8024,7 +8024,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: Type[None], **kwds) -> 'Size': + def bin(self, _: None, **kwds) -> 'Size': ... @overload @@ -8048,7 +8048,7 @@ def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, ... @overload - def legend(self, _: Type[None], **kwds) -> 'Size': + def legend(self, _: None, **kwds) -> 'Size': ... @overload @@ -8056,7 +8056,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: Type[None], **kwds) -> 'Size': + def scale(self, _: None, **kwds) -> 'Size': ... @overload @@ -8076,7 +8076,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Size': ... @overload - def sort(self, _: Type[None], **kwds) -> 'Size': + def sort(self, _: None, **kwds) -> 'Size': ... @overload @@ -8092,7 +8092,7 @@ def title(self, **kwds) -> 'Size': ... @overload - def title(self, _: Type[None], **kwds) -> 'Size': + def title(self, _: None, **kwds) -> 'Size': ... def type(self, _: str, **kwds) -> 'Size': @@ -8243,7 +8243,7 @@ def title(self, **kwds) -> 'SizeDatum': ... @overload - def title(self, _: Type[None], **kwds) -> 'SizeDatum': + def title(self, _: None, **kwds) -> 'SizeDatum': ... def type(self, _: str, **kwds) -> 'SizeDatum': @@ -8548,7 +8548,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: Type[None], **kwds) -> 'Stroke': + def bin(self, _: None, **kwds) -> 'Stroke': ... @overload @@ -8572,7 +8572,7 @@ def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, ... @overload - def legend(self, _: Type[None], **kwds) -> 'Stroke': + def legend(self, _: None, **kwds) -> 'Stroke': ... @overload @@ -8580,7 +8580,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: Type[None], **kwds) -> 'Stroke': + def scale(self, _: None, **kwds) -> 'Stroke': ... @overload @@ -8600,7 +8600,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Stroke': ... @overload - def sort(self, _: Type[None], **kwds) -> 'Stroke': + def sort(self, _: None, **kwds) -> 'Stroke': ... @overload @@ -8616,7 +8616,7 @@ def title(self, **kwds) -> 'Stroke': ... @overload - def title(self, _: Type[None], **kwds) -> 'Stroke': + def title(self, _: None, **kwds) -> 'Stroke': ... def type(self, _: str, **kwds) -> 'Stroke': @@ -8767,7 +8767,7 @@ def title(self, **kwds) -> 'StrokeDatum': ... @overload - def title(self, _: Type[None], **kwds) -> 'StrokeDatum': + def title(self, _: None, **kwds) -> 'StrokeDatum': ... def type(self, _: str, **kwds) -> 'StrokeDatum': @@ -9073,7 +9073,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: Type[None], **kwds) -> 'StrokeDash': + def bin(self, _: None, **kwds) -> 'StrokeDash': ... @overload @@ -9097,7 +9097,7 @@ def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, ... @overload - def legend(self, _: Type[None], **kwds) -> 'StrokeDash': + def legend(self, _: None, **kwds) -> 'StrokeDash': ... @overload @@ -9105,7 +9105,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: Type[None], **kwds) -> 'StrokeDash': + def scale(self, _: None, **kwds) -> 'StrokeDash': ... @overload @@ -9125,7 +9125,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'StrokeDash': ... @overload - def sort(self, _: Type[None], **kwds) -> 'StrokeDash': + def sort(self, _: None, **kwds) -> 'StrokeDash': ... @overload @@ -9141,7 +9141,7 @@ def title(self, **kwds) -> 'StrokeDash': ... @overload - def title(self, _: Type[None], **kwds) -> 'StrokeDash': + def title(self, _: None, **kwds) -> 'StrokeDash': ... def type(self, _: str, **kwds) -> 'StrokeDash': @@ -9292,7 +9292,7 @@ def title(self, **kwds) -> 'StrokeDashDatum': ... @overload - def title(self, _: Type[None], **kwds) -> 'StrokeDashDatum': + def title(self, _: None, **kwds) -> 'StrokeDashDatum': ... def type(self, _: str, **kwds) -> 'StrokeDashDatum': @@ -9598,7 +9598,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: Type[None], **kwds) -> 'StrokeOpacity': + def bin(self, _: None, **kwds) -> 'StrokeOpacity': ... @overload @@ -9622,7 +9622,7 @@ def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, ... @overload - def legend(self, _: Type[None], **kwds) -> 'StrokeOpacity': + def legend(self, _: None, **kwds) -> 'StrokeOpacity': ... @overload @@ -9630,7 +9630,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: Type[None], **kwds) -> 'StrokeOpacity': + def scale(self, _: None, **kwds) -> 'StrokeOpacity': ... @overload @@ -9650,7 +9650,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'StrokeOpacity': ... @overload - def sort(self, _: Type[None], **kwds) -> 'StrokeOpacity': + def sort(self, _: None, **kwds) -> 'StrokeOpacity': ... @overload @@ -9666,7 +9666,7 @@ def title(self, **kwds) -> 'StrokeOpacity': ... @overload - def title(self, _: Type[None], **kwds) -> 'StrokeOpacity': + def title(self, _: None, **kwds) -> 'StrokeOpacity': ... def type(self, _: str, **kwds) -> 'StrokeOpacity': @@ -9817,7 +9817,7 @@ def title(self, **kwds) -> 'StrokeOpacityDatum': ... @overload - def title(self, _: Type[None], **kwds) -> 'StrokeOpacityDatum': + def title(self, _: None, **kwds) -> 'StrokeOpacityDatum': ... def type(self, _: str, **kwds) -> 'StrokeOpacityDatum': @@ -10122,7 +10122,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: Type[None], **kwds) -> 'StrokeWidth': + def bin(self, _: None, **kwds) -> 'StrokeWidth': ... @overload @@ -10146,7 +10146,7 @@ def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, ... @overload - def legend(self, _: Type[None], **kwds) -> 'StrokeWidth': + def legend(self, _: None, **kwds) -> 'StrokeWidth': ... @overload @@ -10154,7 +10154,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: Type[None], **kwds) -> 'StrokeWidth': + def scale(self, _: None, **kwds) -> 'StrokeWidth': ... @overload @@ -10174,7 +10174,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'StrokeWidth': ... @overload - def sort(self, _: Type[None], **kwds) -> 'StrokeWidth': + def sort(self, _: None, **kwds) -> 'StrokeWidth': ... @overload @@ -10190,7 +10190,7 @@ def title(self, **kwds) -> 'StrokeWidth': ... @overload - def title(self, _: Type[None], **kwds) -> 'StrokeWidth': + def title(self, _: None, **kwds) -> 'StrokeWidth': ... def type(self, _: str, **kwds) -> 'StrokeWidth': @@ -10341,7 +10341,7 @@ def title(self, **kwds) -> 'StrokeWidthDatum': ... @overload - def title(self, _: Type[None], **kwds) -> 'StrokeWidthDatum': + def title(self, _: None, **kwds) -> 'StrokeWidthDatum': ... def type(self, _: str, **kwds) -> 'StrokeWidthDatum': @@ -10624,7 +10624,7 @@ def bin(self, _: str, **kwds) -> 'Text': ... @overload - def bin(self, _: Type[None], **kwds) -> 'Text': + def bin(self, _: None, **kwds) -> 'Text': ... @overload @@ -10667,7 +10667,7 @@ def title(self, **kwds) -> 'Text': ... @overload - def title(self, _: Type[None], **kwds) -> 'Text': + def title(self, _: None, **kwds) -> 'Text': ... def type(self, _: str, **kwds) -> 'Text': @@ -10863,7 +10863,7 @@ def title(self, **kwds) -> 'TextDatum': ... @overload - def title(self, _: Type[None], **kwds) -> 'TextDatum': + def title(self, _: None, **kwds) -> 'TextDatum': ... def type(self, _: str, **kwds) -> 'TextDatum': @@ -11184,7 +11184,7 @@ def bin(self, _: str, **kwds) -> 'Theta': ... @overload - def bin(self, _: Type[None], **kwds) -> 'Theta': + def bin(self, _: None, **kwds) -> 'Theta': ... @overload @@ -11200,7 +11200,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: Type[None], **kwds) -> 'Theta': + def scale(self, _: None, **kwds) -> 'Theta': ... @overload @@ -11220,7 +11220,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Theta': ... @overload - def sort(self, _: Type[None], **kwds) -> 'Theta': + def sort(self, _: None, **kwds) -> 'Theta': ... @overload @@ -11228,7 +11228,7 @@ def stack(self, _: str, **kwds) -> 'Theta': ... @overload - def stack(self, _: Type[None], **kwds) -> 'Theta': + def stack(self, _: None, **kwds) -> 'Theta': ... @overload @@ -11248,7 +11248,7 @@ def title(self, **kwds) -> 'Theta': ... @overload - def title(self, _: Type[None], **kwds) -> 'Theta': + def title(self, _: None, **kwds) -> 'Theta': ... def type(self, _: str, **kwds) -> 'Theta': @@ -11423,7 +11423,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: Type[None], **kwds) -> 'ThetaDatum': + def scale(self, _: None, **kwds) -> 'ThetaDatum': ... @overload @@ -11431,7 +11431,7 @@ def stack(self, _: str, **kwds) -> 'ThetaDatum': ... @overload - def stack(self, _: Type[None], **kwds) -> 'ThetaDatum': + def stack(self, _: None, **kwds) -> 'ThetaDatum': ... @overload @@ -11443,7 +11443,7 @@ def title(self, **kwds) -> 'ThetaDatum': ... @overload - def title(self, _: Type[None], **kwds) -> 'ThetaDatum': + def title(self, _: None, **kwds) -> 'ThetaDatum': ... def type(self, _: str, **kwds) -> 'ThetaDatum': @@ -11590,7 +11590,7 @@ def aggregate(self, argmin=Undefined, **kwds) -> 'Theta2': def bandPosition(self, _: float, **kwds) -> 'Theta2': ... - def bin(self, _: Type[None], **kwds) -> 'Theta2': + def bin(self, _: None, **kwds) -> 'Theta2': ... @overload @@ -11614,7 +11614,7 @@ def title(self, **kwds) -> 'Theta2': ... @overload - def title(self, _: Type[None], **kwds) -> 'Theta2': + def title(self, _: None, **kwds) -> 'Theta2': ... @@ -11742,7 +11742,7 @@ def title(self, **kwds) -> 'Theta2Datum': ... @overload - def title(self, _: Type[None], **kwds) -> 'Theta2Datum': + def title(self, _: None, **kwds) -> 'Theta2Datum': ... def type(self, _: str, **kwds) -> 'Theta2Datum': @@ -12012,7 +12012,7 @@ def bin(self, _: str, **kwds) -> 'Tooltip': ... @overload - def bin(self, _: Type[None], **kwds) -> 'Tooltip': + def bin(self, _: None, **kwds) -> 'Tooltip': ... @overload @@ -12055,7 +12055,7 @@ def title(self, **kwds) -> 'Tooltip': ... @overload - def title(self, _: Type[None], **kwds) -> 'Tooltip': + def title(self, _: None, **kwds) -> 'Tooltip': ... def type(self, _: str, **kwds) -> 'Tooltip': @@ -12342,7 +12342,7 @@ def bin(self, _: str, **kwds) -> 'Url': ... @overload - def bin(self, _: Type[None], **kwds) -> 'Url': + def bin(self, _: None, **kwds) -> 'Url': ... @overload @@ -12385,7 +12385,7 @@ def title(self, **kwds) -> 'Url': ... @overload - def title(self, _: Type[None], **kwds) -> 'Url': + def title(self, _: None, **kwds) -> 'Url': ... def type(self, _: str, **kwds) -> 'Url': @@ -12715,7 +12715,7 @@ def axis(self, aria=Undefined, bandPosition=Undefined, description=Undefined, do ... @overload - def axis(self, _: Type[None], **kwds) -> 'X': + def axis(self, _: None, **kwds) -> 'X': ... def bandPosition(self, _: float, **kwds) -> 'X': @@ -12734,7 +12734,7 @@ def bin(self, _: str, **kwds) -> 'X': ... @overload - def bin(self, _: Type[None], **kwds) -> 'X': + def bin(self, _: None, **kwds) -> 'X': ... @overload @@ -12750,7 +12750,7 @@ def impute(self, frame=Undefined, keyvals=Undefined, method=Undefined, value=Und ... @overload - def impute(self, _: Type[None], **kwds) -> 'X': + def impute(self, _: None, **kwds) -> 'X': ... @overload @@ -12758,7 +12758,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: Type[None], **kwds) -> 'X': + def scale(self, _: None, **kwds) -> 'X': ... @overload @@ -12778,7 +12778,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'X': ... @overload - def sort(self, _: Type[None], **kwds) -> 'X': + def sort(self, _: None, **kwds) -> 'X': ... @overload @@ -12786,7 +12786,7 @@ def stack(self, _: str, **kwds) -> 'X': ... @overload - def stack(self, _: Type[None], **kwds) -> 'X': + def stack(self, _: None, **kwds) -> 'X': ... @overload @@ -12806,7 +12806,7 @@ def title(self, **kwds) -> 'X': ... @overload - def title(self, _: Type[None], **kwds) -> 'X': + def title(self, _: None, **kwds) -> 'X': ... def type(self, _: str, **kwds) -> 'X': @@ -12996,7 +12996,7 @@ def axis(self, aria=Undefined, bandPosition=Undefined, description=Undefined, do ... @overload - def axis(self, _: Type[None], **kwds) -> 'XDatum': + def axis(self, _: None, **kwds) -> 'XDatum': ... def bandPosition(self, _: float, **kwds) -> 'XDatum': @@ -13007,7 +13007,7 @@ def impute(self, frame=Undefined, keyvals=Undefined, method=Undefined, value=Und ... @overload - def impute(self, _: Type[None], **kwds) -> 'XDatum': + def impute(self, _: None, **kwds) -> 'XDatum': ... @overload @@ -13015,7 +13015,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: Type[None], **kwds) -> 'XDatum': + def scale(self, _: None, **kwds) -> 'XDatum': ... @overload @@ -13023,7 +13023,7 @@ def stack(self, _: str, **kwds) -> 'XDatum': ... @overload - def stack(self, _: Type[None], **kwds) -> 'XDatum': + def stack(self, _: None, **kwds) -> 'XDatum': ... @overload @@ -13035,7 +13035,7 @@ def title(self, **kwds) -> 'XDatum': ... @overload - def title(self, _: Type[None], **kwds) -> 'XDatum': + def title(self, _: None, **kwds) -> 'XDatum': ... def type(self, _: str, **kwds) -> 'XDatum': @@ -13182,7 +13182,7 @@ def aggregate(self, argmin=Undefined, **kwds) -> 'X2': def bandPosition(self, _: float, **kwds) -> 'X2': ... - def bin(self, _: Type[None], **kwds) -> 'X2': + def bin(self, _: None, **kwds) -> 'X2': ... @overload @@ -13206,7 +13206,7 @@ def title(self, **kwds) -> 'X2': ... @overload - def title(self, _: Type[None], **kwds) -> 'X2': + def title(self, _: None, **kwds) -> 'X2': ... @@ -13333,7 +13333,7 @@ def title(self, **kwds) -> 'X2Datum': ... @overload - def title(self, _: Type[None], **kwds) -> 'X2Datum': + def title(self, _: None, **kwds) -> 'X2Datum': ... def type(self, _: str, **kwds) -> 'X2Datum': @@ -13479,7 +13479,7 @@ def aggregate(self, argmin=Undefined, **kwds) -> 'XError': def bandPosition(self, _: float, **kwds) -> 'XError': ... - def bin(self, _: Type[None], **kwds) -> 'XError': + def bin(self, _: None, **kwds) -> 'XError': ... @overload @@ -13503,7 +13503,7 @@ def title(self, **kwds) -> 'XError': ... @overload - def title(self, _: Type[None], **kwds) -> 'XError': + def title(self, _: None, **kwds) -> 'XError': ... @@ -13648,7 +13648,7 @@ def aggregate(self, argmin=Undefined, **kwds) -> 'XError2': def bandPosition(self, _: float, **kwds) -> 'XError2': ... - def bin(self, _: Type[None], **kwds) -> 'XError2': + def bin(self, _: None, **kwds) -> 'XError2': ... @overload @@ -13672,7 +13672,7 @@ def title(self, **kwds) -> 'XError2': ... @overload - def title(self, _: Type[None], **kwds) -> 'XError2': + def title(self, _: None, **kwds) -> 'XError2': ... @@ -13944,7 +13944,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: Type[None], **kwds) -> 'XOffset': + def bin(self, _: None, **kwds) -> 'XOffset': ... @overload @@ -13960,7 +13960,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: Type[None], **kwds) -> 'XOffset': + def scale(self, _: None, **kwds) -> 'XOffset': ... @overload @@ -13980,7 +13980,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'XOffset': ... @overload - def sort(self, _: Type[None], **kwds) -> 'XOffset': + def sort(self, _: None, **kwds) -> 'XOffset': ... @overload @@ -13996,7 +13996,7 @@ def title(self, **kwds) -> 'XOffset': ... @overload - def title(self, _: Type[None], **kwds) -> 'XOffset': + def title(self, _: None, **kwds) -> 'XOffset': ... def type(self, _: str, **kwds) -> 'XOffset': @@ -14141,7 +14141,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: Type[None], **kwds) -> 'XOffsetDatum': + def scale(self, _: None, **kwds) -> 'XOffsetDatum': ... @overload @@ -14149,7 +14149,7 @@ def title(self, **kwds) -> 'XOffsetDatum': ... @overload - def title(self, _: Type[None], **kwds) -> 'XOffsetDatum': + def title(self, _: None, **kwds) -> 'XOffsetDatum': ... def type(self, _: str, **kwds) -> 'XOffsetDatum': @@ -14463,7 +14463,7 @@ def axis(self, aria=Undefined, bandPosition=Undefined, description=Undefined, do ... @overload - def axis(self, _: Type[None], **kwds) -> 'Y': + def axis(self, _: None, **kwds) -> 'Y': ... def bandPosition(self, _: float, **kwds) -> 'Y': @@ -14482,7 +14482,7 @@ def bin(self, _: str, **kwds) -> 'Y': ... @overload - def bin(self, _: Type[None], **kwds) -> 'Y': + def bin(self, _: None, **kwds) -> 'Y': ... @overload @@ -14498,7 +14498,7 @@ def impute(self, frame=Undefined, keyvals=Undefined, method=Undefined, value=Und ... @overload - def impute(self, _: Type[None], **kwds) -> 'Y': + def impute(self, _: None, **kwds) -> 'Y': ... @overload @@ -14506,7 +14506,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: Type[None], **kwds) -> 'Y': + def scale(self, _: None, **kwds) -> 'Y': ... @overload @@ -14526,7 +14526,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Y': ... @overload - def sort(self, _: Type[None], **kwds) -> 'Y': + def sort(self, _: None, **kwds) -> 'Y': ... @overload @@ -14534,7 +14534,7 @@ def stack(self, _: str, **kwds) -> 'Y': ... @overload - def stack(self, _: Type[None], **kwds) -> 'Y': + def stack(self, _: None, **kwds) -> 'Y': ... @overload @@ -14554,7 +14554,7 @@ def title(self, **kwds) -> 'Y': ... @overload - def title(self, _: Type[None], **kwds) -> 'Y': + def title(self, _: None, **kwds) -> 'Y': ... def type(self, _: str, **kwds) -> 'Y': @@ -14744,7 +14744,7 @@ def axis(self, aria=Undefined, bandPosition=Undefined, description=Undefined, do ... @overload - def axis(self, _: Type[None], **kwds) -> 'YDatum': + def axis(self, _: None, **kwds) -> 'YDatum': ... def bandPosition(self, _: float, **kwds) -> 'YDatum': @@ -14755,7 +14755,7 @@ def impute(self, frame=Undefined, keyvals=Undefined, method=Undefined, value=Und ... @overload - def impute(self, _: Type[None], **kwds) -> 'YDatum': + def impute(self, _: None, **kwds) -> 'YDatum': ... @overload @@ -14763,7 +14763,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: Type[None], **kwds) -> 'YDatum': + def scale(self, _: None, **kwds) -> 'YDatum': ... @overload @@ -14771,7 +14771,7 @@ def stack(self, _: str, **kwds) -> 'YDatum': ... @overload - def stack(self, _: Type[None], **kwds) -> 'YDatum': + def stack(self, _: None, **kwds) -> 'YDatum': ... @overload @@ -14783,7 +14783,7 @@ def title(self, **kwds) -> 'YDatum': ... @overload - def title(self, _: Type[None], **kwds) -> 'YDatum': + def title(self, _: None, **kwds) -> 'YDatum': ... def type(self, _: str, **kwds) -> 'YDatum': @@ -14930,7 +14930,7 @@ def aggregate(self, argmin=Undefined, **kwds) -> 'Y2': def bandPosition(self, _: float, **kwds) -> 'Y2': ... - def bin(self, _: Type[None], **kwds) -> 'Y2': + def bin(self, _: None, **kwds) -> 'Y2': ... @overload @@ -14954,7 +14954,7 @@ def title(self, **kwds) -> 'Y2': ... @overload - def title(self, _: Type[None], **kwds) -> 'Y2': + def title(self, _: None, **kwds) -> 'Y2': ... @@ -15081,7 +15081,7 @@ def title(self, **kwds) -> 'Y2Datum': ... @overload - def title(self, _: Type[None], **kwds) -> 'Y2Datum': + def title(self, _: None, **kwds) -> 'Y2Datum': ... def type(self, _: str, **kwds) -> 'Y2Datum': @@ -15227,7 +15227,7 @@ def aggregate(self, argmin=Undefined, **kwds) -> 'YError': def bandPosition(self, _: float, **kwds) -> 'YError': ... - def bin(self, _: Type[None], **kwds) -> 'YError': + def bin(self, _: None, **kwds) -> 'YError': ... @overload @@ -15251,7 +15251,7 @@ def title(self, **kwds) -> 'YError': ... @overload - def title(self, _: Type[None], **kwds) -> 'YError': + def title(self, _: None, **kwds) -> 'YError': ... @@ -15396,7 +15396,7 @@ def aggregate(self, argmin=Undefined, **kwds) -> 'YError2': def bandPosition(self, _: float, **kwds) -> 'YError2': ... - def bin(self, _: Type[None], **kwds) -> 'YError2': + def bin(self, _: None, **kwds) -> 'YError2': ... @overload @@ -15420,7 +15420,7 @@ def title(self, **kwds) -> 'YError2': ... @overload - def title(self, _: Type[None], **kwds) -> 'YError2': + def title(self, _: None, **kwds) -> 'YError2': ... @@ -15692,7 +15692,7 @@ def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefin ... @overload - def bin(self, _: Type[None], **kwds) -> 'YOffset': + def bin(self, _: None, **kwds) -> 'YOffset': ... @overload @@ -15708,7 +15708,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: Type[None], **kwds) -> 'YOffset': + def scale(self, _: None, **kwds) -> 'YOffset': ... @overload @@ -15728,7 +15728,7 @@ def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'YOffset': ... @overload - def sort(self, _: Type[None], **kwds) -> 'YOffset': + def sort(self, _: None, **kwds) -> 'YOffset': ... @overload @@ -15744,7 +15744,7 @@ def title(self, **kwds) -> 'YOffset': ... @overload - def title(self, _: Type[None], **kwds) -> 'YOffset': + def title(self, _: None, **kwds) -> 'YOffset': ... def type(self, _: str, **kwds) -> 'YOffset': @@ -15889,7 +15889,7 @@ def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined ... @overload - def scale(self, _: Type[None], **kwds) -> 'YOffsetDatum': + def scale(self, _: None, **kwds) -> 'YOffsetDatum': ... @overload @@ -15897,7 +15897,7 @@ def title(self, **kwds) -> 'YOffsetDatum': ... @overload - def title(self, _: Type[None], **kwds) -> 'YOffsetDatum': + def title(self, _: None, **kwds) -> 'YOffsetDatum': ... def type(self, _: str, **kwds) -> 'YOffsetDatum': diff --git a/tools/schemapi/codegen.py b/tools/schemapi/codegen.py index 0984be6c8..b33c20c8f 100644 --- a/tools/schemapi/codegen.py +++ b/tools/schemapi/codegen.py @@ -230,7 +230,7 @@ def init_code(self, indent=0): "object": "dict", "boolean": "bool", "array": "list", - "null": "Type[None]", + "null": "None", } def get_args(self, si): From 890637bf41209d4b298875dc7f8e9250f0d7a664 Mon Sep 17 00:00:00 2001 From: Christopher Davis Date: Fri, 30 Dec 2022 08:10:24 -0600 Subject: [PATCH 21/26] Move examples with the new attribute syntax I've put all of the examples by @joelostblom using the new attribute syntax into a folder `attribute_syntax` and replaced them in the main `examples` folder with the current versions in the master branch. --- altair/examples/airport_connections.py | 22 +- altair/examples/annual_weather_heatmap.py | 13 +- altair/examples/anscombe_plot.py | 4 +- .../attribute_syntax/airport_connections.py | 70 ++++ .../annual_weather_heatmap.py | 24 ++ .../attribute_syntax/anscombe_plot.py | 20 + .../bar_chart_trellis_compact.py | 48 +++ .../beckers_barley_trellis_plot.py | 28 ++ .../beckers_barley_wrapped_facet.py | 22 ++ .../examples/attribute_syntax/bump_chart.py | 29 ++ .../attribute_syntax/candlestick_chart.py | 40 ++ .../attribute_syntax/co2_concentration.py | 64 +++ .../examples/attribute_syntax/comet_chart.py | 44 +++ .../attribute_syntax/connected_scatterplot.py | 18 + .../attribute_syntax/density_stack.py | 35 ++ .../diverging_stacked_bar_chart.py | 363 ++++++++++++++++++ .../examples/attribute_syntax/donut_chart.py | 21 + .../attribute_syntax/errorbars_with_ci.py | 24 ++ .../attribute_syntax/errorbars_with_std.py | 23 ++ altair/examples/attribute_syntax/falkensee.py | 77 ++++ .../attribute_syntax/gapminder_bubble_plot.py | 18 + .../examples/attribute_syntax/groupby-map.py | 36 ++ .../attribute_syntax/grouped_bar_chart2.py | 22 ++ .../grouped_bar_chart_with_error_bars.py | 25 ++ altair/examples/attribute_syntax/hexbins.py | 46 +++ .../attribute_syntax/histogram_heatmap.py | 16 + .../attribute_syntax/histogram_responsive.py | 34 ++ .../attribute_syntax/histogram_scatterplot.py | 16 + .../histogram_with_a_global_mean_overlay.py | 24 ++ .../attribute_syntax/horizon_graph.py | 41 ++ .../interactive_cross_highlight.py | 41 ++ .../interactive_layered_crossfilter.py | 42 ++ .../attribute_syntax/interactive_legend.py | 23 ++ .../attribute_syntax/interval_selection.py | 29 ++ .../attribute_syntax/iowa_electricity.py | 19 + altair/examples/attribute_syntax/isotype.py | 81 ++++ .../attribute_syntax/isotype_emoji.py | 66 ++++ .../examples/attribute_syntax/isotype_grid.py | 38 ++ .../examples/attribute_syntax/lasagna_plot.py | 31 ++ .../attribute_syntax/layered_area_chart.py | 16 + .../attribute_syntax/layered_bar_chart.py | 16 + .../layered_chart_with_dual_axis.py | 28 ++ .../attribute_syntax/layered_heatmap_text.py | 41 ++ .../attribute_syntax/layered_histogram.py | 29 ++ .../line_chart_with_color_datum.py | 23 ++ .../line_chart_with_cumsum.py | 24 ++ .../line_chart_with_custom_legend.py | 40 ++ .../examples/attribute_syntax/line_percent.py | 18 + .../examples/attribute_syntax/line_with_ci.py | 22 ++ .../line_with_last_value_labeled.py | 0 .../attribute_syntax/line_with_log_scale.py | 15 + .../examples/attribute_syntax/london_tube.py | 51 +++ .../attribute_syntax/mosaic_with_labels.py | 85 ++++ .../multifeature_scatter_plot.py | 17 + .../attribute_syntax/multiline_highlight.py | 38 ++ .../attribute_syntax/multiline_tooltip.py | 69 ++++ .../attribute_syntax/multiple_interactions.py | 98 +++++ .../attribute_syntax/natural_disasters.py | 52 +++ .../normalized_stacked_area_chart.py | 16 + .../normalized_stacked_bar_chart.py | 16 + .../attribute_syntax/parallel_coordinates.py | 28 ++ .../attribute_syntax/percentage_of_total.py | 23 ++ altair/examples/attribute_syntax/pie_chart.py | 18 + .../attribute_syntax/pie_chart_with_labels.py | 25 ++ .../attribute_syntax/poly_fit_regression.py | 37 ++ altair/examples/attribute_syntax/pyramid.py | 23 ++ .../examples/attribute_syntax/radial_chart.py | 25 ++ .../attribute_syntax/ranged_dot_plot.py | 38 ++ .../attribute_syntax/ridgeline_plot.py | 59 +++ .../attribute_syntax/scatter_linked_table.py | 55 +++ .../attribute_syntax/scatter_marginal_hist.py | 48 +++ .../scatter_with_layered_histogram.py | 61 +++ .../attribute_syntax/scatter_with_minimap.py | 44 +++ .../scatter_with_rolling_mean.py | 30 ++ .../seattle_weather_interactive.py | 61 +++ .../attribute_syntax/select_detail.py | 65 ++++ .../simple_scatter_with_errorbars.py | 43 +++ .../sorted_error_bars_with_ci.py | 33 ++ .../stacked_bar_chart_sorted_segments.py | 21 + .../stacked_bar_chart_with_text.py | 27 ++ .../attribute_syntax/stem_and_leaf.py | 41 ++ .../examples/attribute_syntax/streamgraph.py | 16 + .../attribute_syntax/strip_plot_jitter.py | 37 ++ .../examples/attribute_syntax/top_k_items.py | 27 ++ .../attribute_syntax/top_k_letters.py | 40 ++ .../attribute_syntax/top_k_with_others.py | 29 ++ .../trellis_area_sort_array.py | 21 + .../attribute_syntax/trellis_histogram.py | 17 + .../attribute_syntax/us_employment.py | 58 +++ .../us_population_over_time.py | 39 ++ .../us_population_over_time_facet.py | 21 + .../us_population_pyramid_over_time.py | 57 +++ .../attribute_syntax/us_state_capitals.py | 43 +++ .../examples/attribute_syntax/violin_plot.py | 28 ++ .../examples/attribute_syntax/wheat_wages.py | 58 +++ .../attribute_syntax/wilkinson-dot-plot.py | 25 ++ .../attribute_syntax/wind_vector_map.py | 57 +++ .../examples/attribute_syntax/window_rank.py | 42 ++ altair/examples/bar_chart_trellis_compact.py | 12 +- .../examples/beckers_barley_trellis_plot.py | 31 +- .../examples/beckers_barley_wrapped_facet.py | 2 +- altair/examples/bump_chart.py | 6 +- altair/examples/candlestick_chart.py | 28 +- altair/examples/co2_concentration.py | 29 +- altair/examples/comet_chart.py | 48 +-- altair/examples/connected_scatterplot.py | 4 +- altair/examples/dendrogram.py | 143 +++++++ altair/examples/density_stack.py | 2 +- .../examples/diverging_stacked_bar_chart.py | 8 +- altair/examples/donut_chart.py | 9 +- altair/examples/dot_dash_plot.py | 12 +- altair/examples/errorbars_with_ci.py | 8 +- altair/examples/errorbars_with_std.py | 8 +- altair/examples/falkensee.py | 6 +- altair/examples/gapminder_bubble_plot.py | 4 +- altair/examples/groupby-map.py | 6 +- altair/examples/grouped_bar_chart2.py | 8 +- .../grouped_bar_chart_with_error_bars.py | 2 +- altair/examples/hexbins.py | 12 +- altair/examples/histogram_heatmap.py | 6 +- altair/examples/histogram_responsive.py | 9 +- altair/examples/histogram_scatterplot.py | 4 +- .../histogram_with_a_global_mean_overlay.py | 2 +- altair/examples/horizon_graph.py | 10 +- .../examples/interactive_cross_highlight.py | 18 +- .../interactive_layered_crossfilter.py | 7 +- altair/examples/interactive_legend.py | 6 +- altair/examples/interval_selection.py | 7 +- altair/examples/iowa_electricity.py | 20 +- altair/examples/isotype.py | 15 +- altair/examples/isotype_emoji.py | 11 +- altair/examples/isotype_grid.py | 6 +- altair/examples/lasagna_plot.py | 12 +- altair/examples/layered_area_chart.py | 2 +- altair/examples/layered_bar_chart.py | 2 +- .../examples/layered_chart_with_dual_axis.py | 10 +- altair/examples/layered_heatmap_text.py | 9 +- altair/examples/layered_histogram.py | 4 +- .../examples/line_chart_with_color_datum.py | 14 +- altair/examples/line_chart_with_cumsum.py | 4 +- .../examples/line_chart_with_custom_legend.py | 10 +- altair/examples/line_percent.py | 4 +- altair/examples/line_with_ci.py | 2 +- altair/examples/line_with_last_value_labeled | 40 ++ altair/examples/line_with_log_scale.py | 7 +- altair/examples/london_tube.py | 18 +- altair/examples/mosaic_with_labels.py | 18 +- altair/examples/multifeature_scatter_plot.py | 4 +- altair/examples/multiline_highlight.py | 6 +- altair/examples/multiline_tooltip.py | 6 +- altair/examples/multiple_interactions.py | 24 +- altair/examples/natural_disasters.py | 26 +- .../examples/normalized_stacked_area_chart.py | 2 +- .../examples/normalized_stacked_bar_chart.py | 2 +- altair/examples/parallel_coordinates.py | 6 +- altair/examples/percentage_of_total.py | 8 +- altair/examples/pie_chart.py | 4 +- altair/examples/pie_chart_with_labels.py | 3 +- altair/examples/poly_fit_regression.py | 3 +- altair/examples/pyramid.py | 15 +- altair/examples/radial_chart.py | 4 +- altair/examples/ranged_dot_plot.py | 7 +- altair/examples/ridgeline_plot.py | 28 +- altair/examples/scatter_linked_table.py | 30 +- altair/examples/scatter_marginal_hist.py | 26 +- .../scatter_with_layered_histogram.py | 20 +- altair/examples/scatter_with_minimap.py | 9 +- altair/examples/scatter_with_rolling_mean.py | 5 +- .../examples/seattle_weather_interactive.py | 17 +- altair/examples/select_detail.py | 4 +- .../examples/simple_scatter_with_errorbars.py | 4 +- altair/examples/sorted_error_bars_with_ci.py | 13 +- .../examples/stacked_bar_chart_with_text.py | 4 +- altair/examples/stem_and_leaf.py | 10 +- altair/examples/streamgraph.py | 10 +- altair/examples/strip_plot_jitter.py | 4 +- altair/examples/top_k_items.py | 6 +- altair/examples/top_k_letters.py | 2 +- altair/examples/top_k_with_others.py | 10 +- altair/examples/trellis_area_sort_array.py | 2 +- altair/examples/trellis_histogram.py | 2 +- altair/examples/us_employment.py | 4 +- altair/examples/us_population_over_time.py | 14 +- .../examples/us_population_over_time_facet.py | 10 +- .../us_population_pyramid_over_time.py | 22 +- altair/examples/us_state_capitals.py | 2 +- altair/examples/violin_plot.py | 33 +- altair/examples/waterfall_chart.py | 106 +++++ altair/examples/wheat_wages.py | 28 +- altair/examples/wilkinson-dot-plot.py | 12 +- altair/examples/wind_vector_map.py | 25 +- altair/examples/window_rank.py | 2 +- 192 files changed, 4545 insertions(+), 475 deletions(-) create mode 100644 altair/examples/attribute_syntax/airport_connections.py create mode 100644 altair/examples/attribute_syntax/annual_weather_heatmap.py create mode 100644 altair/examples/attribute_syntax/anscombe_plot.py create mode 100644 altair/examples/attribute_syntax/bar_chart_trellis_compact.py create mode 100644 altair/examples/attribute_syntax/beckers_barley_trellis_plot.py create mode 100644 altair/examples/attribute_syntax/beckers_barley_wrapped_facet.py create mode 100644 altair/examples/attribute_syntax/bump_chart.py create mode 100644 altair/examples/attribute_syntax/candlestick_chart.py create mode 100644 altair/examples/attribute_syntax/co2_concentration.py create mode 100644 altair/examples/attribute_syntax/comet_chart.py create mode 100644 altair/examples/attribute_syntax/connected_scatterplot.py create mode 100644 altair/examples/attribute_syntax/density_stack.py create mode 100644 altair/examples/attribute_syntax/diverging_stacked_bar_chart.py create mode 100644 altair/examples/attribute_syntax/donut_chart.py create mode 100644 altair/examples/attribute_syntax/errorbars_with_ci.py create mode 100644 altair/examples/attribute_syntax/errorbars_with_std.py create mode 100644 altair/examples/attribute_syntax/falkensee.py create mode 100644 altair/examples/attribute_syntax/gapminder_bubble_plot.py create mode 100644 altair/examples/attribute_syntax/groupby-map.py create mode 100644 altair/examples/attribute_syntax/grouped_bar_chart2.py create mode 100644 altair/examples/attribute_syntax/grouped_bar_chart_with_error_bars.py create mode 100644 altair/examples/attribute_syntax/hexbins.py create mode 100644 altair/examples/attribute_syntax/histogram_heatmap.py create mode 100644 altair/examples/attribute_syntax/histogram_responsive.py create mode 100644 altair/examples/attribute_syntax/histogram_scatterplot.py create mode 100644 altair/examples/attribute_syntax/histogram_with_a_global_mean_overlay.py create mode 100644 altair/examples/attribute_syntax/horizon_graph.py create mode 100644 altair/examples/attribute_syntax/interactive_cross_highlight.py create mode 100644 altair/examples/attribute_syntax/interactive_layered_crossfilter.py create mode 100644 altair/examples/attribute_syntax/interactive_legend.py create mode 100644 altair/examples/attribute_syntax/interval_selection.py create mode 100644 altair/examples/attribute_syntax/iowa_electricity.py create mode 100644 altair/examples/attribute_syntax/isotype.py create mode 100644 altair/examples/attribute_syntax/isotype_emoji.py create mode 100644 altair/examples/attribute_syntax/isotype_grid.py create mode 100644 altair/examples/attribute_syntax/lasagna_plot.py create mode 100644 altair/examples/attribute_syntax/layered_area_chart.py create mode 100644 altair/examples/attribute_syntax/layered_bar_chart.py create mode 100644 altair/examples/attribute_syntax/layered_chart_with_dual_axis.py create mode 100644 altair/examples/attribute_syntax/layered_heatmap_text.py create mode 100644 altair/examples/attribute_syntax/layered_histogram.py create mode 100644 altair/examples/attribute_syntax/line_chart_with_color_datum.py create mode 100644 altair/examples/attribute_syntax/line_chart_with_cumsum.py create mode 100644 altair/examples/attribute_syntax/line_chart_with_custom_legend.py create mode 100644 altair/examples/attribute_syntax/line_percent.py create mode 100644 altair/examples/attribute_syntax/line_with_ci.py rename altair/examples/{ => attribute_syntax}/line_with_last_value_labeled.py (100%) create mode 100644 altair/examples/attribute_syntax/line_with_log_scale.py create mode 100644 altair/examples/attribute_syntax/london_tube.py create mode 100644 altair/examples/attribute_syntax/mosaic_with_labels.py create mode 100644 altair/examples/attribute_syntax/multifeature_scatter_plot.py create mode 100644 altair/examples/attribute_syntax/multiline_highlight.py create mode 100644 altair/examples/attribute_syntax/multiline_tooltip.py create mode 100644 altair/examples/attribute_syntax/multiple_interactions.py create mode 100644 altair/examples/attribute_syntax/natural_disasters.py create mode 100644 altair/examples/attribute_syntax/normalized_stacked_area_chart.py create mode 100644 altair/examples/attribute_syntax/normalized_stacked_bar_chart.py create mode 100644 altair/examples/attribute_syntax/parallel_coordinates.py create mode 100644 altair/examples/attribute_syntax/percentage_of_total.py create mode 100644 altair/examples/attribute_syntax/pie_chart.py create mode 100644 altair/examples/attribute_syntax/pie_chart_with_labels.py create mode 100644 altair/examples/attribute_syntax/poly_fit_regression.py create mode 100644 altair/examples/attribute_syntax/pyramid.py create mode 100644 altair/examples/attribute_syntax/radial_chart.py create mode 100644 altair/examples/attribute_syntax/ranged_dot_plot.py create mode 100644 altair/examples/attribute_syntax/ridgeline_plot.py create mode 100644 altair/examples/attribute_syntax/scatter_linked_table.py create mode 100644 altair/examples/attribute_syntax/scatter_marginal_hist.py create mode 100644 altair/examples/attribute_syntax/scatter_with_layered_histogram.py create mode 100644 altair/examples/attribute_syntax/scatter_with_minimap.py create mode 100644 altair/examples/attribute_syntax/scatter_with_rolling_mean.py create mode 100644 altair/examples/attribute_syntax/seattle_weather_interactive.py create mode 100644 altair/examples/attribute_syntax/select_detail.py create mode 100644 altair/examples/attribute_syntax/simple_scatter_with_errorbars.py create mode 100644 altair/examples/attribute_syntax/sorted_error_bars_with_ci.py create mode 100644 altair/examples/attribute_syntax/stacked_bar_chart_sorted_segments.py create mode 100644 altair/examples/attribute_syntax/stacked_bar_chart_with_text.py create mode 100644 altair/examples/attribute_syntax/stem_and_leaf.py create mode 100644 altair/examples/attribute_syntax/streamgraph.py create mode 100644 altair/examples/attribute_syntax/strip_plot_jitter.py create mode 100644 altair/examples/attribute_syntax/top_k_items.py create mode 100644 altair/examples/attribute_syntax/top_k_letters.py create mode 100644 altair/examples/attribute_syntax/top_k_with_others.py create mode 100644 altair/examples/attribute_syntax/trellis_area_sort_array.py create mode 100644 altair/examples/attribute_syntax/trellis_histogram.py create mode 100644 altair/examples/attribute_syntax/us_employment.py create mode 100644 altair/examples/attribute_syntax/us_population_over_time.py create mode 100644 altair/examples/attribute_syntax/us_population_over_time_facet.py create mode 100644 altair/examples/attribute_syntax/us_population_pyramid_over_time.py create mode 100644 altair/examples/attribute_syntax/us_state_capitals.py create mode 100644 altair/examples/attribute_syntax/violin_plot.py create mode 100644 altair/examples/attribute_syntax/wheat_wages.py create mode 100644 altair/examples/attribute_syntax/wilkinson-dot-plot.py create mode 100644 altair/examples/attribute_syntax/wind_vector_map.py create mode 100644 altair/examples/attribute_syntax/window_rank.py create mode 100644 altair/examples/dendrogram.py create mode 100644 altair/examples/line_with_last_value_labeled create mode 100644 altair/examples/waterfall_chart.py diff --git a/altair/examples/airport_connections.py b/altair/examples/airport_connections.py index 0b54db495..ef1363abc 100644 --- a/altair/examples/airport_connections.py +++ b/altair/examples/airport_connections.py @@ -1,8 +1,8 @@ """ Connections Among U.S. Airports Interactive ------------------------------------------- -This example shows all the connections between major U.S. airports. Lookup transformations -are used to find the coordinates of each airport and connecting airports. Connections +This example shows all the connections between major U.S. airports. Lookup transformations +are used to find the coordinates of each airport and connecting airports. Connections are displayed on mouseover via a single selection. """ # category: case studies @@ -26,10 +26,10 @@ ) background = alt.Chart(states).mark_geoshape( - fill="lightgray", + fill="lightgray", stroke="white" ).properties( - width=750, + width=750, height=500 ).project("albersUsa") @@ -39,11 +39,11 @@ latitude2="lat2:Q", longitude2="lon2:Q" ).transform_lookup( - lookup="origin", + lookup="origin", from_=lookup_data ).transform_lookup( - lookup="destination", - from_=lookup_data, + lookup="destination", + from_=lookup_data, as_=["state", "lat2", "lon2"] ).transform_filter( select_city @@ -52,14 +52,14 @@ points = alt.Chart(flights_airport).mark_circle().encode( latitude="latitude:Q", longitude="longitude:Q", - size=alt.Size("routes:Q").legend(None).scale(range=[0, 1000]), - order=alt.Order("routes:Q").sort("descending"), + size=alt.Size("routes:Q", scale=alt.Scale(range=[0, 1000]), legend=None), + order=alt.Order("routes:Q", sort="descending"), tooltip=["origin:N", "routes:Q"] ).transform_aggregate( - routes="count()", + routes="count()", groupby=["origin"] ).transform_lookup( - lookup="origin", + lookup="origin", from_=lookup_data ).transform_filter( (alt.datum.state != "PR") & (alt.datum.state != "VI") diff --git a/altair/examples/annual_weather_heatmap.py b/altair/examples/annual_weather_heatmap.py index d96b1e06c..972c42404 100644 --- a/altair/examples/annual_weather_heatmap.py +++ b/altair/examples/annual_weather_heatmap.py @@ -9,16 +9,11 @@ source = data.seattle_weather() alt.Chart(source, title="Daily Max Temperatures (C) in Seattle, WA").mark_rect().encode( - alt.X("date(date):O").title("Day").axis(format="%e", labelAngle=0), - alt.Y("month(date):O").title("Month"), - alt.Color("max(temp_max)").title(None), + x=alt.X("date(date):O", title="Day", axis=alt.Axis(format="%e", labelAngle=0)), + y=alt.Y("month(date):O", title="Month"), + color=alt.Color("max(temp_max)", legend=alt.Legend(title=None)), tooltip=[ alt.Tooltip("monthdate(date)", title="Date"), alt.Tooltip("max(temp_max)", title="Max Temp"), ], -).configure_view( - step=13, - strokeWidth=0 -).configure_axis( - domain=False -) +).configure_view(step=13, strokeWidth=0).configure_axis(domain=False) diff --git a/altair/examples/anscombe_plot.py b/altair/examples/anscombe_plot.py index 906f15ee7..9e2007485 100644 --- a/altair/examples/anscombe_plot.py +++ b/altair/examples/anscombe_plot.py @@ -11,8 +11,8 @@ source = data.anscombe() alt.Chart(source).mark_circle().encode( - alt.X('X').scale(zero=False), - alt.Y('Y').scale(zero=False), + alt.X('X', scale=alt.Scale(zero=False)), + alt.Y('Y', scale=alt.Scale(zero=False)), alt.Facet('Series', columns=2), ).properties( width=180, diff --git a/altair/examples/attribute_syntax/airport_connections.py b/altair/examples/attribute_syntax/airport_connections.py new file mode 100644 index 000000000..0b54db495 --- /dev/null +++ b/altair/examples/attribute_syntax/airport_connections.py @@ -0,0 +1,70 @@ +""" +Connections Among U.S. Airports Interactive +------------------------------------------- +This example shows all the connections between major U.S. airports. Lookup transformations +are used to find the coordinates of each airport and connecting airports. Connections +are displayed on mouseover via a single selection. +""" +# category: case studies +import altair as alt +from vega_datasets import data + +# Since these data are each more than 5,000 rows we'll import from the URLs +airports = data.airports.url +flights_airport = data.flights_airport.url + +states = alt.topo_feature(data.us_10m.url, feature="states") + +# Create mouseover selection +select_city = alt.selection_point( + on="mouseover", nearest=True, fields=["origin"], empty=False +) + +# Define which attributes to lookup from airports.csv +lookup_data = alt.LookupData( + airports, key="iata", fields=["state", "latitude", "longitude"] +) + +background = alt.Chart(states).mark_geoshape( + fill="lightgray", + stroke="white" +).properties( + width=750, + height=500 +).project("albersUsa") + +connections = alt.Chart(flights_airport).mark_rule(opacity=0.35).encode( + latitude="latitude:Q", + longitude="longitude:Q", + latitude2="lat2:Q", + longitude2="lon2:Q" +).transform_lookup( + lookup="origin", + from_=lookup_data +).transform_lookup( + lookup="destination", + from_=lookup_data, + as_=["state", "lat2", "lon2"] +).transform_filter( + select_city +) + +points = alt.Chart(flights_airport).mark_circle().encode( + latitude="latitude:Q", + longitude="longitude:Q", + size=alt.Size("routes:Q").legend(None).scale(range=[0, 1000]), + order=alt.Order("routes:Q").sort("descending"), + tooltip=["origin:N", "routes:Q"] +).transform_aggregate( + routes="count()", + groupby=["origin"] +).transform_lookup( + lookup="origin", + from_=lookup_data +).transform_filter( + (alt.datum.state != "PR") & (alt.datum.state != "VI") +).add_params( + select_city +) + +(background + connections + points).configure_view(stroke=None) diff --git a/altair/examples/attribute_syntax/annual_weather_heatmap.py b/altair/examples/attribute_syntax/annual_weather_heatmap.py new file mode 100644 index 000000000..d96b1e06c --- /dev/null +++ b/altair/examples/attribute_syntax/annual_weather_heatmap.py @@ -0,0 +1,24 @@ +""" +Annual Weather Heatmap +---------------------- +""" +# category: tables +import altair as alt +from vega_datasets import data + +source = data.seattle_weather() + +alt.Chart(source, title="Daily Max Temperatures (C) in Seattle, WA").mark_rect().encode( + alt.X("date(date):O").title("Day").axis(format="%e", labelAngle=0), + alt.Y("month(date):O").title("Month"), + alt.Color("max(temp_max)").title(None), + tooltip=[ + alt.Tooltip("monthdate(date)", title="Date"), + alt.Tooltip("max(temp_max)", title="Max Temp"), + ], +).configure_view( + step=13, + strokeWidth=0 +).configure_axis( + domain=False +) diff --git a/altair/examples/attribute_syntax/anscombe_plot.py b/altair/examples/attribute_syntax/anscombe_plot.py new file mode 100644 index 000000000..906f15ee7 --- /dev/null +++ b/altair/examples/attribute_syntax/anscombe_plot.py @@ -0,0 +1,20 @@ +""" +Anscombe's Quartet +------------------ + +This example shows how to use the column channel to make a trellis plot. Anscombe's Quartet is a famous dataset constructed by Francis Anscombe. Common summary statistics are identical for each subset of the data, despite the subsets having vastly different characteristics. +""" +# category: case studies +import altair as alt +from vega_datasets import data + +source = data.anscombe() + +alt.Chart(source).mark_circle().encode( + alt.X('X').scale(zero=False), + alt.Y('Y').scale(zero=False), + alt.Facet('Series', columns=2), +).properties( + width=180, + height=180, +) diff --git a/altair/examples/attribute_syntax/bar_chart_trellis_compact.py b/altair/examples/attribute_syntax/bar_chart_trellis_compact.py new file mode 100644 index 000000000..2cb0e4b7d --- /dev/null +++ b/altair/examples/attribute_syntax/bar_chart_trellis_compact.py @@ -0,0 +1,48 @@ +""" +Compact Trellis Grid of Bar Charts +================================== +This example shows a simple grid of bar charts to compare performance data.. +""" +# category: bar charts +import altair as alt +import pandas as pd + +source = pd.DataFrame( + [ + {"a": "a1", "b": "b1", "c": "x", "p": "0.14"}, + {"a": "a1", "b": "b1", "c": "y", "p": "0.60"}, + {"a": "a1", "b": "b1", "c": "z", "p": "0.03"}, + {"a": "a1", "b": "b2", "c": "x", "p": "0.80"}, + {"a": "a1", "b": "b2", "c": "y", "p": "0.38"}, + {"a": "a1", "b": "b2", "c": "z", "p": "0.55"}, + {"a": "a1", "b": "b3", "c": "x", "p": "0.11"}, + {"a": "a1", "b": "b3", "c": "y", "p": "0.58"}, + {"a": "a1", "b": "b3", "c": "z", "p": "0.79"}, + {"a": "a2", "b": "b1", "c": "x", "p": "0.83"}, + {"a": "a2", "b": "b1", "c": "y", "p": "0.87"}, + {"a": "a2", "b": "b1", "c": "z", "p": "0.67"}, + {"a": "a2", "b": "b2", "c": "x", "p": "0.97"}, + {"a": "a2", "b": "b2", "c": "y", "p": "0.84"}, + {"a": "a2", "b": "b2", "c": "z", "p": "0.90"}, + {"a": "a2", "b": "b3", "c": "x", "p": "0.74"}, + {"a": "a2", "b": "b3", "c": "y", "p": "0.64"}, + {"a": "a2", "b": "b3", "c": "z", "p": "0.19"}, + {"a": "a3", "b": "b1", "c": "x", "p": "0.57"}, + {"a": "a3", "b": "b1", "c": "y", "p": "0.35"}, + {"a": "a3", "b": "b1", "c": "z", "p": "0.49"}, + {"a": "a3", "b": "b2", "c": "x", "p": "0.91"}, + {"a": "a3", "b": "b2", "c": "y", "p": "0.38"}, + {"a": "a3", "b": "b2", "c": "z", "p": "0.91"}, + {"a": "a3", "b": "b3", "c": "x", "p": "0.99"}, + {"a": "a3", "b": "b3", "c": "y", "p": "0.80"}, + {"a": "a3", "b": "b3", "c": "z", "p": "0.37"}, + ] +) + +alt.Chart(source, width=60, height=alt.Step(8)).mark_bar().encode( + alt.Y("c:N").axis(None), + alt.X("p:Q").title(None).axis(format="%"), + alt.Color("c:N").title("settings").legend(orient="bottom", titleOrient="left"), + alt.Row("a:N").title("Factor A").header(labelAngle=0), + alt.Column("b:N").title("Factor B"), +) diff --git a/altair/examples/attribute_syntax/beckers_barley_trellis_plot.py b/altair/examples/attribute_syntax/beckers_barley_trellis_plot.py new file mode 100644 index 000000000..9f7c68867 --- /dev/null +++ b/altair/examples/attribute_syntax/beckers_barley_trellis_plot.py @@ -0,0 +1,28 @@ +""" +Becker's Barley Trellis Plot +---------------------------- +The example demonstrates the trellis charts created by Richard Becker, William Cleveland and others in the 1990s. Using the visualization technique below they identified an anomoly in a widely used agriculatural dataset, which they termed `"The Morris Mistake." `_. It became their favored way of showcasing the power of this pioneering plot. +""" +# category: case studies +import altair as alt +from vega_datasets import data + +source = data.barley() + +alt.Chart(source, title="The Morris Mistake").mark_point().encode( + alt.X('yield:Q') + .title("Barley Yield (bushels/acre)") + .scale(zero=False) + .axis(grid=False), + alt.Y('variety:N') + .title("") + .sort('-x') + .axis(grid=True), + alt.Color('year:N') + .legend(title="Year"), + alt.Row('site:N') + .title("") + .sort(alt.EncodingSortField(field='yield', op='sum', order='descending')) +).properties( + height=alt.Step(20) +).configure_view(stroke="transparent") diff --git a/altair/examples/attribute_syntax/beckers_barley_wrapped_facet.py b/altair/examples/attribute_syntax/beckers_barley_wrapped_facet.py new file mode 100644 index 000000000..1b36dfbc0 --- /dev/null +++ b/altair/examples/attribute_syntax/beckers_barley_wrapped_facet.py @@ -0,0 +1,22 @@ +""" +Becker's Barley Trellis Plot (Wrapped Facet) +-------------------------------------------- +The example demonstrates the trellis charts created by Richard Becker, William Cleveland and others in the 1990s. +This is the Altair replicate of `the VegaLite version `_ +demonstrating the usage of `columns` argument to create wrapped facet. +""" +# category: advanced calculations +import altair as alt +from vega_datasets import data + +source = data.barley.url + +alt.Chart(source).mark_point().encode( + alt.X('median(yield):Q').scale(zero=False), + y='variety:O', + color='year:N', + facet=alt.Facet('site:O', columns=2), +).properties( + width=200, + height=100, +) diff --git a/altair/examples/attribute_syntax/bump_chart.py b/altair/examples/attribute_syntax/bump_chart.py new file mode 100644 index 000000000..03f88c8ac --- /dev/null +++ b/altair/examples/attribute_syntax/bump_chart.py @@ -0,0 +1,29 @@ +""" +Bump Chart +---------- +This example shows a bump chart. The data is first grouped into six-month +intervals using pandas. The ranks are computed by Altair using a +window transform. +""" +# category: line charts + +import altair as alt +from vega_datasets import data +import pandas as pd + +stocks = data.stocks() +source = stocks.groupby([pd.Grouper(key="date", freq="6M"),"symbol"]).mean().reset_index() + +alt.Chart(source).mark_line(point=True).encode( + x=alt.X("date:O").timeUnit("yearmonth").title("date"), + y="rank:O", + color=alt.Color("symbol:N") +).transform_window( + rank="rank()", + sort=[alt.SortField("price", order="descending")], + groupby=["date"] +).properties( + title="Bump Chart for Stock Prices", + width=600, + height=150, +) diff --git a/altair/examples/attribute_syntax/candlestick_chart.py b/altair/examples/attribute_syntax/candlestick_chart.py new file mode 100644 index 000000000..47e713abb --- /dev/null +++ b/altair/examples/attribute_syntax/candlestick_chart.py @@ -0,0 +1,40 @@ +""" +Candlestick Chart +================= +A candlestick chart inspired from `Protovis `_. +This example shows the performance of the Chicago Board Options Exchange `Volatility Index `_ (VIX) +in the summer of 2009. The thick bar represents the opening and closing prices, +while the thin bar shows intraday high and low prices; if the index closed higher on a given day, the bars are colored green rather than red. +""" +# category: advanced calculations +import altair as alt +from vega_datasets import data + +source = data.ohlc() + +open_close_color = alt.condition( + "datum.open <= datum.close", + alt.value("#06982d"), + alt.value("#ae1325") +) + +base = alt.Chart(source).encode( + alt.X('date:T') + .axis(format='%m/%d', labelAngle=-45) + .title('Date in 2009'), + color=open_close_color +) + +rule = base.mark_rule().encode( + alt.Y('low:Q') + .title('Price') + .scale(zero=False), + alt.Y2('high:Q') +) + +bar = base.mark_bar().encode( + alt.Y('open:Q'), + alt.Y2('close:Q') +) + +rule + bar diff --git a/altair/examples/attribute_syntax/co2_concentration.py b/altair/examples/attribute_syntax/co2_concentration.py new file mode 100644 index 000000000..e82f830d6 --- /dev/null +++ b/altair/examples/attribute_syntax/co2_concentration.py @@ -0,0 +1,64 @@ +""" +Atmospheric CO2 Concentration +----------------------------- +This example is a fully developed line chart that uses a window transformation. +It was inspired by `Gregor Aisch's work at datawrapper +`_. +""" +# category: case studies +import altair as alt +from vega_datasets import data + +source = data.co2_concentration.url + +base = alt.Chart( + source, + title="Carbon Dioxide in the Atmosphere" +).transform_calculate( + year="year(datum.Date)" +).transform_calculate( + decade="floor(datum.year / 10)" +).transform_calculate( + scaled_date="(datum.year % 10) + (month(datum.Date)/12)" +).transform_window( + first_date='first_value(scaled_date)', + last_date='last_value(scaled_date)', + sort=[{"field": "scaled_date", "order": "ascending"}], + groupby=['decade'], + frame=[None, None] +).transform_calculate( + end=( + "datum.first_date === datum.scaled_date ? 'first'" + ": datum.last_date === datum.scaled_date ? 'last'" + ": null" + ) +).encode( + alt.X("scaled_date:Q") + .title("Year into Decade") + .axis(tickCount=11), + alt.Y("CO2:Q") + .title("CO2 concentration in ppm") + .scale(zero=False) +) + +line = base.mark_line().encode( + alt.Color("decade:O") + .scale(scheme="magma") + .legend(None) +) + +text = base.encode(text="year:N") + +start_year = text.transform_filter( + alt.datum.end == 'first' +).mark_text(baseline="top") + +end_year = text.transform_filter( + alt.datum.end == 'last' +).mark_text(baseline="bottom") + +(line + start_year + end_year).configure_text( + align="left", + dx=1, + dy=3 +).properties(width=600, height=375) diff --git a/altair/examples/attribute_syntax/comet_chart.py b/altair/examples/attribute_syntax/comet_chart.py new file mode 100644 index 000000000..b8edff751 --- /dev/null +++ b/altair/examples/attribute_syntax/comet_chart.py @@ -0,0 +1,44 @@ +""" +Comet Chart +----------- +Inspired by `Zan Armstrong's comet chart `_ +this plot uses ``mark_trail`` to visualize change of grouped data over time. +A more elaborate example and explanation of creating comet charts in Altair +is shown in `this blogpost `_. +""" +# category: advanced calculations + +import altair as alt +import vega_datasets + +alt.Chart( + vega_datasets.data.barley.url, + title='Barley Yield comparison between 1932 and 1931' +).mark_trail().encode( + alt.X('year:O').title(None), + alt.Y('variety:N').title('Variety'), + alt.Size('yield:Q') + .scale(range=[0, 12]) + .legend(values=[20, 60]) + .title('Barley Yield (bushels/acre)'), + alt.Color('delta:Q') + .scale(domainMid=0) + .title('Yield Delta (%)'), + alt.Tooltip(['year:O', 'yield:Q']), + alt.Column('site:N').title('Site') +).transform_pivot( + "year", + value="yield", + groupby=["variety", "site"] +).transform_fold( + ["1931", "1932"], + as_=["year", "yield"] +).transform_calculate( + calculate="datum['1932'] - datum['1931']", + as_="delta" +).configure_legend( + orient='bottom', + direction='horizontal' +).configure_view( + stroke=None +) diff --git a/altair/examples/attribute_syntax/connected_scatterplot.py b/altair/examples/attribute_syntax/connected_scatterplot.py new file mode 100644 index 000000000..a5902841c --- /dev/null +++ b/altair/examples/attribute_syntax/connected_scatterplot.py @@ -0,0 +1,18 @@ +""" +Connected Scatter Plot (Lines with Custom Paths) +------------------------------------------------ + +This example show how the order encoding can be used to draw a custom path. The dataset tracks miles driven per capita along with gas prices annually from 1956 to 2010. +It is based on Hannah Fairfield's article 'Driving Shifts Into Reverse'. See https://archive.nytimes.com/www.nytimes.com/imagepages/2010/05/02/business/02metrics.html for the original. +""" +# category: scatter plots +import altair as alt +from vega_datasets import data + +source = data.driving() + +alt.Chart(source).mark_line(point=True).encode( + alt.X('miles').scale(zero=False), + alt.Y('gas').scale(zero=False), + order='year' +) diff --git a/altair/examples/attribute_syntax/density_stack.py b/altair/examples/attribute_syntax/density_stack.py new file mode 100644 index 000000000..56b0161f1 --- /dev/null +++ b/altair/examples/attribute_syntax/density_stack.py @@ -0,0 +1,35 @@ +""" +Stacked Density Estimates +------------------------- +To plot a stacked graph of estimates, use a shared ``extent`` and a fixed +number of subdivision ``steps`` to ensure that the points for each area align +well. Density estimates of measurements for each iris flower feature are plot +in a stacked method. In addition, setting ``counts`` to true multiplies the +densities by the number of data points in each group, preserving proportional +differences. +""" +# category: distributions + +import altair as alt +from vega_datasets import data + +source = data.iris() + +alt.Chart(source).transform_fold( + ['petalWidth', + 'petalLength', + 'sepalWidth', + 'sepalLength'], + as_ = ['Measurement_type', 'value'] +).transform_density( + density='value', + bandwidth=0.3, + groupby=['Measurement_type'], + extent= [0, 8], + counts = True, + steps=200 +).mark_area().encode( + alt.X('value:Q'), + alt.Y('density:Q').stack('zero'), + alt.Color('Measurement_type:N') +).properties(width=400, height=100) diff --git a/altair/examples/attribute_syntax/diverging_stacked_bar_chart.py b/altair/examples/attribute_syntax/diverging_stacked_bar_chart.py new file mode 100644 index 000000000..19ddc1d13 --- /dev/null +++ b/altair/examples/attribute_syntax/diverging_stacked_bar_chart.py @@ -0,0 +1,363 @@ +""" +Diverging Stacked Bar Chart +--------------------------- +This example shows a diverging stacked bar chart for sentiments towards a set of eight questions, displayed as percentages with neutral responses straddling the 0% mark. +""" +# category: bar charts +import altair as alt + +source = alt.pd.DataFrame([ + { + "question": "Question 1", + "type": "Strongly disagree", + "value": 24, + "percentage": 0.7, + "percentage_start": -19.1, + "percentage_end": -18.4 + }, + { + "question": "Question 1", + "type": "Disagree", + "value": 294, + "percentage": 9.1, + "percentage_start": -18.4, + "percentage_end": -9.2 + }, + { + "question": "Question 1", + "type": "Neither agree nor disagree", + "value": 594, + "percentage": 18.5, + "percentage_start": -9.2, + "percentage_end": 9.2 + }, + { + "question": "Question 1", + "type": "Agree", + "value": 1927, + "percentage": 59.9, + "percentage_start": 9.2, + "percentage_end": 69.2 + }, + { + "question": "Question 1", + "type": "Strongly agree", + "value": 376, + "percentage": 11.7, + "percentage_start": 69.2, + "percentage_end": 80.9 + }, + + { + "question": "Question 2", + "type": "Strongly disagree", + "value": 2, + "percentage": 18.2, + "percentage_start": -36.4, + "percentage_end": -18.2 + }, + { + "question": "Question 2", + "type": "Disagree", + "value": 2, + "percentage": 18.2, + "percentage_start": -18.2, + "percentage_end": 0 + }, + { + "question": "Question 2", + "type": "Neither agree nor disagree", + "value": 0, + "percentage": 0, + "percentage_start": 0, + "percentage_end": 0 + }, + { + "question": "Question 2", + "type": "Agree", + "value": 7, + "percentage": 63.6, + "percentage_start": 0, + "percentage_end": 63.6 + }, + { + "question": "Question 2", + "type": "Strongly agree", + "value": 11, + "percentage": 0, + "percentage_start": 63.6, + "percentage_end": 63.6 + }, + + { + "question": "Question 3", + "type": "Strongly disagree", + "value": 2, + "percentage": 20, + "percentage_start": -30, + "percentage_end": -10 + }, + { + "question": "Question 3", + "type": "Disagree", + "value": 0, + "percentage": 0, + "percentage_start": -10, + "percentage_end": -10 + }, + { + "question": "Question 3", + "type": "Neither agree nor disagree", + "value": 2, + "percentage": 20, + "percentage_start": -10, + "percentage_end": 10 + }, + { + "question": "Question 3", + "type": "Agree", + "value": 4, + "percentage": 40, + "percentage_start": 10, + "percentage_end": 50 + }, + { + "question": "Question 3", + "type": "Strongly agree", + "value": 2, + "percentage": 20, + "percentage_start": 50, + "percentage_end": 70 + }, + + { + "question": "Question 4", + "type": "Strongly disagree", + "value": 0, + "percentage": 0, + "percentage_start": -15.6, + "percentage_end": -15.6 + }, + { + "question": "Question 4", + "type": "Disagree", + "value": 2, + "percentage": 12.5, + "percentage_start": -15.6, + "percentage_end": -3.1 + }, + { + "question": "Question 4", + "type": "Neither agree nor disagree", + "value": 1, + "percentage": 6.3, + "percentage_start": -3.1, + "percentage_end": 3.1 + }, + { + "question": "Question 4", + "type": "Agree", + "value": 7, + "percentage": 43.8, + "percentage_start": 3.1, + "percentage_end": 46.9 + }, + { + "question": "Question 4", + "type": "Strongly agree", + "value": 6, + "percentage": 37.5, + "percentage_start": 46.9, + "percentage_end": 84.4 + }, + + { + "question": "Question 5", + "type": "Strongly disagree", + "value": 0, + "percentage": 0, + "percentage_start": -10.4, + "percentage_end": -10.4 + }, + { + "question": "Question 5", + "type": "Disagree", + "value": 1, + "percentage": 4.2, + "percentage_start": -10.4, + "percentage_end": -6.3 + }, + { + "question": "Question 5", + "type": "Neither agree nor disagree", + "value": 3, + "percentage": 12.5, + "percentage_start": -6.3, + "percentage_end": 6.3 + }, + { + "question": "Question 5", + "type": "Agree", + "value": 16, + "percentage": 66.7, + "percentage_start": 6.3, + "percentage_end": 72.9 + }, + { + "question": "Question 5", + "type": "Strongly agree", + "value": 4, + "percentage": 16.7, + "percentage_start": 72.9, + "percentage_end": 89.6 + }, + + { + "question": "Question 6", + "type": "Strongly disagree", + "value": 1, + "percentage": 6.3, + "percentage_start": -18.8, + "percentage_end": -12.5 + }, + { + "question": "Question 6", + "type": "Disagree", + "value": 1, + "percentage": 6.3, + "percentage_start": -12.5, + "percentage_end": -6.3 + }, + { + "question": "Question 6", + "type": "Neither agree nor disagree", + "value": 2, + "percentage": 12.5, + "percentage_start": -6.3, + "percentage_end": 6.3 + }, + { + "question": "Question 6", + "type": "Agree", + "value": 9, + "percentage": 56.3, + "percentage_start": 6.3, + "percentage_end": 62.5 + }, + { + "question": "Question 6", + "type": "Strongly agree", + "value": 3, + "percentage": 18.8, + "percentage_start": 62.5, + "percentage_end": 81.3 + }, + + { + "question": "Question 7", + "type": "Strongly disagree", + "value": 0, + "percentage": 0, + "percentage_start": -10, + "percentage_end": -10 + }, + { + "question": "Question 7", + "type": "Disagree", + "value": 0, + "percentage": 0, + "percentage_start": -10, + "percentage_end": -10 + }, + { + "question": "Question 7", + "type": "Neither agree nor disagree", + "value": 1, + "percentage": 20, + "percentage_start": -10, + "percentage_end": 10 + }, + { + "question": "Question 7", + "type": "Agree", + "value": 4, + "percentage": 80, + "percentage_start": 10, + "percentage_end": 90 + }, + { + "question": "Question 7", + "type": "Strongly agree", + "value": 0, + "percentage": 0, + "percentage_start": 90, + "percentage_end": 90 + }, + + { + "question": "Question 8", + "type": "Strongly disagree", + "value": 0, + "percentage": 0, + "percentage_start": 0, + "percentage_end": 0 + }, + { + "question": "Question 8", + "type": "Disagree", + "value": 0, + "percentage": 0, + "percentage_start": 0, + "percentage_end": 0 + }, + { + "question": "Question 8", + "type": "Neither agree nor disagree", + "value": 0, + "percentage": 0, + "percentage_start": 0, + "percentage_end": 0 + }, + { + "question": "Question 8", + "type": "Agree", + "value": 0, + "percentage": 0, + "percentage_start": 0, + "percentage_end": 0 + }, + { + "question": "Question 8", + "type": "Strongly agree", + "value": 2, + "percentage": 100, + "percentage_start": 0, + "percentage_end": 100 + } +]) + +color_scale = alt.Scale( + domain=[ + "Strongly disagree", + "Disagree", + "Neither agree nor disagree", + "Agree", + "Strongly agree" + ], + range=["#c30d24", "#f3a583", "#cccccc", "#94c6da", "#1770ab"] +) + +y_axis = alt.Axis( + title='Question', + offset=5, + ticks=False, + minExtent=60, + domain=False +) + +alt.Chart(source).mark_bar().encode( + x='percentage_start:Q', + x2='percentage_end:Q', + y=alt.Y('question:N').axis(y_axis), + color=alt.Color('type:N').title('Response').scale(color_scale), +) diff --git a/altair/examples/attribute_syntax/donut_chart.py b/altair/examples/attribute_syntax/donut_chart.py new file mode 100644 index 000000000..a734825da --- /dev/null +++ b/altair/examples/attribute_syntax/donut_chart.py @@ -0,0 +1,21 @@ +""" +Donut Chart +----------- +This example shows how to make a Donut Chart using ``mark_arc``. +This is adapted from a corresponding Vega-Lite Example: +`Donut Chart `_. +""" +# category: circular plots + +import pandas as pd +import altair as alt + +source = pd.DataFrame({ + "category": [1, 2, 3, 4, 5, 6], + "value": [4, 6, 10, 3, 7, 8] +}) + +alt.Chart(source).mark_arc(innerRadius=50).encode( + theta="value", + color="category:N", +) diff --git a/altair/examples/attribute_syntax/errorbars_with_ci.py b/altair/examples/attribute_syntax/errorbars_with_ci.py new file mode 100644 index 000000000..af950a45e --- /dev/null +++ b/altair/examples/attribute_syntax/errorbars_with_ci.py @@ -0,0 +1,24 @@ +""" +Error Bars with Confidence Interval +====================================== +This example shows how to show error bars using confidence intervals. +The confidence intervals are computed internally in vega by a non-parametric +`bootstrap of the mean `_. +""" +# category: uncertainties and trends +import altair as alt +from vega_datasets import data + +source = data.barley() + +error_bars = alt.Chart(source).mark_errorbar(extent='ci').encode( + alt.X('yield').scale(zero=False), + alt.Y('variety') +) + +points = alt.Chart(source).mark_point(filled=True, color='black').encode( + x=alt.X('mean(yield)'), + y=alt.Y('variety'), +) + +error_bars + points diff --git a/altair/examples/attribute_syntax/errorbars_with_std.py b/altair/examples/attribute_syntax/errorbars_with_std.py new file mode 100644 index 000000000..d20c154b9 --- /dev/null +++ b/altair/examples/attribute_syntax/errorbars_with_std.py @@ -0,0 +1,23 @@ +""" +Error Bars with Standard Deviation +---------------------------------- +This example shows how to show error bars with standard deviation using crop yields data of different +in the years of 1930s. +""" +# category: uncertainties and trends +import altair as alt +from vega_datasets import data + +source = data.barley() + +error_bars = alt.Chart(source).mark_errorbar(extent='stdev').encode( + x=alt.X('yield').scale(zero=False), + y=alt.Y('variety') +) + +points = alt.Chart(source).mark_point(filled=True, color='black').encode( + x=alt.X('mean(yield)'), + y=alt.Y('variety'), +) + +error_bars + points diff --git a/altair/examples/attribute_syntax/falkensee.py b/altair/examples/attribute_syntax/falkensee.py new file mode 100644 index 000000000..b5d01b86e --- /dev/null +++ b/altair/examples/attribute_syntax/falkensee.py @@ -0,0 +1,77 @@ +""" +Population of Falkensee from 1875 to 2014 +----------------------------------------- +This example is a reproduction of the Falkensee plot found in the Vega-Lite examples. +""" +# category: case studies +import altair as alt + +source = [ + {"year": "1875", "population": 1309}, + {"year": "1890", "population": 1558}, + {"year": "1910", "population": 4512}, + {"year": "1925", "population": 8180}, + {"year": "1933", "population": 15915}, + {"year": "1939", "population": 24824}, + {"year": "1946", "population": 28275}, + {"year": "1950", "population": 29189}, + {"year": "1964", "population": 29881}, + {"year": "1971", "population": 26007}, + {"year": "1981", "population": 24029}, + {"year": "1985", "population": 23340}, + {"year": "1989", "population": 22307}, + {"year": "1990", "population": 22087}, + {"year": "1991", "population": 22139}, + {"year": "1992", "population": 22105}, + {"year": "1993", "population": 22242}, + {"year": "1994", "population": 22801}, + {"year": "1995", "population": 24273}, + {"year": "1996", "population": 25640}, + {"year": "1997", "population": 27393}, + {"year": "1998", "population": 29505}, + {"year": "1999", "population": 32124}, + {"year": "2000", "population": 33791}, + {"year": "2001", "population": 35297}, + {"year": "2002", "population": 36179}, + {"year": "2003", "population": 36829}, + {"year": "2004", "population": 37493}, + {"year": "2005", "population": 38376}, + {"year": "2006", "population": 39008}, + {"year": "2007", "population": 39366}, + {"year": "2008", "population": 39821}, + {"year": "2009", "population": 40179}, + {"year": "2010", "population": 40511}, + {"year": "2011", "population": 40465}, + {"year": "2012", "population": 40905}, + {"year": "2013", "population": 41258}, + {"year": "2014", "population": 41777}, +] + +source2 = [ + {"start": "1933", "end": "1945", "event": "Nazi Rule"}, + {"start": "1948", "end": "1989", "event": "GDR (East Germany)"}, +] + + +source = alt.pd.DataFrame(source) +source2 = alt.pd.DataFrame(source2) + + +line = alt.Chart(source).mark_line(color="#333").encode( + alt.X("year:T").axis(format="%Y").title("Year"), + alt.Y("population").title("Population"), +) + +point = line.mark_point(color="#333") + +rect = alt.Chart(source2).mark_rect().encode( + x="start:T", + x2="end:T", + color=alt.Color("event:N").title("Event") +) + +(rect + line + point).properties( + title="Population of Falkensee from 1875 to 2014", + width=500, + height=300 +) diff --git a/altair/examples/attribute_syntax/gapminder_bubble_plot.py b/altair/examples/attribute_syntax/gapminder_bubble_plot.py new file mode 100644 index 000000000..839212885 --- /dev/null +++ b/altair/examples/attribute_syntax/gapminder_bubble_plot.py @@ -0,0 +1,18 @@ +""" +Gapminder Bubble Plot +===================== +This example shows how to make a bubble plot showing the correlation between +health and income for 187 countries in the world (modified from an example +in Lisa Charlotte Rost's blog post `'One Chart, Twelve Charting Libraries' `_. +""" +# category: case studies +import altair as alt +from vega_datasets import data + +source = data.gapminder_health_income.url + +alt.Chart(source).mark_circle().encode( + alt.X('income:Q').scale(type='log'), + alt.Y('health:Q').scale(zero=False), + size='population:Q' +) diff --git a/altair/examples/attribute_syntax/groupby-map.py b/altair/examples/attribute_syntax/groupby-map.py new file mode 100644 index 000000000..20f0817e6 --- /dev/null +++ b/altair/examples/attribute_syntax/groupby-map.py @@ -0,0 +1,36 @@ +""" +Grouped Points with Proportional Symbols Map +============================================ +This is a layered geographic visualization that groups points by state. +""" +# category: maps +import altair as alt +from vega_datasets import data + +airports = data.airports.url +states = alt.topo_feature(data.us_10m.url, feature='states') + +# US states background +background = alt.Chart(states).mark_geoshape( + fill='lightgray', + stroke='white' +).properties( + width=500, + height=300 +).project('albersUsa') + +# Airports grouped by state +points = alt.Chart(airports, title='Number of airports in US').transform_aggregate( + latitude='mean(latitude)', + longitude='mean(longitude)', + count='count()', + groupby=['state'] +).mark_circle().encode( + longitude='longitude:Q', + latitude='latitude:Q', + size=alt.Size('count:Q').title('Number of Airports'), + color=alt.value('steelblue'), + tooltip=['state:N','count:Q'] +) + +background + points diff --git a/altair/examples/attribute_syntax/grouped_bar_chart2.py b/altair/examples/attribute_syntax/grouped_bar_chart2.py new file mode 100644 index 000000000..671f83e44 --- /dev/null +++ b/altair/examples/attribute_syntax/grouped_bar_chart2.py @@ -0,0 +1,22 @@ +""" +Grouped Bar Chart with xOffset +------------------------------ +Like :ref:`gallery_grouped_bar_chart`, this example shows a grouped bar chart. Whereas :ref:`gallery_grouped_bar_chart` used the ``column`` encoding channel, this example uses the ``xOffset`` encoding channel. This is adapted from a corresponding Vega-Lite Example: +`Grouped Bar Chart `_. +""" +# category: bar charts +import altair as alt +import pandas as pd + +source = pd.DataFrame({ + "Category":list("AAABBBCCC"), + "Group":list("xyzxyzxyz"), + "Value":[0.1, 0.6, 0.9, 0.7, 0.2, 1.1, 0.6, 0.1, 0.2] +}) + +alt.Chart(source).mark_bar().encode( + x="Category:N", + y="Value:Q", + xOffset="Group:N", + color="Group:N" +) diff --git a/altair/examples/attribute_syntax/grouped_bar_chart_with_error_bars.py b/altair/examples/attribute_syntax/grouped_bar_chart_with_error_bars.py new file mode 100644 index 000000000..4ef796f12 --- /dev/null +++ b/altair/examples/attribute_syntax/grouped_bar_chart_with_error_bars.py @@ -0,0 +1,25 @@ +""" +Grouped Bar Chart with Error Bars +--------------------------------- +This example shows a grouped bar chart with error bars. +""" +# category: bar charts +import altair as alt +from vega_datasets import data + +source = data.barley() + +bars = alt.Chart().mark_bar().encode( + x='year:O', + y=alt.Y('mean(yield):Q').title('Mean Yield'), + color='year:N', +) + +error_bars = alt.Chart().mark_errorbar(extent='ci').encode( + x='year:O', + y='yield:Q' +) + +alt.layer(bars, error_bars, data=source).facet( + column='site:N' +) diff --git a/altair/examples/attribute_syntax/hexbins.py b/altair/examples/attribute_syntax/hexbins.py new file mode 100644 index 000000000..26f3890a0 --- /dev/null +++ b/altair/examples/attribute_syntax/hexbins.py @@ -0,0 +1,46 @@ +""" +Hexbin Chart +------------ +This example shows a hexbin chart. +""" +# category: tables +import altair as alt +from vega_datasets import data + +source = data.seattle_weather() + +# Size of the hexbins +size = 15 +# Count of distinct x features +xFeaturesCount = 12 +# Count of distinct y features +yFeaturesCount = 7 +# Name of the x field +xField = 'date' +# Name of the y field +yField = 'date' + +# the shape of a hexagon +hexagon = "M0,-2.3094010768L2,-1.1547005384 2,1.1547005384 0,2.3094010768 -2,1.1547005384 -2,-1.1547005384Z" + +alt.Chart(source).mark_point(size=size**2, shape=hexagon).encode( + alt.X('xFeaturePos:Q') + .title('Month') + .axis(grid=False, tickOpacity=0, domainOpacity=0), + alt.Y('day(' + yField + '):O') + .title('Weekday') + .axis(labelPadding=20, tickOpacity=0, domainOpacity=0), + stroke=alt.value('black'), + strokeWidth=alt.value(0.2), + fill=alt.Color('mean(temp_max):Q').scale(scheme='darkblue'), + tooltip=['month(' + xField + '):O', 'day(' + yField + '):O', 'mean(temp_max):Q'] +).transform_calculate( + # This field is required for the hexagonal X-Offset + xFeaturePos='(day(datum.' + yField + ') % 2) / 2 + month(datum.' + xField + ')' +).properties( + # Exact scaling factors to make the hexbins fit + width=size * xFeaturesCount * 2, + height=size * yFeaturesCount * 1.7320508076, # 1.7320508076 is approx. sin(60°)*2 +).configure_view( + strokeWidth=0 +) diff --git a/altair/examples/attribute_syntax/histogram_heatmap.py b/altair/examples/attribute_syntax/histogram_heatmap.py new file mode 100644 index 000000000..c697d1dd7 --- /dev/null +++ b/altair/examples/attribute_syntax/histogram_heatmap.py @@ -0,0 +1,16 @@ +""" +2D Histogram Heatmap +-------------------- +This example shows how to make a heatmap from binned quantitative data. +""" +# category: distributions +import altair as alt +from vega_datasets import data + +source = data.movies.url + +alt.Chart(source).mark_rect().encode( + alt.X('IMDB_Rating:Q').bin(maxbins=60), + alt.Y('Rotten_Tomatoes_Rating:Q').bin(maxbins=40), + alt.Color('count():Q').scale(scheme='greenblue') +) diff --git a/altair/examples/attribute_syntax/histogram_responsive.py b/altair/examples/attribute_syntax/histogram_responsive.py new file mode 100644 index 000000000..e8ce16cb6 --- /dev/null +++ b/altair/examples/attribute_syntax/histogram_responsive.py @@ -0,0 +1,34 @@ +""" +Histogram with Responsive Bins +------------------------------ +This shows an example of a histogram with bins that are responsive to a +selection domain. Click and drag on the bottom panel to see the bins +change on the top panel. +""" +# category: distributions +import altair as alt +from vega_datasets import data + +source = data.flights_5k.url + +brush = alt.selection_interval(encodings=['x']) + +base = alt.Chart(source).transform_calculate( + time="hours(datum.date) + minutes(datum.date) / 60" +).mark_bar().encode( + y='count():Q' +).properties( + width=600, + height=100 +) + +alt.vconcat( + base.encode( + alt.X('time:Q') + .bin(maxbins=30, extent=brush) + .scale(domain=brush) + ), + base.encode( + alt.X('time:Q').bin(maxbins=30), + ).add_params(brush) +) diff --git a/altair/examples/attribute_syntax/histogram_scatterplot.py b/altair/examples/attribute_syntax/histogram_scatterplot.py new file mode 100644 index 000000000..6286b615e --- /dev/null +++ b/altair/examples/attribute_syntax/histogram_scatterplot.py @@ -0,0 +1,16 @@ +""" +2D Histogram Scatter Plot +------------------------- +This example shows how to make a 2d histogram scatter plot. +""" +# category: distributions +import altair as alt +from vega_datasets import data + +source = data.movies.url + +alt.Chart(source).mark_circle().encode( + alt.X('IMDB_Rating:Q').bin(), + alt.Y('Rotten_Tomatoes_Rating:Q').bin(), + size='count()' +) diff --git a/altair/examples/attribute_syntax/histogram_with_a_global_mean_overlay.py b/altair/examples/attribute_syntax/histogram_with_a_global_mean_overlay.py new file mode 100644 index 000000000..bcb91a216 --- /dev/null +++ b/altair/examples/attribute_syntax/histogram_with_a_global_mean_overlay.py @@ -0,0 +1,24 @@ +""" +Histogram with a Global Mean Overlay +------------------------------------ +This example shows a histogram with a global mean overlay. +""" +# category: distributions +import altair as alt +from vega_datasets import data + +source = data.movies.url + +base = alt.Chart(source) + +bar = base.mark_bar().encode( + alt.X('IMDB_Rating:Q').bin().axis(None), + y='count()' +) + +rule = base.mark_rule(color='red').encode( + x='mean(IMDB_Rating):Q', + size=alt.value(5) +) + +bar + rule diff --git a/altair/examples/attribute_syntax/horizon_graph.py b/altair/examples/attribute_syntax/horizon_graph.py new file mode 100644 index 000000000..d2f534a73 --- /dev/null +++ b/altair/examples/attribute_syntax/horizon_graph.py @@ -0,0 +1,41 @@ +""" +Horizon Graph +------------- +This example shows how to make a Horizon Graph with 2 layers. (See https://idl.cs.washington.edu/papers/horizon/ for more details on Horizon Graphs.) +""" +# category: area charts +import altair as alt +import pandas as pd + +source = pd.DataFrame([ + {"x": 1, "y": 28}, {"x": 2, "y": 55}, + {"x": 3, "y": 43}, {"x": 4, "y": 91}, + {"x": 5, "y": 81}, {"x": 6, "y": 53}, + {"x": 7, "y": 19}, {"x": 8, "y": 87}, + {"x": 9, "y": 52}, {"x": 10, "y": 48}, + {"x": 11, "y": 24}, {"x": 12, "y": 49}, + {"x": 13, "y": 87}, {"x": 14, "y": 66}, + {"x": 15, "y": 17}, {"x": 16, "y": 27}, + {"x": 17, "y": 68}, {"x": 18, "y": 16}, + {"x": 19, "y": 49}, {"x": 20, "y": 15} +]) + +area1 = alt.Chart(source).mark_area( + clip=True, + interpolate='monotone', + opacity=0.6 +).encode( + alt.X('x').scale(zero=False, nice=False), + alt.Y('y').scale(domain=[0, 50]).title('y'), +).properties( + width=500, + height=75 +) + +area2 = area1.encode( + alt.Y('ny:Q').scale(domain=[0, 50]) +).transform_calculate( + "ny", alt.datum.y - 50 +) + +area1 + area2 diff --git a/altair/examples/attribute_syntax/interactive_cross_highlight.py b/altair/examples/attribute_syntax/interactive_cross_highlight.py new file mode 100644 index 000000000..f862cb973 --- /dev/null +++ b/altair/examples/attribute_syntax/interactive_cross_highlight.py @@ -0,0 +1,41 @@ +""" +Interactive Chart with Cross-Highlight +====================================== +This example shows an interactive chart where selections in one portion of +the chart affect what is shown in other panels. Click on the bar chart to +see a detail of the distribution in the upper panel. +""" +# category: interactive charts +import altair as alt +from vega_datasets import data + +source = data.movies.url + +pts = alt.selection(type="point", encodings=['x']) + +rect = alt.Chart(data.movies.url).mark_rect().encode( + alt.X('IMDB_Rating:Q').bin(), + alt.Y('Rotten_Tomatoes_Rating:Q').bin(), + alt.Color('count()').scale(scheme='greenblue').title('Total Records') +) + +circ = rect.mark_point().encode( + alt.ColorValue('grey'), + alt.Size('count()').title('Records in Selection') +).transform_filter( + pts +) + +bar = alt.Chart(source, width=550, height=200).mark_bar().encode( + x='Major_Genre:N', + y='count()', + color=alt.condition(pts, alt.ColorValue("steelblue"), alt.ColorValue("grey")) +).add_params(pts) + +alt.vconcat( + rect + circ, + bar +).resolve_legend( + color="independent", + size="independent" +) diff --git a/altair/examples/attribute_syntax/interactive_layered_crossfilter.py b/altair/examples/attribute_syntax/interactive_layered_crossfilter.py new file mode 100644 index 000000000..831365996 --- /dev/null +++ b/altair/examples/attribute_syntax/interactive_layered_crossfilter.py @@ -0,0 +1,42 @@ +""" +Interactive Crossfilter +======================= +This example shows a multi-panel view of the same data, where you can interactively +select a portion of the data in any of the panels to highlight that portion in any +of the other panels. +""" +# category: interactive charts +import altair as alt +from vega_datasets import data + +source = alt.UrlData( + data.flights_2k.url, + format={'parse': {'date': 'date'}} +) + +brush = alt.selection(type='interval', encodings=['x']) + +# Define the base chart, with the common parts of the +# background and highlights +base = alt.Chart(width=160, height=130).mark_bar().encode( + x=alt.X(alt.repeat('column')).bin(maxbins=20), + y='count()' +) + +# gray background with selection +background = base.encode( + color=alt.value('#ddd') +).add_params(brush) + +# blue highlights on the transformed data +highlight = base.transform_filter(brush) + +# layer the two charts & repeat +alt.layer( + background, + highlight, + data=source +).transform_calculate( + "time", + "hours(datum.date)" +).repeat(column=["distance", "delay", "time"]) diff --git a/altair/examples/attribute_syntax/interactive_legend.py b/altair/examples/attribute_syntax/interactive_legend.py new file mode 100644 index 000000000..80c47cf11 --- /dev/null +++ b/altair/examples/attribute_syntax/interactive_legend.py @@ -0,0 +1,23 @@ +""" +Interactive Legend +------------------ +The following shows how to create a chart with an interactive legend, by +binding the selection to ``"legend"``. Such a binding only works with +``selection_point`` when projected over a single field or encoding. +""" +# category: interactive charts +import altair as alt +from vega_datasets import data + +source = data.unemployment_across_industries.url + +selection = alt.selection_point(fields=['series'], bind='legend') + +alt.Chart(source).mark_area().encode( + alt.X('yearmonth(date):T').axis(domain=False, format='%Y', tickSize=0), + alt.Y('sum(count):Q').stack('center').axis(None), + alt.Color('series:N').scale(scheme='category20b'), + opacity=alt.condition(selection, alt.value(1), alt.value(0.2)) +).add_params( + selection +) diff --git a/altair/examples/attribute_syntax/interval_selection.py b/altair/examples/attribute_syntax/interval_selection.py new file mode 100644 index 000000000..f0aa303e9 --- /dev/null +++ b/altair/examples/attribute_syntax/interval_selection.py @@ -0,0 +1,29 @@ +""" +Interval Selection +================== + +This is an example of creating a stacked chart for which the domain of the +top chart can be selected by interacting with the bottom chart. +""" +# category: area charts +import altair as alt +from vega_datasets import data + +source = data.sp500.url + +brush = alt.selection(type='interval', encodings=['x']) + +base = alt.Chart(source, width=600, height=200).mark_area().encode( + x = 'date:T', + y = 'price:Q' +) + +upper = base.encode( + alt.X('date:T').scale(domain=brush) +) + +lower = base.properties( + height=60 +).add_params(brush) + +upper & lower diff --git a/altair/examples/attribute_syntax/iowa_electricity.py b/altair/examples/attribute_syntax/iowa_electricity.py new file mode 100644 index 000000000..252cb0423 --- /dev/null +++ b/altair/examples/attribute_syntax/iowa_electricity.py @@ -0,0 +1,19 @@ +""" +Iowa's Renewable Energy Boom +---------------------------- +This example is a fully developed stacked chart using the sample dataset of Iowa's electricity sources. +""" +# category: case studies +import altair as alt +from vega_datasets import data + +source = data.iowa_electricity() + +alt.Chart(source, title="Iowa's renewable energy boom").mark_area().encode( + alt.X("year:T").title("Year"), + alt.Y("net_generation:Q") + .title("Share of net generation") + .stack("normalize") + .axis(format=".0%"), + alt.Color("source:N").title("Electricity source") +) diff --git a/altair/examples/attribute_syntax/isotype.py b/altair/examples/attribute_syntax/isotype.py new file mode 100644 index 000000000..92850b729 --- /dev/null +++ b/altair/examples/attribute_syntax/isotype.py @@ -0,0 +1,81 @@ +''' +Isotype Visualization +===================== +Isotype Visualization shows the distribution of animals across UK and US. +Inspired by `Only An Ocean Between, 1943 `_. Population Live Stock, p.13. +This is adapted from Vega-Lite example https://vega.github.io/editor/#/examples/vega-lite/isotype_bar_chart +''' +# category: advanced calculations +import altair as alt +import pandas as pd + +source = pd.DataFrame([ + {'country': 'Great Britain', 'animal': 'cattle'}, + {'country': 'Great Britain', 'animal': 'cattle'}, + {'country': 'Great Britain', 'animal': 'cattle'}, + {'country': 'Great Britain', 'animal': 'pigs'}, + {'country': 'Great Britain', 'animal': 'pigs'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'pigs'}, + {'country': 'United States', 'animal': 'pigs'}, + {'country': 'United States', 'animal': 'pigs'}, + {'country': 'United States', 'animal': 'pigs'}, + {'country': 'United States', 'animal': 'pigs'}, + {'country': 'United States', 'animal': 'pigs'}, + {'country': 'United States', 'animal': 'sheep'}, + {'country': 'United States', 'animal': 'sheep'}, + {'country': 'United States', 'animal': 'sheep'}, + {'country': 'United States', 'animal': 'sheep'}, + {'country': 'United States', 'animal': 'sheep'}, + {'country': 'United States', 'animal': 'sheep'}, + {'country': 'United States', 'animal': 'sheep'} + ]) + +domains = ['person', 'cattle', 'pigs', 'sheep'] + +shape_scale = alt.Scale( + domain=domains, + range=[ + 'M1.7 -1.7h-0.8c0.3 -0.2 0.6 -0.5 0.6 -0.9c0 -0.6 -0.4 -1 -1 -1c-0.6 0 -1 0.4 -1 1c0 0.4 0.2 0.7 0.6 0.9h-0.8c-0.4 0 -0.7 0.3 -0.7 0.6v1.9c0 0.3 0.3 0.6 0.6 0.6h0.2c0 0 0 0.1 0 0.1v1.9c0 0.3 0.2 0.6 0.3 0.6h1.3c0.2 0 0.3 -0.3 0.3 -0.6v-1.8c0 0 0 -0.1 0 -0.1h0.2c0.3 0 0.6 -0.3 0.6 -0.6v-2c0.2 -0.3 -0.1 -0.6 -0.4 -0.6z', + 'M4 -2c0 0 0.9 -0.7 1.1 -0.8c0.1 -0.1 -0.1 0.5 -0.3 0.7c-0.2 0.2 1.1 1.1 1.1 1.2c0 0.2 -0.2 0.8 -0.4 0.7c-0.1 0 -0.8 -0.3 -1.3 -0.2c-0.5 0.1 -1.3 1.6 -1.5 2c-0.3 0.4 -0.6 0.4 -0.6 0.4c0 0.1 0.3 1.7 0.4 1.8c0.1 0.1 -0.4 0.1 -0.5 0c0 0 -0.6 -1.9 -0.6 -1.9c-0.1 0 -0.3 -0.1 -0.3 -0.1c0 0.1 -0.5 1.4 -0.4 1.6c0.1 0.2 0.1 0.3 0.1 0.3c0 0 -0.4 0 -0.4 0c0 0 -0.2 -0.1 -0.1 -0.3c0 -0.2 0.3 -1.7 0.3 -1.7c0 0 -2.8 -0.9 -2.9 -0.8c-0.2 0.1 -0.4 0.6 -0.4 1c0 0.4 0.5 1.9 0.5 1.9l-0.5 0l-0.6 -2l0 -0.6c0 0 -1 0.8 -1 1c0 0.2 -0.2 1.3 -0.2 1.3c0 0 0.3 0.3 0.2 0.3c0 0 -0.5 0 -0.5 0c0 0 -0.2 -0.2 -0.1 -0.4c0 -0.1 0.2 -1.6 0.2 -1.6c0 0 0.5 -0.4 0.5 -0.5c0 -0.1 0 -2.7 -0.2 -2.7c-0.1 0 -0.4 2 -0.4 2c0 0 0 0.2 -0.2 0.5c-0.1 0.4 -0.2 1.1 -0.2 1.1c0 0 -0.2 -0.1 -0.2 -0.2c0 -0.1 -0.1 -0.7 0 -0.7c0.1 -0.1 0.3 -0.8 0.4 -1.4c0 -0.6 0.2 -1.3 0.4 -1.5c0.1 -0.2 0.6 -0.4 0.6 -0.4z', + 'M1.2 -2c0 0 0.7 0 1.2 0.5c0.5 0.5 0.4 0.6 0.5 0.6c0.1 0 0.7 0 0.8 0.1c0.1 0 0.2 0.2 0.2 0.2c0 0 -0.6 0.2 -0.6 0.3c0 0.1 0.4 0.9 0.6 0.9c0.1 0 0.6 0 0.6 0.1c0 0.1 0 0.7 -0.1 0.7c-0.1 0 -1.2 0.4 -1.5 0.5c-0.3 0.1 -1.1 0.5 -1.1 0.7c-0.1 0.2 0.4 1.2 0.4 1.2l-0.4 0c0 0 -0.4 -0.8 -0.4 -0.9c0 -0.1 -0.1 -0.3 -0.1 -0.3l-0.2 0l-0.5 1.3l-0.4 0c0 0 -0.1 -0.4 0 -0.6c0.1 -0.1 0.3 -0.6 0.3 -0.7c0 0 -0.8 0 -1.5 -0.1c-0.7 -0.1 -1.2 -0.3 -1.2 -0.2c0 0.1 -0.4 0.6 -0.5 0.6c0 0 0.3 0.9 0.3 0.9l-0.4 0c0 0 -0.4 -0.5 -0.4 -0.6c0 -0.1 -0.2 -0.6 -0.2 -0.5c0 0 -0.4 0.4 -0.6 0.4c-0.2 0.1 -0.4 0.1 -0.4 0.1c0 0 -0.1 0.6 -0.1 0.6l-0.5 0l0 -1c0 0 0.5 -0.4 0.5 -0.5c0 -0.1 -0.7 -1.2 -0.6 -1.4c0.1 -0.1 0.1 -1.1 0.1 -1.1c0 0 -0.2 0.1 -0.2 0.1c0 0 0 0.9 0 1c0 0.1 -0.2 0.3 -0.3 0.3c-0.1 0 0 -0.5 0 -0.9c0 -0.4 0 -0.4 0.2 -0.6c0.2 -0.2 0.6 -0.3 0.8 -0.8c0.3 -0.5 1 -0.6 1 -0.6z', + 'M-4.1 -0.5c0.2 0 0.2 0.2 0.5 0.2c0.3 0 0.3 -0.2 0.5 -0.2c0.2 0 0.2 0.2 0.4 0.2c0.2 0 0.2 -0.2 0.5 -0.2c0.2 0 0.2 0.2 0.4 0.2c0.2 0 0.2 -0.2 0.4 -0.2c0.1 0 0.2 0.2 0.4 0.1c0.2 0 0.2 -0.2 0.4 -0.3c0.1 0 0.1 -0.1 0.4 0c0.3 0 0.3 -0.4 0.6 -0.4c0.3 0 0.6 -0.3 0.7 -0.2c0.1 0.1 1.4 1 1.3 1.4c-0.1 0.4 -0.3 0.3 -0.4 0.3c-0.1 0 -0.5 -0.4 -0.7 -0.2c-0.3 0.2 -0.1 0.4 -0.2 0.6c-0.1 0.1 -0.2 0.2 -0.3 0.4c0 0.2 0.1 0.3 0 0.5c-0.1 0.2 -0.3 0.2 -0.3 0.5c0 0.3 -0.2 0.3 -0.3 0.6c-0.1 0.2 0 0.3 -0.1 0.5c-0.1 0.2 -0.1 0.2 -0.2 0.3c-0.1 0.1 0.3 1.1 0.3 1.1l-0.3 0c0 0 -0.3 -0.9 -0.3 -1c0 -0.1 -0.1 -0.2 -0.3 -0.2c-0.2 0 -0.3 0.1 -0.4 0.4c0 0.3 -0.2 0.8 -0.2 0.8l-0.3 0l0.3 -1c0 0 0.1 -0.6 -0.2 -0.5c-0.3 0.1 -0.2 -0.1 -0.4 -0.1c-0.2 -0.1 -0.3 0.1 -0.4 0c-0.2 -0.1 -0.3 0.1 -0.5 0c-0.2 -0.1 -0.1 0 -0.3 0.3c-0.2 0.3 -0.4 0.3 -0.4 0.3l0.2 1.1l-0.3 0l-0.2 -1.1c0 0 -0.4 -0.6 -0.5 -0.4c-0.1 0.3 -0.1 0.4 -0.3 0.4c-0.1 -0.1 -0.2 1.1 -0.2 1.1l-0.3 0l0.2 -1.1c0 0 -0.3 -0.1 -0.3 -0.5c0 -0.3 0.1 -0.5 0.1 -0.7c0.1 -0.2 -0.1 -1 -0.2 -1.1c-0.1 -0.2 -0.2 -0.8 -0.2 -0.8c0 0 -0.1 -0.5 0.4 -0.8z' + ] +) + +color_scale = alt.Scale( + domain=domains, + range=['rgb(162,160,152)', 'rgb(194,81,64)', 'rgb(93,93,93)', 'rgb(91,131,149)'] +) + +alt.Chart(source).mark_point(filled=True, opacity=1, size=100).encode( + alt.X('x:O').axis(None), + alt.Y('animal:O').axis(None), + alt.Row('country:N').header(title=''), + alt.Shape('animal:N').legend(None).scale(shape_scale), + alt.Color('animal:N').legend(None).scale(color_scale), +).transform_window( + x='rank()', + groupby=['country', 'animal'] +).properties( + width=550, + height=140 +) diff --git a/altair/examples/attribute_syntax/isotype_emoji.py b/altair/examples/attribute_syntax/isotype_emoji.py new file mode 100644 index 000000000..313af8e82 --- /dev/null +++ b/altair/examples/attribute_syntax/isotype_emoji.py @@ -0,0 +1,66 @@ +''' +Isotype Visualization with Emoji +================================ +Isotype Visualization shows the distribution of animals across UK and US, using unicode emoji +marks rather than custom SVG paths (see https://altair-viz.github.io/gallery/isotype.html). +This is adapted from Vega-Lite example https://vega.github.io/vega-lite/examples/isotype_bar_chart_emoji.html. +''' +# category:advanced calculations +import altair as alt +import pandas as pd + +source = pd.DataFrame([ + {'country': 'Great Britain', 'animal': 'cattle'}, + {'country': 'Great Britain', 'animal': 'cattle'}, + {'country': 'Great Britain', 'animal': 'cattle'}, + {'country': 'Great Britain', 'animal': 'pigs'}, + {'country': 'Great Britain', 'animal': 'pigs'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'pigs'}, + {'country': 'United States', 'animal': 'pigs'}, + {'country': 'United States', 'animal': 'pigs'}, + {'country': 'United States', 'animal': 'pigs'}, + {'country': 'United States', 'animal': 'pigs'}, + {'country': 'United States', 'animal': 'pigs'}, + {'country': 'United States', 'animal': 'sheep'}, + {'country': 'United States', 'animal': 'sheep'}, + {'country': 'United States', 'animal': 'sheep'}, + {'country': 'United States', 'animal': 'sheep'}, + {'country': 'United States', 'animal': 'sheep'}, + {'country': 'United States', 'animal': 'sheep'}, + {'country': 'United States', 'animal': 'sheep'} + ]) + + +alt.Chart(source).mark_text(size=45, baseline='middle').encode( + alt.X('x:O').axis(None), + alt.Y('animal:O').axis(None), + alt.Row('country:N').title(''), + alt.Text('emoji:N') +).transform_calculate( + emoji="{'cattle': '🐄', 'pigs': '🐖', 'sheep': '🐏'}[datum.animal]" +).transform_window( + x='rank()', + groupby=['country', 'animal'] +).properties( + width=550, + height=140 +) diff --git a/altair/examples/attribute_syntax/isotype_grid.py b/altair/examples/attribute_syntax/isotype_grid.py new file mode 100644 index 000000000..d0a9b6d4b --- /dev/null +++ b/altair/examples/attribute_syntax/isotype_grid.py @@ -0,0 +1,38 @@ +""" +Isotype Grid +------------ +This example is a grid of isotype figures. +""" +# category: advanced calculations +import altair as alt +import pandas as pd + +data = pd.DataFrame([dict(id=i) for i in range(1, 101)]) + +person = ( + "M1.7 -1.7h-0.8c0.3 -0.2 0.6 -0.5 0.6 -0.9c0 -0.6 " + "-0.4 -1 -1 -1c-0.6 0 -1 0.4 -1 1c0 0.4 0.2 0.7 0.6 " + "0.9h-0.8c-0.4 0 -0.7 0.3 -0.7 0.6v1.9c0 0.3 0.3 0.6 " + "0.6 0.6h0.2c0 0 0 0.1 0 0.1v1.9c0 0.3 0.2 0.6 0.3 " + "0.6h1.3c0.2 0 0.3 -0.3 0.3 -0.6v-1.8c0 0 0 -0.1 0 " + "-0.1h0.2c0.3 0 0.6 -0.3 0.6 -0.6v-2c0.2 -0.3 -0.1 " + "-0.6 -0.4 -0.6z" +) + +alt.Chart(data).transform_calculate( + row="ceil(datum.id/10)" +).transform_calculate( + col="datum.id - datum.row*10" +).mark_point( + filled=True, + size=50 +).encode( + alt.X("col:O").axis(None), + alt.Y("row:O").axis(None), + alt.ShapeValue(person) +).properties( + width=400, + height=400 +).configure_view( + strokeWidth=0 +) diff --git a/altair/examples/attribute_syntax/lasagna_plot.py b/altair/examples/attribute_syntax/lasagna_plot.py new file mode 100644 index 000000000..0da7c44fd --- /dev/null +++ b/altair/examples/attribute_syntax/lasagna_plot.py @@ -0,0 +1,31 @@ +""" +Lasagna Plot (Dense Time-Series Heatmap) +---------------------------------------- +""" +# category: tables +import altair as alt +from vega_datasets import data + +source = data.stocks() + +color_condition = alt.condition( + "month(datum.value) == 1 && date(datum.value) == 1", + alt.value("black"), + alt.value(None), +) + +alt.Chart(source, width=300, height=100).transform_filter( + alt.datum.symbol != "GOOG" +).mark_rect().encode( + alt.X("yearmonthdate(date):O") + .title("Time") + .axis( + format="%Y", + labelAngle=0, + labelOverlap=False, + labelColor=color_condition, + tickColor=color_condition, + ), + alt.Y("symbol:N").title(None), + alt.Color("sum(price)").title("Price") +) diff --git a/altair/examples/attribute_syntax/layered_area_chart.py b/altair/examples/attribute_syntax/layered_area_chart.py new file mode 100644 index 000000000..83eb51b75 --- /dev/null +++ b/altair/examples/attribute_syntax/layered_area_chart.py @@ -0,0 +1,16 @@ +""" +Layered Area Chart +------------------ +This example shows a layered area chart. +""" +# category: area charts +import altair as alt +from vega_datasets import data + +source = data.iowa_electricity() + +alt.Chart(source).mark_area(opacity=0.3).encode( + x="year:T", + y=alt.Y("net_generation:Q").stack(None), + color="source:N" +) diff --git a/altair/examples/attribute_syntax/layered_bar_chart.py b/altair/examples/attribute_syntax/layered_bar_chart.py new file mode 100644 index 000000000..ba485fea7 --- /dev/null +++ b/altair/examples/attribute_syntax/layered_bar_chart.py @@ -0,0 +1,16 @@ +""" +Layered Bar Chart +----------------- +This example shows a segmented bar chart that is layered rather than stacked. +""" +# category: bar charts +import altair as alt +from vega_datasets import data + +source = data.iowa_electricity() + +alt.Chart(source).mark_bar(opacity=0.7).encode( + x='year:O', + y=alt.Y('net_generation:Q').stack(None), + color="source", +) diff --git a/altair/examples/attribute_syntax/layered_chart_with_dual_axis.py b/altair/examples/attribute_syntax/layered_chart_with_dual_axis.py new file mode 100644 index 000000000..d14fbca57 --- /dev/null +++ b/altair/examples/attribute_syntax/layered_chart_with_dual_axis.py @@ -0,0 +1,28 @@ +""" +Layered chart with Dual-Axis +---------------------------- +This example shows how to create a second independent y axis. +""" +# category: advanced calculations + +import altair as alt +from vega_datasets import data + +source = data.seattle_weather() + +base = alt.Chart(source).encode( + alt.X('month(date):T').axis(title=None) +) + +area = base.mark_area(opacity=0.3, color='#57A44C').encode( + alt.Y('average(temp_max)').title('Avg. Temperature (°C)', titleColor='#57A44C'), + alt.Y2('average(temp_min)') +) + +line = base.mark_line(stroke='#5276A7', interpolate='monotone').encode( + alt.Y('average(precipitation)').title('Precipitation (inches)', titleColor='#5276A7') +) + +alt.layer(area, line).resolve_scale( + y='independent' +) diff --git a/altair/examples/attribute_syntax/layered_heatmap_text.py b/altair/examples/attribute_syntax/layered_heatmap_text.py new file mode 100644 index 000000000..7a61c08cb --- /dev/null +++ b/altair/examples/attribute_syntax/layered_heatmap_text.py @@ -0,0 +1,41 @@ +""" +Text over a Heatmap +------------------- + +An example of a layered chart of text over a heatmap using the cars dataset. +""" +# category: tables +import altair as alt +from vega_datasets import data + +source = data.cars() + +# Configure common options. We specify the aggregation +# as a transform here so we can reuse it in both layers. +base = alt.Chart(source).transform_aggregate( + mean_horsepower='mean(Horsepower)', + groupby=['Origin', 'Cylinders'] +).encode( + alt.X('Cylinders:O'), + alt.Y('Origin:O'), +) + +# Configure heatmap +heatmap = base.mark_rect().encode( + alt.Color('mean_horsepower:Q') + .scale(scheme='viridis') + .title("Mean of Horsepower") +) + +# Configure text +text = base.mark_text(baseline='middle').encode( + alt.Text('mean_horsepower:Q', format=".0f"), + color=alt.condition( + alt.datum.mean_horsepower > 150, + alt.value('black'), + alt.value('white') + ) +) + +# Draw the chart +heatmap + text diff --git a/altair/examples/attribute_syntax/layered_histogram.py b/altair/examples/attribute_syntax/layered_histogram.py new file mode 100644 index 000000000..62c7dccf6 --- /dev/null +++ b/altair/examples/attribute_syntax/layered_histogram.py @@ -0,0 +1,29 @@ +""" +Layered Histogram +================= +This example shows how to use opacity to make a layered histogram in Altair. +""" +# category: distributions +import pandas as pd +import altair as alt +import numpy as np +np.random.seed(42) + +# Generating Data +source = pd.DataFrame({ + 'Trial A': np.random.normal(0, 0.8, 1000), + 'Trial B': np.random.normal(-2, 1, 1000), + 'Trial C': np.random.normal(3, 2, 1000) +}) + +alt.Chart(source).transform_fold( + ['Trial A', 'Trial B', 'Trial C'], + as_=['Experiment', 'Measurement'] +).mark_bar( + opacity=0.3, + binSpacing=0 +).encode( + alt.X('Measurement:Q').bin(maxbins=100), + alt.Y('count()').stack(None), + alt.Color('Experiment:N') +) diff --git a/altair/examples/attribute_syntax/line_chart_with_color_datum.py b/altair/examples/attribute_syntax/line_chart_with_color_datum.py new file mode 100644 index 000000000..77cad9574 --- /dev/null +++ b/altair/examples/attribute_syntax/line_chart_with_color_datum.py @@ -0,0 +1,23 @@ +""" +Line Chart with Datum for Color +------------------------------- +An example of using ``repeat`` inside ``datum`` to color a multi-series line chart. +This is adapted from this corresponding Vega-Lite Example: +`Repeat and Layer to Show Different Movie Measures `_. +""" +# category: line charts + +import altair as alt +from vega_datasets import data + +source = data.movies() + +alt.Chart(source).mark_line().encode( + alt.X("IMDB_Rating").bin(True), + alt.Y(alt.repeat("layer")) + .aggregate("mean") + .title("Mean of US and Worldwide Gross"), + color=alt.datum(alt.repeat("layer")), +).repeat( + layer=["US_Gross", "Worldwide_Gross"] +) diff --git a/altair/examples/attribute_syntax/line_chart_with_cumsum.py b/altair/examples/attribute_syntax/line_chart_with_cumsum.py new file mode 100644 index 000000000..ef3144fe1 --- /dev/null +++ b/altair/examples/attribute_syntax/line_chart_with_cumsum.py @@ -0,0 +1,24 @@ +""" +Line Chart with Cumulative Sum +------------------------------ +This chart creates a simple line chart from the cumulative sum of a fields. +""" +# category: line charts +import altair as alt +from vega_datasets import data + +source = data.wheat() + +alt.Chart(source, width=600).mark_line().transform_window( + # Sort the data chronologically + sort=[{'field': 'year'}], + # Include all previous records before the current record and none after + # (This is the default value so you could skip it and it would still work.) + frame=[None, 0], + # What to add up as you go + cumulative_wheat='sum(wheat)' +).encode( + x='year:O', + # Plot the calculated field created by the transformation + y='cumulative_wheat:Q' +) diff --git a/altair/examples/attribute_syntax/line_chart_with_custom_legend.py b/altair/examples/attribute_syntax/line_chart_with_custom_legend.py new file mode 100644 index 000000000..2ee60088e --- /dev/null +++ b/altair/examples/attribute_syntax/line_chart_with_custom_legend.py @@ -0,0 +1,40 @@ +""" +Line Chart with Custom Legend +----------------------------- +This example uses the argmax aggregation function in order to create a custom +legend for a line chart. +""" +# category: line charts +import altair as alt +from vega_datasets import data + + +source = data.stocks() + +base = alt.Chart(source).encode( + alt.Color("symbol").legend(None) +).transform_filter( + "datum.symbol !== 'IBM'" +).properties( + width=500 +) + +line = base.mark_line().encode(x="date", y="price") + + +last_price = base.mark_circle().encode( + alt.X("last_date['date']:T"), + alt.Y("last_date['price']:Q") +).transform_aggregate( + last_date="argmax(date)", + groupby=["symbol"] +) + +company_name = last_price.mark_text(align="left", dx=4).encode(text="symbol") + +chart = (line + last_price + company_name).encode( + x=alt.X().title("date"), + y=alt.Y().title("price") +) + +chart diff --git a/altair/examples/attribute_syntax/line_percent.py b/altair/examples/attribute_syntax/line_percent.py new file mode 100644 index 000000000..52e047034 --- /dev/null +++ b/altair/examples/attribute_syntax/line_percent.py @@ -0,0 +1,18 @@ +""" +Line Chart with Percent axis +---------------------------- +This example shows how to format the tick labels of the y-axis of a chart as percentages. +""" +# category: line charts +import altair as alt +from vega_datasets import data + +source = data.jobs.url + +alt.Chart(source).mark_line().encode( + alt.X('year:O'), + alt.Y('perc:Q').axis(format='%'), + alt.Color('sex:N') +).transform_filter( + alt.datum.job == 'Welder' +) diff --git a/altair/examples/attribute_syntax/line_with_ci.py b/altair/examples/attribute_syntax/line_with_ci.py new file mode 100644 index 000000000..744f453d0 --- /dev/null +++ b/altair/examples/attribute_syntax/line_with_ci.py @@ -0,0 +1,22 @@ +""" +Line Chart with Confidence Interval Band +---------------------------------------- +How to make a line chart with a bootstrapped 95% confidence interval band. +""" +# category: uncertainties and trends +import altair as alt +from vega_datasets import data + +source = data.cars() + +line = alt.Chart(source).mark_line().encode( + x='Year', + y='mean(Miles_per_Gallon)' +) + +band = alt.Chart(source).mark_errorband(extent='ci').encode( + x='Year', + y=alt.Y('Miles_per_Gallon').title('Miles/Gallon'), +) + +band + line diff --git a/altair/examples/line_with_last_value_labeled.py b/altair/examples/attribute_syntax/line_with_last_value_labeled.py similarity index 100% rename from altair/examples/line_with_last_value_labeled.py rename to altair/examples/attribute_syntax/line_with_last_value_labeled.py diff --git a/altair/examples/attribute_syntax/line_with_log_scale.py b/altair/examples/attribute_syntax/line_with_log_scale.py new file mode 100644 index 000000000..740a670cb --- /dev/null +++ b/altair/examples/attribute_syntax/line_with_log_scale.py @@ -0,0 +1,15 @@ +""" +Line Chart with Logarithmic Scale +--------------------------------- +How to make a line chart on a `Logarithmic scale `_. +""" +# category: line charts +import altair as alt +from vega_datasets import data + +source = data.population() + +alt.Chart(source).mark_line().encode( + x='year:O', + y=alt.Y('sum(people)').scale(type="log") +) diff --git a/altair/examples/attribute_syntax/london_tube.py b/altair/examples/attribute_syntax/london_tube.py new file mode 100644 index 000000000..b19ef9acc --- /dev/null +++ b/altair/examples/attribute_syntax/london_tube.py @@ -0,0 +1,51 @@ +""" +London Tube Lines +================= +This example shows the London tube lines against the background of the +borough boundaries. It is based on the vega-lite example at +https://vega.github.io/vega-lite/examples/geo_layer_line_london.html. +""" +# category: case studies +import altair as alt +from vega_datasets import data + +boroughs = alt.topo_feature(data.londonBoroughs.url, 'boroughs') +tubelines = alt.topo_feature(data.londonTubeLines.url, 'line') +centroids = data.londonCentroids.url + +background = alt.Chart(boroughs, width=700, height=500).mark_geoshape( + stroke='white', + strokeWidth=2 +).encode( + color=alt.value('#eee'), +) + +labels = alt.Chart(centroids).mark_text().encode( + longitude='cx:Q', + latitude='cy:Q', + text='bLabel:N', + size=alt.value(8), + opacity=alt.value(0.6) +).transform_calculate( + "bLabel", "indexof (datum.name,' ') > 0 ? substring(datum.name,0,indexof(datum.name, ' ')) : datum.name" +) + +line_scale = alt.Scale(domain=["Bakerloo", "Central", "Circle", "District", "DLR", + "Hammersmith & City", "Jubilee", "Metropolitan", "Northern", + "Piccadilly", "Victoria", "Waterloo & City"], + range=["rgb(137,78,36)", "rgb(220,36,30)", "rgb(255,206,0)", + "rgb(1,114,41)", "rgb(0,175,173)", "rgb(215,153,175)", + "rgb(106,114,120)", "rgb(114,17,84)", "rgb(0,0,0)", + "rgb(0,24,168)", "rgb(0,160,226)", "rgb(106,187,170)"]) + +lines = alt.Chart(tubelines).mark_geoshape( + filled=False, + strokeWidth=2 +).encode( + alt.Color('id:N') + .title(None) + .legend(orient='bottom-right', offset=0) + .scale(line_scale) +) + +background + labels + lines diff --git a/altair/examples/attribute_syntax/mosaic_with_labels.py b/altair/examples/attribute_syntax/mosaic_with_labels.py new file mode 100644 index 000000000..d77ed05ab --- /dev/null +++ b/altair/examples/attribute_syntax/mosaic_with_labels.py @@ -0,0 +1,85 @@ +""" +Mosaic Chart with Labels +------------------------ +""" +# category: tables + +import altair as alt +from vega_datasets import data + +source = data.cars() + +base = ( + alt.Chart(source) + .transform_aggregate(count_="count()", groupby=["Origin", "Cylinders"]) + .transform_stack( + stack="count_", + as_=["stack_count_Origin1", "stack_count_Origin2"], + offset="normalize", + sort=[alt.SortField("Origin", "ascending")], + groupby=[], + ) + .transform_window( + x="min(stack_count_Origin1)", + x2="max(stack_count_Origin2)", + rank_Cylinders="dense_rank()", + distinct_Cylinders="distinct(Cylinders)", + groupby=["Origin"], + frame=[None, None], + sort=[alt.SortField("Cylinders", "ascending")], + ) + .transform_window( + rank_Origin="dense_rank()", + frame=[None, None], + sort=[alt.SortField("Origin", "ascending")], + ) + .transform_stack( + stack="count_", + groupby=["Origin"], + as_=["y", "y2"], + offset="normalize", + sort=[alt.SortField("Cylinders", "ascending")], + ) + .transform_calculate( + ny="datum.y + (datum.rank_Cylinders - 1) * datum.distinct_Cylinders * 0.01 / 3", + ny2="datum.y2 + (datum.rank_Cylinders - 1) * datum.distinct_Cylinders * 0.01 / 3", + nx="datum.x + (datum.rank_Origin - 1) * 0.01", + nx2="datum.x2 + (datum.rank_Origin - 1) * 0.01", + xc="(datum.nx+datum.nx2)/2", + yc="(datum.ny+datum.ny2)/2", + ) +) + + +rect = base.mark_rect().encode( + x=alt.X("nx:Q").axis(None), + x2="nx2", + y="ny:Q", + y2="ny2", + color=alt.Color("Origin:N").legend(None), + opacity=alt.Opacity("Cylinders:Q").legend(None), + tooltip=["Origin:N", "Cylinders:Q"], +) + + +text = base.mark_text(baseline="middle").encode( + alt.X("xc:Q").axis(None), + alt.Y("yc:Q").title("Cylinders"), + text="Cylinders:N" +) + +mosaic = rect + text + +origin_labels = base.mark_text(baseline="middle", align="center").encode( + alt.X("min(xc):Q").title("Origin").axis(orient="top"), + alt.Color("Origin").legend(None), + text="Origin", +) + +( + (origin_labels & mosaic) + .resolve_scale(x="shared") + .configure_view(stroke="") + .configure_concat(spacing=10) + .configure_axis(domain=False, ticks=False, labels=False, grid=False) +) diff --git a/altair/examples/attribute_syntax/multifeature_scatter_plot.py b/altair/examples/attribute_syntax/multifeature_scatter_plot.py new file mode 100644 index 000000000..164b647bd --- /dev/null +++ b/altair/examples/attribute_syntax/multifeature_scatter_plot.py @@ -0,0 +1,17 @@ +""" +Multifeature Scatter Plot +========================= +This example shows how to make a scatter plot with multiple feature encodings. +""" +# category: scatter plots +import altair as alt +from vega_datasets import data + +source = data.iris() + +alt.Chart(source).mark_circle().encode( + alt.X('sepalLength').scale(zero=False), + alt.Y('sepalWidth').scale(zero=False, padding=1), + color='species', + size='petalWidth' +) diff --git a/altair/examples/attribute_syntax/multiline_highlight.py b/altair/examples/attribute_syntax/multiline_highlight.py new file mode 100644 index 000000000..0e3f7781b --- /dev/null +++ b/altair/examples/attribute_syntax/multiline_highlight.py @@ -0,0 +1,38 @@ +""" +Multi-Line Highlight +==================== +This multi-line chart uses an invisible Voronoi tessellation to handle mouseover to +identify the nearest point and then highlight the line on which the point falls. +It is adapted from the Vega-Lite example found at +https://bl.ocks.org/amitkaps/fe4238e716db53930b2f1a70d3401701 +""" +# category: interactive charts +import altair as alt +from vega_datasets import data + +source = data.stocks() + +highlight = alt.selection( + type='point', on='mouseover', + fields=['symbol'], nearest=True +) + +base = alt.Chart(source).encode( + x='date:T', + y='price:Q', + color='symbol:N' +) + +points = base.mark_circle().encode( + opacity=alt.value(0) +).add_params( + highlight +).properties( + width=600 +) + +lines = base.mark_line().encode( + size=alt.condition(~highlight, alt.value(1), alt.value(3)) +) + +points + lines diff --git a/altair/examples/attribute_syntax/multiline_tooltip.py b/altair/examples/attribute_syntax/multiline_tooltip.py new file mode 100644 index 000000000..4dfa8d2c0 --- /dev/null +++ b/altair/examples/attribute_syntax/multiline_tooltip.py @@ -0,0 +1,69 @@ +""" +Multi-Line Tooltip +================== +This example shows how you can use selections and layers to create a +tooltip-like behavior tied to the x position of the cursor. +If you are looking for more standard tooltips, it is recommended to use the +tooltip encoding channel as shown in the +`Scatter Plot With Tooltips `_ +example. + +The following example employs a little trick to isolate the x-position of the +cursor: we add some transparent points with only an x encoding (no y encoding) +and tie a *nearest* selection to these, tied to the "x" field. +""" +# category: interactive charts +import altair as alt +import pandas as pd +import numpy as np + +np.random.seed(42) +source = pd.DataFrame( + np.cumsum(np.random.randn(100, 3), 0).round(2), + columns=['A', 'B', 'C'], index=pd.RangeIndex(100, name='x') +) +source = source.reset_index().melt('x', var_name='category', value_name='y') + +# Create a selection that chooses the nearest point & selects based on x-value +nearest = alt.selection(type='point', nearest=True, on='mouseover', + fields=['x'], empty=False) + +# The basic line +line = alt.Chart(source).mark_line(interpolate='basis').encode( + x='x:Q', + y='y:Q', + color='category:N' +) + +# Transparent selectors across the chart. This is what tells us +# the x-value of the cursor +selectors = alt.Chart(source).mark_point().encode( + x='x:Q', + opacity=alt.value(0), +).add_params( + nearest +) + +# Draw points on the line, and highlight based on selection +points = line.mark_point().encode( + opacity=alt.condition(nearest, alt.value(1), alt.value(0)) +) + +# Draw text labels near the points, and highlight based on selection +text = line.mark_text(align='left', dx=5, dy=-5).encode( + text=alt.condition(nearest, 'y:Q', alt.value(' ')) +) + +# Draw a rule at the location of the selection +rules = alt.Chart(source).mark_rule(color='gray').encode( + x='x:Q', +).transform_filter( + nearest +) + +# Put the five layers into a chart and bind the data +alt.layer( + line, selectors, points, rules, text +).properties( + width=600, height=300 +) diff --git a/altair/examples/attribute_syntax/multiple_interactions.py b/altair/examples/attribute_syntax/multiple_interactions.py new file mode 100644 index 000000000..3f85ab5aa --- /dev/null +++ b/altair/examples/attribute_syntax/multiple_interactions.py @@ -0,0 +1,98 @@ +""" +Multiple Interactions +===================== +This example shows how multiple user inputs can be layered onto a chart. The four inputs have functionality as follows: + +* Dropdown: Filters the movies by genre +* Radio Buttons: Highlights certain films by Worldwide Gross +* Mouse Drag and Scroll: Zooms the x and y scales to allow for panning. + + + +""" +# category: interactive charts +import altair as alt +from vega_datasets import data + +movies = alt.UrlData( + data.movies.url, + format=alt.DataFormat(parse={"Release_Date":"date"}) +) +ratings = ['G', 'NC-17', 'PG', 'PG-13', 'R'] +genres = [ + 'Action', 'Adventure', 'Black Comedy', 'Comedy', + 'Concert/Performance', 'Documentary', 'Drama', 'Horror', 'Musical', + 'Romantic Comedy', 'Thriller/Suspense', 'Western' +] + +base = alt.Chart(movies, width=200, height=200).mark_point(filled=True).transform_calculate( + Rounded_IMDB_Rating = "floor(datum.IMDB_Rating)", + Hundred_Million_Production = "datum.Production_Budget > 100000000.0 ? 100 : 10", + Release_Year = "year(datum.Release_Date)" +).transform_filter( + alt.datum.IMDB_Rating > 0 +).transform_filter( + alt.FieldOneOfPredicate(field='MPAA_Rating', oneOf=ratings) +).encode( + x=alt.X('Worldwide_Gross:Q').scale(domain=(100000,10**9), clamp=True), + y='IMDB_Rating:Q', + tooltip="Title:N" +) + +# A slider filter +year_slider = alt.binding_range(min=1969, max=2018, step=1) +slider_selection = alt.selection_point( + bind=year_slider, + fields=['Release_Year'], + name="Release Year_" +) + + +filter_year = base.add_params( + slider_selection +).transform_filter( + slider_selection +).properties(title="Slider Filtering") + +# A dropdown filter +genre_dropdown = alt.binding_select(options=genres) +genre_select = alt.selection_point(fields=['Major_Genre'], bind=genre_dropdown, name="Genre") + +filter_genres = base.add_params( + genre_select +).transform_filter( + genre_select +).properties(title="Dropdown Filtering") + +#color changing marks +rating_radio = alt.binding_radio(options=ratings) + +rating_select = alt.selection_point(fields=['MPAA_Rating'], bind=rating_radio, name="Rating") +rating_color_condition = alt.condition( + rating_select, + alt.Color('MPAA_Rating:N').legend(None), + alt.value('lightgray') +) + +highlight_ratings = base.add_params( + rating_select +).encode( + color=rating_color_condition +).properties(title="Radio Button Highlighting") + +# Boolean selection for format changes +input_checkbox = alt.binding_checkbox() +checkbox_selection = alt.selection_point(bind=input_checkbox, name="Big Budget Films") + +size_checkbox_condition = alt.condition(checkbox_selection, + alt.SizeValue(25), + alt.Size('Hundred_Million_Production:Q') + ) + +budget_sizing = base.add_params( + checkbox_selection +).encode( + size=size_checkbox_condition +).properties(title="Checkbox Formatting") + +( filter_year | filter_genres) & (highlight_ratings | budget_sizing ) diff --git a/altair/examples/attribute_syntax/natural_disasters.py b/altair/examples/attribute_syntax/natural_disasters.py new file mode 100644 index 000000000..31b50a151 --- /dev/null +++ b/altair/examples/attribute_syntax/natural_disasters.py @@ -0,0 +1,52 @@ +""" +Global Deaths from Natural Disasters +------------------------------------ +This example shows a proportional symbols visualization of deaths from natural disasters by year and type. +""" +# category: case studies +import altair as alt +from vega_datasets import data + +source = data.disasters.url + +alt.Chart(source).transform_filter( + alt.datum.Entity != 'All natural disasters' +).mark_circle( + opacity=0.8, + stroke='black', + strokeWidth=1, + strokeOpacity=0.4 +).encode( + alt.X('Year:T') + .title(None) + .scale(domain=['1899','2018']), + alt.Y('Entity:N') + .title(None) + .sort(field="Deaths", op="sum", order='descending'), + alt.Size('Deaths:Q') + .scale(range=[0, 2500]) + .title('Deaths') + .legend(clipHeight=30, format='s'), + alt.Color('Entity:N').legend(None), + tooltip=[ + "Entity:N", + alt.Tooltip("Year:T", format='%Y'), + alt.Tooltip("Deaths:Q", format='~s') + ], +).properties( + width=450, + height=320, + title=alt.TitleParams( + text="Global Deaths from Natural Disasters (1900-2017)", + subtitle="The size of the bubble represents the total death count per year, by type of disaster", + anchor='start' + ) +).configure_axisY( + domain=False, + ticks=False, + offset=10 +).configure_axisX( + grid=False, +).configure_view( + stroke=None +) diff --git a/altair/examples/attribute_syntax/normalized_stacked_area_chart.py b/altair/examples/attribute_syntax/normalized_stacked_area_chart.py new file mode 100644 index 000000000..5973d7174 --- /dev/null +++ b/altair/examples/attribute_syntax/normalized_stacked_area_chart.py @@ -0,0 +1,16 @@ +""" +Normalized Stacked Area Chart +----------------------------- +This example shows how to make a normalized stacked area chart. +""" +# category: area charts +import altair as alt +from vega_datasets import data + +source = data.iowa_electricity() + +alt.Chart(source).mark_area().encode( + x="year:T", + y=alt.Y("net_generation:Q").stack("normalize"), + color="source:N" +) diff --git a/altair/examples/attribute_syntax/normalized_stacked_bar_chart.py b/altair/examples/attribute_syntax/normalized_stacked_bar_chart.py new file mode 100644 index 000000000..71e48b9a1 --- /dev/null +++ b/altair/examples/attribute_syntax/normalized_stacked_bar_chart.py @@ -0,0 +1,16 @@ +""" +Normalized Stacked Bar Chart +---------------------------- +This is an example of a normalized stacked bar chart using data which contains crop yields over different regions and different years in the 1930s. +""" +# category: bar charts +import altair as alt +from vega_datasets import data + +source = data.barley() + +alt.Chart(source).mark_bar().encode( + x=alt.X('sum(yield)').stack("normalize"), + y='variety', + color='site' +) diff --git a/altair/examples/attribute_syntax/parallel_coordinates.py b/altair/examples/attribute_syntax/parallel_coordinates.py new file mode 100644 index 000000000..f5d7cbd6e --- /dev/null +++ b/altair/examples/attribute_syntax/parallel_coordinates.py @@ -0,0 +1,28 @@ +""" +Parallel Coordinates +-------------------- +A `Parallel Coordinates `_ +chart is a chart that lets you visualize the individual data points by drawing +a single line for each of them. +Such a chart can be created in Altair by first transforming the data into a +suitable representation. +This example shows a parallel coordinates chart with the Iris dataset. +""" +# category: advanced calculations + +import altair as alt +from vega_datasets import data + +source = data.iris() + +alt.Chart(source, width=500).transform_window( + index='count()' +).transform_fold( + ['petalLength', 'petalWidth', 'sepalLength', 'sepalWidth'] +).mark_line().encode( + x='key:N', + y='value:Q', + color='species:N', + detail='index:N', + opacity=alt.value(0.5) +) diff --git a/altair/examples/attribute_syntax/percentage_of_total.py b/altair/examples/attribute_syntax/percentage_of_total.py new file mode 100644 index 000000000..addb9fd84 --- /dev/null +++ b/altair/examples/attribute_syntax/percentage_of_total.py @@ -0,0 +1,23 @@ +""" +Calculating Percentage of Total +------------------------------- +This chart demonstrates how to use a joinaggregate transform to display +data values as a percentage of total. +""" +# category: bar charts +import altair as alt +import pandas as pd + +source = pd.DataFrame({ + 'Activity': ['Sleeping', 'Eating', 'TV', 'Work', 'Exercise'], + 'Time': [8, 2, 4, 8, 2] +}) + +alt.Chart(source).transform_joinaggregate( + TotalTime='sum(Time)', +).transform_calculate( + PercentOfTotal="datum.Time / datum.TotalTime" +).mark_bar().encode( + alt.X('PercentOfTotal:Q').axis(format='.0%'), + y='Activity:N' +) diff --git a/altair/examples/attribute_syntax/pie_chart.py b/altair/examples/attribute_syntax/pie_chart.py new file mode 100644 index 000000000..afc7515cb --- /dev/null +++ b/altair/examples/attribute_syntax/pie_chart.py @@ -0,0 +1,18 @@ +""" +Pie Chart +--------- +This example shows how to make a Pie Chart using ``mark_arc``. +This is adapted from a corresponding Vega-Lite Example: +`Pie Chart `_. +""" +# category: circular plots + +import pandas as pd +import altair as alt + +source = pd.DataFrame({"category": [1, 2, 3, 4, 5, 6], "value": [4, 6, 10, 3, 7, 8]}) + +alt.Chart(source).mark_arc().encode( + theta="value", + color="category" +) diff --git a/altair/examples/attribute_syntax/pie_chart_with_labels.py b/altair/examples/attribute_syntax/pie_chart_with_labels.py new file mode 100644 index 000000000..d82860853 --- /dev/null +++ b/altair/examples/attribute_syntax/pie_chart_with_labels.py @@ -0,0 +1,25 @@ +""" +Pie Chart with Labels +--------------------- +This example shows how to layer text over arc marks (``mark_arc``) to label pie charts. +This is adapted from a corresponding Vega-Lite Example: +`Pie Chart with Labels `_. +""" +# category: circular plots + +import pandas as pd +import altair as alt + +source = pd.DataFrame( + {"category": ["a", "b", "c", "d", "e", "f"], "value": [4, 6, 10, 3, 7, 8]} +) + +base = alt.Chart(source).encode( + alt.Theta("value:Q").stack(True), + alt.Color("category:N").legend(None) +) + +pie = base.mark_arc(outerRadius=120) +text = base.mark_text(radius=140, size=20).encode(text="category:N") + +pie + text diff --git a/altair/examples/attribute_syntax/poly_fit_regression.py b/altair/examples/attribute_syntax/poly_fit_regression.py new file mode 100644 index 000000000..8842b9d98 --- /dev/null +++ b/altair/examples/attribute_syntax/poly_fit_regression.py @@ -0,0 +1,37 @@ +""" +Polynomial Fit Plot with Regression Transform +============================================= +This example shows how to overlay data with multiple fitted polynomials using +the regression transform. +""" +# category: uncertainties and trends + +import numpy as np +import pandas as pd +import altair as alt + +# Generate some random data +rng = np.random.RandomState(1) +x = rng.rand(40) ** 2 +y = 10 - 1.0 / (x + 0.1) + rng.randn(40) +source = pd.DataFrame({"x": x, "y": y}) + +# Define the degree of the polynomial fits +degree_list = [1, 3, 5] + +base = alt.Chart(source).mark_circle(color="black").encode( + alt.X("x"), + alt.Y("y") +) + +polynomial_fit = [ + base.transform_regression( + "x", "y", method="poly", order=order, as_=["x", str(order)] + ) + .mark_line() + .transform_fold([str(order)], as_=["degree", "y"]) + .encode(alt.Color("degree:N")) + for order in degree_list +] + +alt.layer(base, *polynomial_fit) diff --git a/altair/examples/attribute_syntax/pyramid.py b/altair/examples/attribute_syntax/pyramid.py new file mode 100644 index 000000000..82aa854d0 --- /dev/null +++ b/altair/examples/attribute_syntax/pyramid.py @@ -0,0 +1,23 @@ +""" +Pyramid Pie Chart +----------------- +Altair reproduction of http://robslink.com/SAS/democd91/pyramid_pie.htm +""" +# category: case studies +import altair as alt +import pandas as pd + +category = ['Sky', 'Shady side of a pyramid', 'Sunny side of a pyramid'] +color = ["#416D9D", "#674028", "#DEAC58"] +df = pd.DataFrame({'category': category, 'value': [75, 10, 15]}) + +alt.Chart(df, width=150, height=150).mark_arc(outerRadius=80).encode( + alt.Theta('value:Q').scale(range=[2.356, 8.639]), + alt.Color('category:N') + .title(None) + .scale(domain=category, range=color) + .legend(orient='none', legendX=160, legendY=50), + order='value:Q' +).configure_view( + strokeOpacity=0 +) diff --git a/altair/examples/attribute_syntax/radial_chart.py b/altair/examples/attribute_syntax/radial_chart.py new file mode 100644 index 000000000..1f844c945 --- /dev/null +++ b/altair/examples/attribute_syntax/radial_chart.py @@ -0,0 +1,25 @@ +""" +Radial Chart +------------ +This radial plot uses both angular and radial extent to convey multiple dimensions of data. +This is adapted from a corresponding Vega-Lite Example: +`Radial Plot `_. +""" +# category: circular plots + +import pandas as pd +import altair as alt + +source = pd.DataFrame({"values": [12, 23, 47, 6, 52, 19]}) + +base = alt.Chart(source).encode( + alt.Theta("values:Q").stack(True), + alt.Radius("values").scale(type="sqrt", zero=True, rangeMin=20), + color="values:N", +) + +c1 = base.mark_arc(innerRadius=20, stroke="#fff") + +c2 = base.mark_text(radiusOffset=10).encode(text="values:Q") + +c1 + c2 diff --git a/altair/examples/attribute_syntax/ranged_dot_plot.py b/altair/examples/attribute_syntax/ranged_dot_plot.py new file mode 100644 index 000000000..340eeed32 --- /dev/null +++ b/altair/examples/attribute_syntax/ranged_dot_plot.py @@ -0,0 +1,38 @@ +""" +Ranged Dot Plot +--------------- +This example shows a ranged dot plot to convey changing life expectancy for the five most populous countries (between 1955 and 2000). +""" +# category: advanced calculations +import altair as alt +from vega_datasets import data + +source = data.countries.url + +chart = alt.Chart( + data=source +).transform_filter( + filter={"field": 'country', + "oneOf": ["China", "India", "United States", "Indonesia", "Brazil"]} +).transform_filter( + filter={'field': 'year', + "oneOf": [1955, 2000]} +) + +line = chart.mark_line(color='#db646f').encode( + x='life_expect:Q', + y='country:N', + detail='country:N' +) +# Add points for life expectancy in 1955 & 2000 +points = chart.mark_point( + size=100, + opacity=1, + filled=True +).encode( + x='life_expect:Q', + y='country:N', + color=alt.Color('year:O').scale(domain=[1955, 2000], range=['#e6959c', '#911a24']) +).interactive() + +(line + points) diff --git a/altair/examples/attribute_syntax/ridgeline_plot.py b/altair/examples/attribute_syntax/ridgeline_plot.py new file mode 100644 index 000000000..a04d6c566 --- /dev/null +++ b/altair/examples/attribute_syntax/ridgeline_plot.py @@ -0,0 +1,59 @@ +""" +Ridgeline plot +-------------- +A `Ridgeline plot `_ +chart is a chart that lets you visualize distribution of a numeric value for +several groups. + +Such a chart can be created in Altair by first transforming the data into a +suitable representation. + +""" +# category: distributions +import altair as alt +from vega_datasets import data + +source = data.seattle_weather.url + +step = 20 +overlap = 1 + +alt.Chart(source, height=step).transform_timeunit( + Month='month(date)' +).transform_joinaggregate( + mean_temp='mean(temp_max)', groupby=['Month'] +).transform_bin( + ['bin_max', 'bin_min'], 'temp_max' +).transform_aggregate( + value='count()', groupby=['Month', 'mean_temp', 'bin_min', 'bin_max'] +).transform_impute( + impute='value', groupby=['Month', 'mean_temp'], key='bin_min', value=0 +).mark_area( + interpolate='monotone', + fillOpacity=0.8, + stroke='lightgray', + strokeWidth=0.5 +).encode( + alt.X('bin_min:Q') + .bin(True) + .title('Maximum Daily Temperature (C)'), + alt.Y('value:Q') + .axis(None) + .scale(range=[step, -step * overlap]), + alt.Fill('mean_temp:Q') + .legend(None) + .scale(domain=[30, 5], scheme='redyellowblue') +).facet( + alt.Row('Month:T') + .title(None) + .header(labelAngle=0, labelAlign='right', format='%B') +).properties( + title='Seattle Weather', + bounds='flush' +).configure_facet( + spacing=0 +).configure_view( + stroke=None +).configure_title( + anchor='end' +) diff --git a/altair/examples/attribute_syntax/scatter_linked_table.py b/altair/examples/attribute_syntax/scatter_linked_table.py new file mode 100644 index 000000000..a822d4ef3 --- /dev/null +++ b/altair/examples/attribute_syntax/scatter_linked_table.py @@ -0,0 +1,55 @@ +""" +Brushing Scatter Plot to Show Data on a Table +--------------------------------------------- +A scatter plot of the cars dataset, with data tables for horsepower, MPG, and origin. +The tables update to reflect the selection on the scatter plot. +""" +# category: scatter plots + +import altair as alt +from vega_datasets import data + +source = data.cars() + +# Brush for selection +brush = alt.selection_interval() + +# Scatter Plot +points = alt.Chart(source).mark_point().encode( + x='Horsepower:Q', + y='Miles_per_Gallon:Q', + color=alt.condition(brush, alt.value('steelblue'), alt.value('grey')) +).add_params(brush) + +# Base chart for data tables +ranked_text = alt.Chart(source).mark_text(align='right').encode( + y=alt.Y('row_number:O').axis(None) +).transform_filter( + brush +).transform_window( + row_number='row_number()' +).transform_filter( + 'datum.row_number < 15' +) + +# Data Tables +horsepower = ranked_text.encode(text='Horsepower:N').properties( + title=alt.TitleParams(text='Horsepower', align='right') +) +mpg = ranked_text.encode(text='Miles_per_Gallon:N').properties( + title=alt.TitleParams(text='MPG', align='right') +) +origin = ranked_text.encode(text='Origin:N').properties( + title=alt.TitleParams(text='Origin', align='right') +) +text = alt.hconcat(horsepower, mpg, origin) # Combine data tables + +# Build chart +alt.hconcat( + points, + text +).resolve_legend( + color="independent" +).configure_view( + stroke=None +) diff --git a/altair/examples/attribute_syntax/scatter_marginal_hist.py b/altair/examples/attribute_syntax/scatter_marginal_hist.py new file mode 100644 index 000000000..02ddc37fe --- /dev/null +++ b/altair/examples/attribute_syntax/scatter_marginal_hist.py @@ -0,0 +1,48 @@ +""" +Facetted Scatter Plot with Marginal Histograms +---------------------------------------------- +This example demonstrates how to generate a facetted scatter plot, +with marginal facetted histograms, and how to share their respective +- x,some y-limits. +""" +# category: distributions +import altair as alt +from vega_datasets import data + +source = data.iris() + +base = alt.Chart(source) + +xscale = alt.Scale(domain=(4.0, 8.0)) +yscale = alt.Scale(domain=(1.9, 4.55)) + +bar_args = {'opacity': .3, 'binSpacing': 0} + +points = base.mark_circle().encode( + alt.X('sepalLength').scale(xscale), + alt.Y('sepalWidth').scale(yscale), + color='species', +) + +top_hist = base.mark_bar(**bar_args).encode( + alt.X('sepalLength:Q') + # when using bins, the axis scale is set through + # the bin extent, so we do not specify the scale here + # (which would be ignored anyway) + .bin(maxbins=20, extent=xscale.domain) + .stack(None) + .title(''), + alt.Y('count()').stack(None).title(''), + alt.Color('species:N'), +).properties(height=60) + +right_hist = base.mark_bar(**bar_args).encode( + alt.Y('sepalWidth:Q') + .bin(maxbins=20, extent=yscale.domain) + .stack(None) + .title(''), + alt.X('count()').stack(None).title(''), + alt.Color('species:N'), +).properties(width=60) + +top_hist & (points | right_hist) diff --git a/altair/examples/attribute_syntax/scatter_with_layered_histogram.py b/altair/examples/attribute_syntax/scatter_with_layered_histogram.py new file mode 100644 index 000000000..995766ead --- /dev/null +++ b/altair/examples/attribute_syntax/scatter_with_layered_histogram.py @@ -0,0 +1,61 @@ +""" +Interactive Scatter Plot and Linked Layered Histogram +===================================================== + +This example shows how to link a scatter plot and a histogram +together such that clicking on a point in the scatter plot will +isolate the distribution corresponding to that point, and vice versa. +""" +# category: interactive charts + +import altair as alt +import pandas as pd +import numpy as np + +# generate fake data +source = pd.DataFrame({ + 'gender': ['M']*1000 + ['F']*1000, + 'height':np.concatenate(( + np.random.normal(69, 7, 1000), np.random.normal(64, 6, 1000) + )), + 'weight': np.concatenate(( + np.random.normal(195.8, 144, 1000), np.random.normal(167, 100, 1000) + )), + 'age': np.concatenate(( + np.random.normal(45, 8, 1000), np.random.normal(51, 6, 1000) + )) + }) + +selector = alt.selection_point(fields=['gender']) + +color_scale = alt.Scale(domain=['M', 'F'], + range=['#1FC3AA', '#8624F5']) + +base = alt.Chart(source).properties( + width=250, + height=250 +).add_params(selector) + +points = base.mark_point(filled=True, size=200).encode( + x=alt.X('mean(height):Q').scale(domain=[0,84]), + y=alt.Y('mean(weight):Q').scale(domain=[0,250]), + color=alt.condition( + selector, + 'gender:N', + alt.value('lightgray'), + scale=color_scale), +) + +hists = base.mark_bar(opacity=0.5, thickness=100).encode( + x=alt.X('age') + .bin(step=5) # step keeps bin size the same + .scale(domain=[0,100]), + y=alt.Y('count()') + .stack(None) + .scale(domain=[0,350]), + color=alt.Color('gender:N', scale=color_scale) +).transform_filter( + selector +) + +points | hists diff --git a/altair/examples/attribute_syntax/scatter_with_minimap.py b/altair/examples/attribute_syntax/scatter_with_minimap.py new file mode 100644 index 000000000..0ad0c634c --- /dev/null +++ b/altair/examples/attribute_syntax/scatter_with_minimap.py @@ -0,0 +1,44 @@ +""" +Scatter Plot with Minimap +------------------------- +This example shows how to create a miniature version of a plot +such that creating a selection in the miniature version +adjusts the axis limits in another, more detailed view. +""" +# category: scatter plots + +import altair as alt +from vega_datasets import data + +source = data.seattle_weather() + +zoom = alt.selection_interval(encodings=["x", "y"]) + +minimap = ( + alt.Chart(source) + .mark_point() + .add_params(zoom) + .encode( + x="date:T", + y="temp_max:Q", + color=alt.condition(zoom, "weather", alt.value("lightgray")), + ) + .properties( + width=200, + height=200, + title="Minimap -- click and drag to zoom in the detail view", + ) +) + +detail = ( + alt.Chart(source) + .mark_point() + .encode( + alt.X("date:T").scale(domain={"param": zoom.name, "encoding": "x"}), + alt.Y("temp_max:Q").scale(domain={"param": zoom.name, "encoding": "y"}), + color="weather", + ) + .properties(width=600, height=400, title="Seattle weather -- detail view") +) + +detail | minimap diff --git a/altair/examples/attribute_syntax/scatter_with_rolling_mean.py b/altair/examples/attribute_syntax/scatter_with_rolling_mean.py new file mode 100644 index 000000000..914e32e4e --- /dev/null +++ b/altair/examples/attribute_syntax/scatter_with_rolling_mean.py @@ -0,0 +1,30 @@ +""" +Scatter Plot with Rolling Mean +------------------------------ +A scatter plot with a rolling mean overlay. In this example a 30 day window +is used to calculate the mean of the maximum temperature around each date. +""" +# category: scatter plots + +import altair as alt +from vega_datasets import data + +source = data.seattle_weather() + +line = alt.Chart(source).mark_line( + color='red', + size=3 +).transform_window( + rolling_mean='mean(temp_max)', + frame=[-15, 15] +).encode( + x='date:T', + y='rolling_mean:Q' +) + +points = alt.Chart(source).mark_point().encode( + x='date:T', + y=alt.Y('temp_max:Q').title('Max Temp') +) + +points + line diff --git a/altair/examples/attribute_syntax/seattle_weather_interactive.py b/altair/examples/attribute_syntax/seattle_weather_interactive.py new file mode 100644 index 000000000..46b7448e4 --- /dev/null +++ b/altair/examples/attribute_syntax/seattle_weather_interactive.py @@ -0,0 +1,61 @@ +""" +Seattle Weather Interactive +=========================== +This chart provides an interactive exploration of Seattle weather over the +course of the year. It includes a one-axis brush selection to easily +see the distribution of weather types in a particular date range. +""" +# category: case studies +import altair as alt +from vega_datasets import data + +source = data.seattle_weather() + +scale = alt.Scale( + domain=['sun', 'fog', 'drizzle', 'rain', 'snow'], + range=['#e7ba52', '#a7a7a7', '#aec7e8', '#1f77b4', '#9467bd'] +) +color = alt.Color('weather:N', scale=scale) + +# We create two selections: +# - a brush that is active on the top panel +# - a multi-click that is active on the bottom panel +brush = alt.selection_interval(encodings=['x']) +click = alt.selection_point(encodings=['color']) + +# Top panel is scatter plot of temperature vs time +points = alt.Chart().mark_point().encode( + alt.X('monthdate(date):T').title('Date'), + alt.Y('temp_max:Q') + .title('Maximum Daily Temperature (C)') + .scale(domain=[-5, 40]), + alt.Size('precipitation:Q').scale(range=[5, 200]), + color=alt.condition(brush, color, alt.value('lightgray')), +).properties( + width=550, + height=300 +).add_params( + brush +).transform_filter( + click +) + +# Bottom panel is a bar chart of weather type +bars = alt.Chart().mark_bar().encode( + x='count()', + y='weather:N', + color=alt.condition(click, color, alt.value('lightgray')), +).transform_filter( + brush +).properties( + width=550, +).add_params( + click +) + +alt.vconcat( + points, + bars, + data=source, + title="Seattle Weather: 2012-2015" +) diff --git a/altair/examples/attribute_syntax/select_detail.py b/altair/examples/attribute_syntax/select_detail.py new file mode 100644 index 000000000..4dead24c5 --- /dev/null +++ b/altair/examples/attribute_syntax/select_detail.py @@ -0,0 +1,65 @@ +""" +Selection Detail +================ +This example shows a selection that links two views of data: the left panel +contains one point per object, and the right panel contains one line per +object. Clicking on either the points or lines will select the corresponding +objects in both views of the data. + +The challenge lies in expressing such hierarchical data in a way that Altair +can handle. We do this by merging the data into a "long form" dataframe, and +aggregating identical metadata for the final plot. +""" +# category: interactive charts +import altair as alt +import pandas as pd +import numpy as np + +np.random.seed(0) + +n_objects = 20 +n_times = 50 + +# Create one (x, y) pair of metadata per object +locations = pd.DataFrame({ + 'id': range(n_objects), + 'x': np.random.randn(n_objects), + 'y': np.random.randn(n_objects) +}) + +# Create a 50-element time-series for each object +timeseries = pd.DataFrame(np.random.randn(n_times, n_objects).cumsum(0), + columns=locations['id'], + index=pd.RangeIndex(0, n_times, name='time')) + +# Melt the wide-form timeseries into a long-form view +timeseries = timeseries.reset_index().melt('time') + +# Merge the (x, y) metadata into the long-form view +timeseries['id'] = timeseries['id'].astype(int) # make merge not complain +data = pd.merge(timeseries, locations, on='id') + +# Data is prepared, now make a chart + +selector = alt.selection_point(fields=['id']) + +base = alt.Chart(data).properties( + width=250, + height=250 +).add_params(selector) + +points = base.mark_point(filled=True, size=200).encode( + x='mean(x)', + y='mean(y)', + color=alt.condition(selector, 'id:O', alt.value('lightgray'), legend=None), +) + +timeseries = base.mark_line().encode( + x='time', + y=alt.Y('value').scale(domain=(-15, 15)), + color=alt.Color('id:O').legend(None) +).transform_filter( + selector +) + +points | timeseries diff --git a/altair/examples/attribute_syntax/simple_scatter_with_errorbars.py b/altair/examples/attribute_syntax/simple_scatter_with_errorbars.py new file mode 100644 index 000000000..434e6adca --- /dev/null +++ b/altair/examples/attribute_syntax/simple_scatter_with_errorbars.py @@ -0,0 +1,43 @@ +""" +Simple Scatter Plot with Errorbars +---------------------------------- +A simple scatter plot of a data set with errorbars. +""" +# category: uncertainties and trends +import altair as alt +import pandas as pd +import numpy as np + +# generate some data points with uncertainties +np.random.seed(0) +x = [1, 2, 3, 4, 5] +y = np.random.normal(10, 0.5, size=len(x)) +yerr = 0.2 + +# set up data frame +source = pd.DataFrame({"x": x, "y": y, "yerr": yerr}) + +# the base chart +base = alt.Chart(source).transform_calculate( + ymin="datum.y-datum.yerr", + ymax="datum.y+datum.yerr" +) + +# generate the points +points = base.mark_point( + filled=True, + size=50, + color='black' +).encode( + alt.X('x').scale(domain=(0, 6)), + alt.Y('y').scale(zero=False) +) + +# generate the error bars +errorbars = base.mark_errorbar().encode( + x="x", + y="ymin:Q", + y2="ymax:Q" +) + +points + errorbars diff --git a/altair/examples/attribute_syntax/sorted_error_bars_with_ci.py b/altair/examples/attribute_syntax/sorted_error_bars_with_ci.py new file mode 100644 index 000000000..ebda26a99 --- /dev/null +++ b/altair/examples/attribute_syntax/sorted_error_bars_with_ci.py @@ -0,0 +1,33 @@ +""" +Sorted Error Bars showing Confidence Interval +============================================= +This example shows how to show error bars using confidence intervals, while also sorting the y-axis based on x-axis values. +""" +# category: advanced calculations + +import altair as alt +from vega_datasets import data + +source = data.barley() + +points = alt.Chart(source).mark_point( + filled=True, + color='black' +).encode( + x=alt.X('mean(yield)').title('Barley Yield'), + y=alt.Y('variety').sort( + field='yield', + op='mean', + order='descending' + ) +).properties( + width=400, + height=250 +) + +error_bars = points.mark_rule().encode( + x='ci0(yield)', + x2='ci1(yield)', +) + +points + error_bars diff --git a/altair/examples/attribute_syntax/stacked_bar_chart_sorted_segments.py b/altair/examples/attribute_syntax/stacked_bar_chart_sorted_segments.py new file mode 100644 index 000000000..2a189fedd --- /dev/null +++ b/altair/examples/attribute_syntax/stacked_bar_chart_sorted_segments.py @@ -0,0 +1,21 @@ +""" +Stacked Bar Chart with Sorted Segments +-------------------------------------- +This is an example of a stacked-bar chart with the segments of each bar resorted. +""" +# category: bar charts +import altair as alt +from vega_datasets import data + +source = data.barley() + +alt.Chart(source).mark_bar().encode( + x='sum(yield)', + y='variety', + color='site', + order=alt.Order( + # Sort the segments of the bars by this field + 'site', + sort='ascending' + ) +) diff --git a/altair/examples/attribute_syntax/stacked_bar_chart_with_text.py b/altair/examples/attribute_syntax/stacked_bar_chart_with_text.py new file mode 100644 index 000000000..f2641e4e2 --- /dev/null +++ b/altair/examples/attribute_syntax/stacked_bar_chart_with_text.py @@ -0,0 +1,27 @@ +""" +Stacked Bar Chart with Text Overlay +=================================== +This example shows how to overlay text on a stacked bar chart. For both the +bar and text marks, we use the ``stack`` argument in the ``x`` encoding to +cause the values to be stacked horizontally. +""" +# category: bar charts +import altair as alt +from vega_datasets import data + +source=data.barley() + +bars = alt.Chart(source).mark_bar().encode( + x=alt.X('sum(yield):Q').stack('zero'), + y=alt.Y('variety:N'), + color=alt.Color('site') +) + +text = alt.Chart(source).mark_text(dx=-15, dy=3, color='white').encode( + x=alt.X('sum(yield):Q').stack('zero'), + y=alt.Y('variety:N'), + detail='site:N', + text=alt.Text('sum(yield):Q', format='.1f') +) + +bars + text diff --git a/altair/examples/attribute_syntax/stem_and_leaf.py b/altair/examples/attribute_syntax/stem_and_leaf.py new file mode 100644 index 000000000..9436d8eb2 --- /dev/null +++ b/altair/examples/attribute_syntax/stem_and_leaf.py @@ -0,0 +1,41 @@ +""" +Stem and Leaf Plot +------------------ +This example shows how to make a stem and leaf plot. +""" +# category: advanced calculations +import altair as alt +import pandas as pd +import numpy as np +np.random.seed(42) + +# Generating random data +source = pd.DataFrame({'samples': np.random.normal(50, 15, 100).astype(int).astype(str)}) + +# Splitting stem and leaf +source['stem'] = source['samples'].str[:-1] +source['leaf'] = source['samples'].str[-1] + +source = source.sort_values(by=['stem', 'leaf']) + +# Determining leaf position +source['position'] = source.groupby('stem').cumcount().add(1) + +# Creating stem and leaf plot +alt.Chart(source).mark_text( + align='left', + baseline='middle', + dx=-5 +).encode( + alt.X('position:Q') + .title('') + .axis(ticks=False, labels=False, grid=False), + alt.Y('stem:N') + .title('') + .axis(tickSize=0), + text='leaf:N', +).configure_axis( + labelFontSize=20 +).configure_text( + fontSize=20 +) diff --git a/altair/examples/attribute_syntax/streamgraph.py b/altair/examples/attribute_syntax/streamgraph.py new file mode 100644 index 000000000..b9bdcb512 --- /dev/null +++ b/altair/examples/attribute_syntax/streamgraph.py @@ -0,0 +1,16 @@ +""" +Streamgraph +----------------- +This example shows the streamgraph from vega-lite examples. +""" +# category: area charts +import altair as alt +from vega_datasets import data + +source = data.unemployment_across_industries.url + +alt.Chart(source).mark_area().encode( + alt.X('yearmonth(date):T').axis(format='%Y', domain=False, tickSize=0), + alt.Y('sum(count):Q').stack('center').axis(None), + alt.Color('series:N').scale(scheme='category20b') +).interactive() diff --git a/altair/examples/attribute_syntax/strip_plot_jitter.py b/altair/examples/attribute_syntax/strip_plot_jitter.py new file mode 100644 index 000000000..edf572b02 --- /dev/null +++ b/altair/examples/attribute_syntax/strip_plot_jitter.py @@ -0,0 +1,37 @@ +""" +Strip Plot with Jitter +---------------------- +In this chart, we encode the ``Major_Genre`` column from the ``movies`` dataset +in the ``y``-channel. In the default presentation of this data, it would be +difficult to gauge the relative frequencies with which different values occur +because there would be so much overlap. To address this, we use the ``yOffset`` +channel to incorporate a random offset (jittering). The example is shown twice, +on the left side using normally distributed and on the right side using +uniformally distributed jitter. +""" +# category: distributions +import altair as alt +from vega_datasets import data + +source = data.movies.url + +gaussian_jitter = alt.Chart(source, title='Normally distributed jitter').mark_circle(size=8).encode( + y="Major_Genre:N", + x="IMDB_Rating:Q", + yOffset="jitter:Q", + color=alt.Color('Major_Genre:N').legend(None) +).transform_calculate( + # Generate Gaussian jitter with a Box-Muller transform + jitter="sqrt(-2*log(random()))*cos(2*PI*random())" +) + +uniform_jitter = gaussian_jitter.transform_calculate( + # Generate uniform jitter + jitter='random()' +).encode( + alt.Y('Major_Genre:N').axis(None) +).properties( + title='Uniformly distributed jitter' +) + +(gaussian_jitter | uniform_jitter).resolve_scale(yOffset='independent') diff --git a/altair/examples/attribute_syntax/top_k_items.py b/altair/examples/attribute_syntax/top_k_items.py new file mode 100644 index 000000000..49285670e --- /dev/null +++ b/altair/examples/attribute_syntax/top_k_items.py @@ -0,0 +1,27 @@ +""" +Top K Items +----------- +This example shows how to use the window and transformation filter to display +the Top items of a long list of items in decreasing order. +Here we sort the top 10 highest ranking movies of IMDB. +""" +# category: advanced calculations +import altair as alt +from vega_datasets import data + +source = data.movies.url + +# Top 10 movies by IMBD rating +alt.Chart( + source, +).mark_bar().encode( + alt.X('Title:N').sort('-y'), + alt.Y('IMDB_Rating:Q'), + alt.Color('IMDB_Rating:Q') + +).transform_window( + rank='rank(IMDB_Rating)', + sort=[alt.SortField('IMDB_Rating', order='descending')] +).transform_filter( + (alt.datum.rank < 10) +) diff --git a/altair/examples/attribute_syntax/top_k_letters.py b/altair/examples/attribute_syntax/top_k_letters.py new file mode 100644 index 000000000..ac56b02a8 --- /dev/null +++ b/altair/examples/attribute_syntax/top_k_letters.py @@ -0,0 +1,40 @@ +""" +Top K Letters +------------- +This example shows how to use a window transform in order to display only the +top K categories by number of entries. In this case, we rank the characters in +the first paragraph of Dickens' *A Tale of Two Cities* by number of occurances. +""" +# category: advanced calculations +import altair as alt +import pandas as pd +import numpy as np + +# Excerpt from A Tale of Two Cities; public domain text +text = """ +It was the best of times, it was the worst of times, it was the age of wisdom, +it was the age of foolishness, it was the epoch of belief, it was the epoch of +incredulity, it was the season of Light, it was the season of Darkness, it was +the spring of hope, it was the winter of despair, we had everything before us, +we had nothing before us, we were all going direct to Heaven, we were all going +direct the other way - in short, the period was so far like the present period, +that some of its noisiest authorities insisted on its being received, for good +or for evil, in the superlative degree of comparison only. +""" + +source = pd.DataFrame( + {'letters': np.array([c for c in text if c.isalpha()])} +) + +alt.Chart(source).transform_aggregate( + count='count()', + groupby=['letters'] +).transform_window( + rank='rank(count)', + sort=[alt.SortField('count', order='descending')] +).transform_filter( + alt.datum.rank < 10 +).mark_bar().encode( + y=alt.Y('letters:N').sort('-x'), + x='count:Q', +) diff --git a/altair/examples/attribute_syntax/top_k_with_others.py b/altair/examples/attribute_syntax/top_k_with_others.py new file mode 100644 index 000000000..5a177e160 --- /dev/null +++ b/altair/examples/attribute_syntax/top_k_with_others.py @@ -0,0 +1,29 @@ +""" +Top-K Plot with Others +---------------------- +This example shows how to use aggregate, window, and calculate transfromations +to display the top-k directors by average worldwide gross while grouping the +remaining directors as 'All Others'. +""" +# category: advanced calculations +import altair as alt +from vega_datasets import data + +source = data.movies.url + +alt.Chart(source).mark_bar().encode( + alt.X("aggregate_gross:Q").aggregate("mean").title(None), + alt.Y("ranked_director:N") + .sort(op="mean", field="aggregate_gross", order="descending") + .title(None) +).transform_aggregate( + aggregate_gross='mean(Worldwide_Gross)', + groupby=["Director"], +).transform_window( + rank='row_number()', + sort=[alt.SortField("aggregate_gross", order="descending")], +).transform_calculate( + ranked_director="datum.rank < 10 ? datum.Director : 'All Others'" +).properties( + title="Top Directors by Average Worldwide Gross", +) diff --git a/altair/examples/attribute_syntax/trellis_area_sort_array.py b/altair/examples/attribute_syntax/trellis_area_sort_array.py new file mode 100644 index 000000000..2dab32fde --- /dev/null +++ b/altair/examples/attribute_syntax/trellis_area_sort_array.py @@ -0,0 +1,21 @@ +''' +Trellis Area Sort Chart +----------------------- +This example shows small multiples of an area chart. +Stock prices of four large companies +sorted by `['MSFT', 'AAPL', 'IBM', 'AMZN']` +''' +# category: area charts +import altair as alt +from vega_datasets import data + +source = data.stocks() + +alt.Chart(source).transform_filter( + alt.datum.symbol != 'GOOG' +).mark_area().encode( + x='date:T', + y='price:Q', + color='symbol:N', + row=alt.Row('symbol:N').sort(['MSFT', 'AAPL', 'IBM', 'AMZN']) +).properties(height=50, width=400) diff --git a/altair/examples/attribute_syntax/trellis_histogram.py b/altair/examples/attribute_syntax/trellis_histogram.py new file mode 100644 index 000000000..8c45ccf20 --- /dev/null +++ b/altair/examples/attribute_syntax/trellis_histogram.py @@ -0,0 +1,17 @@ +""" +Trellis Histogram +----------------- +This example shows how to make a basic trellis histogram. +https://vega.github.io/vega-lite/examples/trellis_bar_histogram.html +""" +# category: distributions +import altair as alt +from vega_datasets import data + +source = data.cars() + +alt.Chart(source).mark_bar().encode( + alt.X("Horsepower:Q").bin(), + y='count()', + row='Origin' +) diff --git a/altair/examples/attribute_syntax/us_employment.py b/altair/examples/attribute_syntax/us_employment.py new file mode 100644 index 000000000..2dada0833 --- /dev/null +++ b/altair/examples/attribute_syntax/us_employment.py @@ -0,0 +1,58 @@ +""" +The U.S. Employment Crash During the Great Recession +---------------------------------------------------- +This example is a fully developed bar chart with negative values using the sample dataset of U.S. employment changes during the Great Recession. +""" +# category: case studies +import altair as alt +import pandas as pd +from vega_datasets import data + +source = data.us_employment() +presidents = pd.DataFrame([ + { + "start": "2006-01-01", + "end": "2009-01-19", + "president": "Bush" + }, + { + "start": "2009-01-20", + "end": "2015-12-31", + "president": "Obama" + } +]) + +bars = alt.Chart( + source, + title="The U.S. employment crash during the Great Recession" +).mark_bar().encode( + alt.X("month:T").title(""), + alt.Y("nonfarm_change:Q").title("Change in non-farm employment (in thousands)"), + color=alt.condition( + alt.datum.nonfarm_change > 0, + alt.value("steelblue"), + alt.value("orange") + ) +) + +rule = alt.Chart(presidents).mark_rule( + color="black", + strokeWidth=2 +).encode( + x='end:T' +).transform_filter(alt.datum.president == "Bush") + +text = alt.Chart(presidents).mark_text( + align='left', + baseline='middle', + dx=7, + dy=-135, + size=11 +).encode( + x='start:T', + x2='end:T', + text='president', + color=alt.value('#000000') +) + +(bars + rule + text).properties(width=600) diff --git a/altair/examples/attribute_syntax/us_population_over_time.py b/altair/examples/attribute_syntax/us_population_over_time.py new file mode 100644 index 000000000..75c4fa01c --- /dev/null +++ b/altair/examples/attribute_syntax/us_population_over_time.py @@ -0,0 +1,39 @@ +""" +US Population by Age and Sex +============================ +This chart visualizes the age distribution of the US population over time. +It uses a slider widget that is bound to the year to visualize the age +distribution over time. +""" +# category: case studies +import altair as alt +from vega_datasets import data + +source = data.population.url + +select_year = alt.selection_point( + name="Year", + fields=["year"], + bind=alt.binding_range(min=1900, max=2000, step=10, name="Year"), + value={"year": 2000}, +) + +alt.Chart(source).mark_bar().encode( + alt.X("sex:N").title('').axis(labels=False, ticks=False), + alt.Y("people:Q").scale(domain=(0, 12000000)).title("Population"), + alt.Color("sex:N") + .scale(domain=("Male", "Female"), range=["steelblue", "salmon"]) + .title("Sex"), + alt.Column("age:O").title("Age") +).properties( + width=20, + title="U.S. Population by Age and Sex" +).add_params( + select_year +).transform_calculate( + "sex", alt.expr.if_(alt.datum.sex == 1, "Male", "Female") +).transform_filter( + select_year +).configure_facet( + spacing=8 +) diff --git a/altair/examples/attribute_syntax/us_population_over_time_facet.py b/altair/examples/attribute_syntax/us_population_over_time_facet.py new file mode 100644 index 000000000..6444e0d80 --- /dev/null +++ b/altair/examples/attribute_syntax/us_population_over_time_facet.py @@ -0,0 +1,21 @@ +""" +US Population: Wrapped Facet +============================ +This chart visualizes the age distribution of the US population over time, +using a wrapped faceting of the data by decade. +""" +# category: case studies +import altair as alt +from vega_datasets import data + +source = data.population.url + +alt.Chart(source).mark_area().encode( + x='age:O', + y=alt.Y('sum(people):Q').title('Population').axis(format='~s'), + facet=alt.Facet('year:O').columns(5), +).properties( + title='US Age Distribution By Year', + width=90, + height=80 +) diff --git a/altair/examples/attribute_syntax/us_population_pyramid_over_time.py b/altair/examples/attribute_syntax/us_population_pyramid_over_time.py new file mode 100644 index 000000000..f7418413d --- /dev/null +++ b/altair/examples/attribute_syntax/us_population_pyramid_over_time.py @@ -0,0 +1,57 @@ +''' +US Population Pyramid Over Time +=============================== +A population pyramid shows the distribution of age groups within a population. +It uses a slider widget that is bound to the year to visualize the age +distribution over time. +''' +# category: case studies +import altair as alt +from vega_datasets import data + +source = data.population.url + +slider = alt.binding_range(min=1850, max=2000, step=10) +select_year = alt.selection_point(name='year', fields=['year'], + bind=slider, value={'year': 2000}) + +base = alt.Chart(source).add_params( + select_year +).transform_filter( + select_year +).transform_calculate( + gender=alt.expr.if_(alt.datum.sex == 1, 'Male', 'Female') +).properties( + width=250 +) + + +color_scale = alt.Scale(domain=['Male', 'Female'], + range=['#1f77b4', '#e377c2']) + +left = base.transform_filter( + alt.datum.gender == 'Female' +).encode( + alt.Y('age:O').axis(None), + alt.X('sum(people):Q') + .title('population') + .sort('descending'), + alt.Color('gender:N') + .scale(color_scale) + .legend(None) +).mark_bar().properties(title='Female') + +middle = base.encode( + alt.Y('age:O').axis(None), + alt.Text('age:Q'), +).mark_text().properties(width=20) + +right = base.transform_filter( + alt.datum.gender == 'Male' +).encode( + alt.Y('age:O').axis(None), + alt.X('sum(people):Q').title('population'), + alt.Color('gender:N').scale(color_scale).legend(None) +).mark_bar().properties(title='Male') + +alt.concat(left, middle, right, spacing=5) diff --git a/altair/examples/attribute_syntax/us_state_capitals.py b/altair/examples/attribute_syntax/us_state_capitals.py new file mode 100644 index 000000000..00dfdaea6 --- /dev/null +++ b/altair/examples/attribute_syntax/us_state_capitals.py @@ -0,0 +1,43 @@ +""" +U.S. State Capitals Overlayed on a Map of the U.S +------------------------------------------------- +This is a layered geographic visualization that shows US capitals +overlayed on a map. +""" +# category: case studies +import altair as alt +from vega_datasets import data + +states = alt.topo_feature(data.us_10m.url, 'states') +capitals = data.us_state_capitals.url + +# US states background +background = alt.Chart(states).mark_geoshape( + fill='lightgray', + stroke='white' +).properties( + title='US State Capitols', + width=650, + height=400 +).project('albersUsa') + +# Points and text +hover = alt.selection(type='point', on='mouseover', nearest=True, + fields=['lat', 'lon']) + +base = alt.Chart(capitals).encode( + longitude='lon:Q', + latitude='lat:Q', +) + +text = base.mark_text(dy=-5, align='right').encode( + alt.Text('city:N'), + opacity=alt.condition(~hover, alt.value(0), alt.value(1)) +) + +points = base.mark_point().encode( + color=alt.value('black'), + size=alt.condition(~hover, alt.value(30), alt.value(100)) +).add_params(hover) + +background + points + text diff --git a/altair/examples/attribute_syntax/violin_plot.py b/altair/examples/attribute_syntax/violin_plot.py new file mode 100644 index 000000000..d09274d1e --- /dev/null +++ b/altair/examples/attribute_syntax/violin_plot.py @@ -0,0 +1,28 @@ +""" +Violin Plot +----------- +This example shows how to make a Violin Plot using Altair's density transform. +""" +# category: distributions +import altair as alt +from vega_datasets import data + +alt.Chart(data.cars(), width=100).transform_density( + 'Miles_per_Gallon', + as_=['Miles_per_Gallon', 'density'], + extent=[5, 50], + groupby=['Origin'] +).mark_area(orient='horizontal').encode( + alt.X('density:Q') + .stack('center') + .impute(None) + .title(None) + .axis(labels=False, values=[0], grid=False, ticks=True), + alt.Y('Miles_per_Gallon:Q'), + alt.Color('Origin:N'), + alt.Column('Origin:N') + .spacing(0) + .header(titleOrient='bottom', labelOrient='bottom', labelPadding=0) +).configure_view( + stroke=None +) diff --git a/altair/examples/attribute_syntax/wheat_wages.py b/altair/examples/attribute_syntax/wheat_wages.py new file mode 100644 index 000000000..81153712d --- /dev/null +++ b/altair/examples/attribute_syntax/wheat_wages.py @@ -0,0 +1,58 @@ +""" +Wheat and Wages +--------------- +A recreation of William Playfair's classic chart visualizing +the price of wheat, the wages of a mechanic, and the reigning British monarch. + +This is a more polished version of the simpler chart in :ref:`gallery_bar_and_line_with_dual_axis`. +""" +# category: case studies +import altair as alt +from vega_datasets import data + + +base_wheat = alt.Chart(data.wheat.url).transform_calculate( + year_end="+datum.year + 5") + +base_monarchs = alt.Chart(data.monarchs.url).transform_calculate( + offset="((!datum.commonwealth && datum.index % 2) ? -1: 1) * 2 + 95", + off2="((!datum.commonwealth && datum.index % 2) ? -1: 1) + 95", + y="95", + x="+datum.start + (+datum.end - +datum.start)/2" +) + +bars = base_wheat.mark_bar(**{"fill": "#aaa", "stroke": "#999"}).encode( + alt.X("year:Q").axis(format='d', tickCount=5), + alt.Y("wheat:Q").axis(zindex=1), + alt.X2("year_end") +) + +area = base_wheat.mark_area(**{"color": "#a4cedb", "opacity": 0.7}).encode( + alt.X("year:Q"), + alt.Y("wages:Q") +) + +area_line_1 = area.mark_line(**{"color": "#000", "opacity": 0.7}) +area_line_2 = area.mark_line(**{"yOffset": -2, "color": "#EE8182"}) + +top_bars = base_monarchs.mark_bar(stroke="#000").encode( + alt.X("start:Q"), + alt.X2("end"), + alt.Y("y:Q"), + alt.Y2("offset"), + alt.Fill("commonwealth:N").legend(None).scale(range=["black", "white"]) +) + +top_text = base_monarchs.mark_text(**{"yOffset": 14, "fontSize": 9, "fontStyle": "italic"}).encode( + alt.X("x:Q"), + alt.Y("off2:Q"), + alt.Text("name:N") +) + +(bars + area + area_line_1 + area_line_2 + top_bars + top_text).properties( + width=900, height=400 +).configure_axis( + title=None, gridColor="white", gridOpacity=0.25, domain=False +).configure_view( + stroke="transparent" +) diff --git a/altair/examples/attribute_syntax/wilkinson-dot-plot.py b/altair/examples/attribute_syntax/wilkinson-dot-plot.py new file mode 100644 index 000000000..55e31296c --- /dev/null +++ b/altair/examples/attribute_syntax/wilkinson-dot-plot.py @@ -0,0 +1,25 @@ +""" +Wilkinson Dot Plot +------------------ +An example of a `Wilkinson Dot Plot `_ +""" +# category: advanced calculations + +import altair as alt +import pandas as pd + +source = pd.DataFrame( + {"data":[1,1,1,1,1,1,1,1,1,1, + 2,2,2, + 3,3, + 4,4,4,4,4,4] + } +) + +alt.Chart(source, height=100).mark_circle(opacity=1).transform_window( + id='rank()', + groupby=['data'] +).encode( + alt.X('data:O'), + alt.Y('id:O').axis(None).sort('descending') +) diff --git a/altair/examples/attribute_syntax/wind_vector_map.py b/altair/examples/attribute_syntax/wind_vector_map.py new file mode 100644 index 000000000..56dcd674b --- /dev/null +++ b/altair/examples/attribute_syntax/wind_vector_map.py @@ -0,0 +1,57 @@ +""" +Wind Vector Map +--------------- +An example showing a vector array map showing wind speed and direction using ``wedge`` +as shape for ``mark_point`` and ``angle`` encoding for the wind direction. +This is adapted from this corresponding Vega-Lite Example: +`Wind Vector Map `_ +with an added base map. +""" +# category: maps +import altair as alt +from vega_datasets import data + +df_wind = data.windvectors() +data_world = alt.topo_feature(data.world_110m.url, "countries") + +wedge = alt.Chart(df_wind).mark_point(shape="wedge", filled=True).encode( + alt.Latitude("latitude"), + alt.Longitude("longitude"), + alt.Color("dir") + .scale(domain=[0, 360], scheme="rainbow") + .legend(None), + alt.Angle("dir").scale(domain=[0, 360], range=[180, 540]), + alt.Size("speed").scale(rangeMax=500) +).project("equalEarth") + +xmin, xmax, ymin, ymax = ( + df_wind.longitude.min(), + df_wind.longitude.max(), + df_wind.latitude.min(), + df_wind.latitude.max(), +) + +# clockwise, left-hand-rule +extent = [ + { + "type": "Polygon", + "coordinates": ( + ( + (xmax, ymax), + (xmax, ymin), + (xmin, ymin), + (xmin, ymax), + (xmax, ymax), + ), + ), + } +] + +# use fit combined with clip=True +base = ( + alt.Chart(data_world) + .mark_geoshape(clip=True, fill="lightgray", stroke="black", strokeWidth=0.5) + .project(type="equalEarth", fit=extent) +) + +base + wedge diff --git a/altair/examples/attribute_syntax/window_rank.py b/altair/examples/attribute_syntax/window_rank.py new file mode 100644 index 000000000..35796dffe --- /dev/null +++ b/altair/examples/attribute_syntax/window_rank.py @@ -0,0 +1,42 @@ +""" +Window Rank Line Chart +---------------------- +This example shows the Group F rankings in the 2018 World Cup after each matchday. +A window transformation is used to rank each after each match day, sorting by points and difference. +""" +# category: line charts +import altair as alt +import pandas as pd + +source = pd.DataFrame( + [ + {"team": "Germany", "matchday": 1, "point": 0, "diff": -1}, + {"team": "Germany", "matchday": 2, "point": 3, "diff": 0}, + {"team": "Germany", "matchday": 3, "point": 3, "diff": -2}, + {"team": "Mexico", "matchday": 1, "point": 3, "diff": 1}, + {"team": "Mexico", "matchday": 2, "point": 6, "diff": 2}, + {"team": "Mexico", "matchday": 3, "point": 6, "diff": -1}, + {"team": "South Korea", "matchday": 1, "point": 0, "diff": -1}, + {"team": "South Korea", "matchday": 2, "point": 0, "diff": -2}, + {"team": "South Korea", "matchday": 3, "point": 3, "diff": 0}, + {"team": "Sweden", "matchday": 1, "point": 3, "diff": 1}, + {"team": "Sweden", "matchday": 2, "point": 3, "diff": 0}, + {"team": "Sweden", "matchday": 3, "point": 6, "diff": 3}, + ] +) + +color_scale = alt.Scale( + domain=["Germany", "Mexico", "South Korea", "Sweden"], + range=["#000000", "#127153", "#C91A3C", "#0C71AB"], +) + +alt.Chart(source).mark_line().encode( + x="matchday:O", y="rank:O", color=alt.Color("team:N").scale(color_scale) +).transform_window( + rank="rank()", + sort=[ + alt.SortField("point", order="descending"), + alt.SortField("diff", order="descending"), + ], + groupby=["matchday"], +).properties(title="World Cup 2018: Group F Rankings") diff --git a/altair/examples/bar_chart_trellis_compact.py b/altair/examples/bar_chart_trellis_compact.py index 2cb0e4b7d..6fb011476 100644 --- a/altair/examples/bar_chart_trellis_compact.py +++ b/altair/examples/bar_chart_trellis_compact.py @@ -40,9 +40,11 @@ ) alt.Chart(source, width=60, height=alt.Step(8)).mark_bar().encode( - alt.Y("c:N").axis(None), - alt.X("p:Q").title(None).axis(format="%"), - alt.Color("c:N").title("settings").legend(orient="bottom", titleOrient="left"), - alt.Row("a:N").title("Factor A").header(labelAngle=0), - alt.Column("b:N").title("Factor B"), + y=alt.Y("c:N", axis=None), + x=alt.X("p:Q", title=None, axis=alt.Axis(format="%")), + color=alt.Color( + "c:N", title="settings", legend=alt.Legend(orient="bottom", titleOrient="left") + ), + row=alt.Row("a:N", title="Factor A", header=alt.Header(labelAngle=0)), + column=alt.Column("b:N", title="Factor B"), ) diff --git a/altair/examples/beckers_barley_trellis_plot.py b/altair/examples/beckers_barley_trellis_plot.py index 9f7c68867..4f780d963 100644 --- a/altair/examples/beckers_barley_trellis_plot.py +++ b/altair/examples/beckers_barley_trellis_plot.py @@ -10,19 +10,24 @@ source = data.barley() alt.Chart(source, title="The Morris Mistake").mark_point().encode( - alt.X('yield:Q') - .title("Barley Yield (bushels/acre)") - .scale(zero=False) - .axis(grid=False), - alt.Y('variety:N') - .title("") - .sort('-x') - .axis(grid=True), - alt.Color('year:N') - .legend(title="Year"), - alt.Row('site:N') - .title("") - .sort(alt.EncodingSortField(field='yield', op='sum', order='descending')) + alt.X( + 'yield:Q', + title="Barley Yield (bushels/acre)", + scale=alt.Scale(zero=False), + axis=alt.Axis(grid=False) + ), + alt.Y( + 'variety:N', + title="", + sort='-x', + axis=alt.Axis(grid=True) + ), + color=alt.Color('year:N', legend=alt.Legend(title="Year")), + row=alt.Row( + 'site:N', + title="", + sort=alt.EncodingSortField(field='yield', op='sum', order='descending'), + ) ).properties( height=alt.Step(20) ).configure_view(stroke="transparent") diff --git a/altair/examples/beckers_barley_wrapped_facet.py b/altair/examples/beckers_barley_wrapped_facet.py index 1b36dfbc0..b67af69d4 100644 --- a/altair/examples/beckers_barley_wrapped_facet.py +++ b/altair/examples/beckers_barley_wrapped_facet.py @@ -12,7 +12,7 @@ source = data.barley.url alt.Chart(source).mark_point().encode( - alt.X('median(yield):Q').scale(zero=False), + alt.X('median(yield):Q', scale=alt.Scale(zero=False)), y='variety:O', color='year:N', facet=alt.Facet('site:O', columns=2), diff --git a/altair/examples/bump_chart.py b/altair/examples/bump_chart.py index 03f88c8ac..1586b956e 100644 --- a/altair/examples/bump_chart.py +++ b/altair/examples/bump_chart.py @@ -14,8 +14,8 @@ stocks = data.stocks() source = stocks.groupby([pd.Grouper(key="date", freq="6M"),"symbol"]).mean().reset_index() -alt.Chart(source).mark_line(point=True).encode( - x=alt.X("date:O").timeUnit("yearmonth").title("date"), +alt.Chart(source).mark_line(point = True).encode( + x = alt.X("date:O", timeUnit="yearmonth", title="date"), y="rank:O", color=alt.Color("symbol:N") ).transform_window( @@ -26,4 +26,4 @@ title="Bump Chart for Stock Prices", width=600, height=150, -) +) \ No newline at end of file diff --git a/altair/examples/candlestick_chart.py b/altair/examples/candlestick_chart.py index 47e713abb..23b338b8e 100644 --- a/altair/examples/candlestick_chart.py +++ b/altair/examples/candlestick_chart.py @@ -12,23 +12,27 @@ source = data.ohlc() -open_close_color = alt.condition( - "datum.open <= datum.close", - alt.value("#06982d"), - alt.value("#ae1325") -) +open_close_color = alt.condition("datum.open <= datum.close", + alt.value("#06982d"), + alt.value("#ae1325")) base = alt.Chart(source).encode( - alt.X('date:T') - .axis(format='%m/%d', labelAngle=-45) - .title('Date in 2009'), + alt.X('date:T', + axis=alt.Axis( + format='%m/%d', + labelAngle=-45, + title='Date in 2009' + ) + ), color=open_close_color ) rule = base.mark_rule().encode( - alt.Y('low:Q') - .title('Price') - .scale(zero=False), + alt.Y( + 'low:Q', + title='Price', + scale=alt.Scale(zero=False), + ), alt.Y2('high:Q') ) @@ -37,4 +41,4 @@ alt.Y2('close:Q') ) -rule + bar +rule + bar \ No newline at end of file diff --git a/altair/examples/co2_concentration.py b/altair/examples/co2_concentration.py index e82f830d6..cd53d4ed7 100644 --- a/altair/examples/co2_concentration.py +++ b/altair/examples/co2_concentration.py @@ -27,24 +27,25 @@ groupby=['decade'], frame=[None, None] ).transform_calculate( - end=( - "datum.first_date === datum.scaled_date ? 'first'" - ": datum.last_date === datum.scaled_date ? 'last'" - ": null" - ) + end="datum.first_date === datum.scaled_date ? 'first' : datum.last_date === datum.scaled_date ? 'last' : null" ).encode( - alt.X("scaled_date:Q") - .title("Year into Decade") - .axis(tickCount=11), - alt.Y("CO2:Q") - .title("CO2 concentration in ppm") - .scale(zero=False) + x=alt.X( + "scaled_date:Q", + axis=alt.Axis(title="Year into Decade", tickCount=11) + ), + y=alt.Y( + "CO2:Q", + title="CO2 concentration in ppm", + scale=alt.Scale(zero=False) + ) ) line = base.mark_line().encode( - alt.Color("decade:O") - .scale(scheme="magma") - .legend(None) + color=alt.Color( + "decade:O", + scale=alt.Scale(scheme="magma"), + legend=None + ) ) text = base.encode(text="year:N") diff --git a/altair/examples/comet_chart.py b/altair/examples/comet_chart.py index b8edff751..32dd9392c 100644 --- a/altair/examples/comet_chart.py +++ b/altair/examples/comet_chart.py @@ -11,34 +11,22 @@ import altair as alt import vega_datasets -alt.Chart( - vega_datasets.data.barley.url, - title='Barley Yield comparison between 1932 and 1931' -).mark_trail().encode( - alt.X('year:O').title(None), - alt.Y('variety:N').title('Variety'), - alt.Size('yield:Q') - .scale(range=[0, 12]) - .legend(values=[20, 60]) - .title('Barley Yield (bushels/acre)'), - alt.Color('delta:Q') - .scale(domainMid=0) - .title('Yield Delta (%)'), - alt.Tooltip(['year:O', 'yield:Q']), - alt.Column('site:N').title('Site') -).transform_pivot( - "year", - value="yield", - groupby=["variety", "site"] -).transform_fold( - ["1931", "1932"], - as_=["year", "yield"] -).transform_calculate( - calculate="datum['1932'] - datum['1931']", - as_="delta" -).configure_legend( - orient='bottom', - direction='horizontal' -).configure_view( - stroke=None +( + alt.Chart(vega_datasets.data.barley.url) + .transform_pivot("year", value="yield", groupby=["variety", "site"]) + .transform_fold(["1931", "1932"], as_=["year", "yield"]) + .transform_calculate(calculate="datum['1932'] - datum['1931']", as_="delta") + .mark_trail() + .encode( + x=alt.X('year:O', title=None), + y=alt.Y('variety:N', title='Variety'), + size=alt.Size('yield:Q', scale=alt.Scale(range=[0, 12]), legend=alt.Legend(values=[20, 60], title='Barley Yield (bushels/acre)')), + color=alt.Color('delta:Q', scale=alt.Scale(domainMid=0), legend=alt.Legend(title='Yield Delta (%)')), + tooltip=alt.Tooltip(['year:O', 'yield:Q']), + column=alt.Column('site:N', title='Site') + + ) + .configure_view(stroke=None) + .configure_legend(orient='bottom', direction='horizontal') + .properties(title='Barley Yield comparison between 1932 and 1931') ) diff --git a/altair/examples/connected_scatterplot.py b/altair/examples/connected_scatterplot.py index a5902841c..8528fb86f 100644 --- a/altair/examples/connected_scatterplot.py +++ b/altair/examples/connected_scatterplot.py @@ -12,7 +12,7 @@ source = data.driving() alt.Chart(source).mark_line(point=True).encode( - alt.X('miles').scale(zero=False), - alt.Y('gas').scale(zero=False), + alt.X('miles', scale=alt.Scale(zero=False)), + alt.Y('gas', scale=alt.Scale(zero=False)), order='year' ) diff --git a/altair/examples/dendrogram.py b/altair/examples/dendrogram.py new file mode 100644 index 000000000..bd35ddaca --- /dev/null +++ b/altair/examples/dendrogram.py @@ -0,0 +1,143 @@ +""" +Dendrogram of Hierarchical Clustering +------------------------------------- +This is a dendrogram from the result of a hierarchical clustering. It's based on the example from +https://scikit-learn.org/stable/auto_examples/cluster/plot_agglomerative_dendrogram.html +""" +# category: case studies + +import pandas as pd +import altair as alt +import numpy as np + +# the variable `den` shown below is an exemplary output of `scipy.cluster.hierarchy.dendrogram` +# (https://docs.scipy.org/doc/scipy/reference/generated/scipy.cluster.hierarchy.dendrogram.html#scipy.cluster.hierarchy.dendrogram) +# where the dendrogram itself is truncated such that no more than 3 levels of the dendrogram tree are shown. +den = { + 'dcoord': [[0.0, 0.8187388676087964, 0.8187388676087964, 0.0], + [0.0, 1.105139508538779, 1.105139508538779, 0.0], + [0.8187388676087964, + 1.3712698320830048, + 1.3712698320830048, + 1.105139508538779], + [0.0, 0.9099819926189507, 0.9099819926189507, 0.0], + [0.0, 1.2539936203984452, 1.2539936203984452, 0.0], + [0.9099819926189507, + 1.9187528699821954, + 1.9187528699821954, + 1.2539936203984452], + [1.3712698320830048, + 3.828052620290243, + 3.828052620290243, + 1.9187528699821954], + [0.0, 1.7604450194955439, 1.7604450194955439, 0.0], + [0.0, 1.845844754344974, 1.845844754344974, 0.0], + [1.7604450194955439, + 4.847708507921838, + 4.847708507921838, + 1.845844754344974], + [0.0, 2.8139388316471536, 2.8139388316471536, 0.0], + [0.0, 2.8694176394568705, 2.8694176394568705, 0.0], + [2.8139388316471536, + 6.399406819518539, + 6.399406819518539, + 2.8694176394568705], + [4.847708507921838, + 12.300396052792589, + 12.300396052792589, + 6.399406819518539], + [3.828052620290243, + 32.44760699959244, + 32.44760699959244, + 12.300396052792589]], + 'icoord': [[5.0, 5.0, 15.0, 15.0], + [25.0, 25.0, 35.0, 35.0], + [10.0, 10.0, 30.0, 30.0], + [45.0, 45.0, 55.0, 55.0], + [65.0, 65.0, 75.0, 75.0], + [50.0, 50.0, 70.0, 70.0], + [20.0, 20.0, 60.0, 60.0], + [85.0, 85.0, 95.0, 95.0], + [105.0, 105.0, 115.0, 115.0], + [90.0, 90.0, 110.0, 110.0], + [125.0, 125.0, 135.0, 135.0], + [145.0, 145.0, 155.0, 155.0], + [130.0, 130.0, 150.0, 150.0], + [100.0, 100.0, 140.0, 140.0], + [40.0, 40.0, 120.0, 120.0]], + 'ivl': [ + '(7)', '(8)', '41', '(5)', '(10)', '(7)', '(4)', '(8)', '(9)', '(15)', '(5)', '(7)', '(4)', '(22)', '(15)', '(23)' + ], +} + +def get_leaf_loc(den): + """ + Get the location of the leaves + """ + _from = int(np.array(den["icoord"]).min()) + _to = int(np.array(den["icoord"]).max() + 1) + return range(_from, _to, 10) + +def get_df_coord(den): + """ + Get coordinate dataframe. + """ + # if you view the dendrogram as a collection of upside-down "U" shapes, then + # we can regard the 4 corners of the upside-down "U" as points 1, 2, 3 and 4. + cols_xk = ["xk1", "xk2", "xk3", "xk4"] + cols_yk = ["yk1", "yk2", "yk3", "yk4"] + + df_coord = pd.merge( + pd.DataFrame(den["icoord"], columns=cols_xk), + pd.DataFrame(den["dcoord"], columns=cols_yk), + left_index=True, + right_index=True + ) + return df_coord + +source = get_df_coord(den) +base = alt.Chart(source) + +# the U shape is composed of a shoulder plus two arms +shoulder = base.mark_rule().encode( + alt.X("xk2:Q", title=""), + alt.X2("xk3:Q"), + alt.Y("yk2:Q", title="") +) +arm1 = base.mark_rule().encode( + alt.X("xk1:Q"), + alt.Y("yk1:Q"), + alt.Y2("yk2:Q") +) +arm2 = base.mark_rule().encode( + alt.X("xk3:Q"), + alt.Y("yk3:Q"), + alt.Y2("yk4:Q") +) + +chart_den = shoulder + arm1 + arm2 + +df_text = pd.DataFrame(dict(labels=den["ivl"], x=get_leaf_loc(den))) + +chart_text = alt.Chart( + df_text +).mark_text( + dy=0, angle=0, align="center" +).encode( + x = alt.X("x:Q", axis={"grid":False, "title":"Number of points in nodes"}), + text = alt.Text("labels:N") +) + +(chart_den & chart_text).resolve_scale( + x="shared" +).configure( + padding={"top":10,"left":10} +).configure_concat( + spacing=0 +).configure_axis( + labels=False, + ticks=False, + grid=False +).properties( + title="Hierarchical Clustering Dendrogram" +) \ No newline at end of file diff --git a/altair/examples/density_stack.py b/altair/examples/density_stack.py index 56b0161f1..e408e308d 100644 --- a/altair/examples/density_stack.py +++ b/altair/examples/density_stack.py @@ -30,6 +30,6 @@ steps=200 ).mark_area().encode( alt.X('value:Q'), - alt.Y('density:Q').stack('zero'), + alt.Y('density:Q', stack='zero'), alt.Color('Measurement_type:N') ).properties(width=400, height=100) diff --git a/altair/examples/diverging_stacked_bar_chart.py b/altair/examples/diverging_stacked_bar_chart.py index 19ddc1d13..cb2c21832 100644 --- a/altair/examples/diverging_stacked_bar_chart.py +++ b/altair/examples/diverging_stacked_bar_chart.py @@ -358,6 +358,10 @@ alt.Chart(source).mark_bar().encode( x='percentage_start:Q', x2='percentage_end:Q', - y=alt.Y('question:N').axis(y_axis), - color=alt.Color('type:N').title('Response').scale(color_scale), + y=alt.Y('question:N', axis=y_axis), + color=alt.Color( + 'type:N', + legend=alt.Legend( title='Response'), + scale=color_scale, + ) ) diff --git a/altair/examples/donut_chart.py b/altair/examples/donut_chart.py index a734825da..32498a56d 100644 --- a/altair/examples/donut_chart.py +++ b/altair/examples/donut_chart.py @@ -10,12 +10,9 @@ import pandas as pd import altair as alt -source = pd.DataFrame({ - "category": [1, 2, 3, 4, 5, 6], - "value": [4, 6, 10, 3, 7, 8] -}) +source = pd.DataFrame({"category": [1, 2, 3, 4, 5, 6], "value": [4, 6, 10, 3, 7, 8]}) alt.Chart(source).mark_arc(innerRadius=50).encode( - theta="value", - color="category:N", + theta=alt.Theta(field="value", type="quantitative"), + color=alt.Color(field="category", type="nominal"), ) diff --git a/altair/examples/dot_dash_plot.py b/altair/examples/dot_dash_plot.py index 58ade5962..52f805adc 100644 --- a/altair/examples/dot_dash_plot.py +++ b/altair/examples/dot_dash_plot.py @@ -16,8 +16,8 @@ # Configure the points points = base.mark_point().encode( - alt.X('Miles_per_Gallon').title(''), - alt.Y('Horsepower').title(''), + x=alt.X('Miles_per_Gallon', title=''), + y=alt.Y('Horsepower', title=''), color=alt.condition(brush, 'Origin', alt.value('grey')) ) @@ -25,14 +25,14 @@ tick_axis = alt.Axis(labels=False, domain=False, ticks=False) x_ticks = base.mark_tick().encode( - alt.X('Miles_per_Gallon').axis(tick_axis), - alt.Y('Origin').title('').axis(tick_axis), + alt.X('Miles_per_Gallon', axis=tick_axis), + alt.Y('Origin', title='', axis=tick_axis), color=alt.condition(brush, 'Origin', alt.value('lightgrey')) ) y_ticks = base.mark_tick().encode( - alt.X('Origin').title('').axis(tick_axis), - alt.Y('Horsepower').axis(tick_axis), + alt.X('Origin', title='', axis=tick_axis), + alt.Y('Horsepower', axis=tick_axis), color=alt.condition(brush, 'Origin', alt.value('lightgrey')) ) diff --git a/altair/examples/errorbars_with_ci.py b/altair/examples/errorbars_with_ci.py index af950a45e..55c706ecc 100644 --- a/altair/examples/errorbars_with_ci.py +++ b/altair/examples/errorbars_with_ci.py @@ -12,13 +12,13 @@ source = data.barley() error_bars = alt.Chart(source).mark_errorbar(extent='ci').encode( - alt.X('yield').scale(zero=False), - alt.Y('variety') + x=alt.X('yield:Q', scale=alt.Scale(zero=False)), + y=alt.Y('variety:N') ) points = alt.Chart(source).mark_point(filled=True, color='black').encode( - x=alt.X('mean(yield)'), - y=alt.Y('variety'), + x=alt.X('yield:Q', aggregate='mean'), + y=alt.Y('variety:N'), ) error_bars + points diff --git a/altair/examples/errorbars_with_std.py b/altair/examples/errorbars_with_std.py index d20c154b9..167bc7283 100644 --- a/altair/examples/errorbars_with_std.py +++ b/altair/examples/errorbars_with_std.py @@ -11,13 +11,13 @@ source = data.barley() error_bars = alt.Chart(source).mark_errorbar(extent='stdev').encode( - x=alt.X('yield').scale(zero=False), - y=alt.Y('variety') + x=alt.X('yield:Q', scale=alt.Scale(zero=False)), + y=alt.Y('variety:N') ) points = alt.Chart(source).mark_point(filled=True, color='black').encode( - x=alt.X('mean(yield)'), - y=alt.Y('variety'), + x=alt.X('yield:Q', aggregate='mean'), + y=alt.Y('variety:N'), ) error_bars + points diff --git a/altair/examples/falkensee.py b/altair/examples/falkensee.py index b5d01b86e..463e70ada 100644 --- a/altair/examples/falkensee.py +++ b/altair/examples/falkensee.py @@ -58,8 +58,8 @@ line = alt.Chart(source).mark_line(color="#333").encode( - alt.X("year:T").axis(format="%Y").title("Year"), - alt.Y("population").title("Population"), + x=alt.X("year:T", axis=alt.Axis(format="%Y"), title="Year"), + y=alt.Y("population", title="Population"), ) point = line.mark_point(color="#333") @@ -67,7 +67,7 @@ rect = alt.Chart(source2).mark_rect().encode( x="start:T", x2="end:T", - color=alt.Color("event:N").title("Event") + color=alt.Color("event:N", title="Event") ) (rect + line + point).properties( diff --git a/altair/examples/gapminder_bubble_plot.py b/altair/examples/gapminder_bubble_plot.py index 839212885..381f81017 100644 --- a/altair/examples/gapminder_bubble_plot.py +++ b/altair/examples/gapminder_bubble_plot.py @@ -12,7 +12,7 @@ source = data.gapminder_health_income.url alt.Chart(source).mark_circle().encode( - alt.X('income:Q').scale(type='log'), - alt.Y('health:Q').scale(zero=False), + alt.X('income:Q', scale=alt.Scale(type='log')), + alt.Y('health:Q', scale=alt.Scale(zero=False)), size='population:Q' ) diff --git a/altair/examples/groupby-map.py b/altair/examples/groupby-map.py index 20f0817e6..adb4e0256 100644 --- a/altair/examples/groupby-map.py +++ b/altair/examples/groupby-map.py @@ -20,7 +20,7 @@ ).project('albersUsa') # Airports grouped by state -points = alt.Chart(airports, title='Number of airports in US').transform_aggregate( +points = alt.Chart(airports).transform_aggregate( latitude='mean(latitude)', longitude='mean(longitude)', count='count()', @@ -28,9 +28,11 @@ ).mark_circle().encode( longitude='longitude:Q', latitude='latitude:Q', - size=alt.Size('count:Q').title('Number of Airports'), + size=alt.Size('count:Q', title='Number of Airports'), color=alt.value('steelblue'), tooltip=['state:N','count:Q'] +).properties( + title='Number of airports in US' ) background + points diff --git a/altair/examples/grouped_bar_chart2.py b/altair/examples/grouped_bar_chart2.py index 671f83e44..74e955113 100644 --- a/altair/examples/grouped_bar_chart2.py +++ b/altair/examples/grouped_bar_chart2.py @@ -8,11 +8,9 @@ import altair as alt import pandas as pd -source = pd.DataFrame({ - "Category":list("AAABBBCCC"), - "Group":list("xyzxyzxyz"), - "Value":[0.1, 0.6, 0.9, 0.7, 0.2, 1.1, 0.6, 0.1, 0.2] -}) +source = pd.DataFrame({"Category":list("AAABBBCCC"), + "Group":list("xyzxyzxyz"), + "Value":[0.1, 0.6, 0.9, 0.7, 0.2, 1.1, 0.6, 0.1, 0.2]}) alt.Chart(source).mark_bar().encode( x="Category:N", diff --git a/altair/examples/grouped_bar_chart_with_error_bars.py b/altair/examples/grouped_bar_chart_with_error_bars.py index 4ef796f12..c1eab965d 100644 --- a/altair/examples/grouped_bar_chart_with_error_bars.py +++ b/altair/examples/grouped_bar_chart_with_error_bars.py @@ -11,7 +11,7 @@ bars = alt.Chart().mark_bar().encode( x='year:O', - y=alt.Y('mean(yield):Q').title('Mean Yield'), + y=alt.Y('mean(yield):Q', title='Mean Yield'), color='year:N', ) diff --git a/altair/examples/hexbins.py b/altair/examples/hexbins.py index 26f3890a0..a8d91ac74 100644 --- a/altair/examples/hexbins.py +++ b/altair/examples/hexbins.py @@ -24,15 +24,13 @@ hexagon = "M0,-2.3094010768L2,-1.1547005384 2,1.1547005384 0,2.3094010768 -2,1.1547005384 -2,-1.1547005384Z" alt.Chart(source).mark_point(size=size**2, shape=hexagon).encode( - alt.X('xFeaturePos:Q') - .title('Month') - .axis(grid=False, tickOpacity=0, domainOpacity=0), - alt.Y('day(' + yField + '):O') - .title('Weekday') - .axis(labelPadding=20, tickOpacity=0, domainOpacity=0), + x=alt.X('xFeaturePos:Q', axis=alt.Axis(title='Month', + grid=False, tickOpacity=0, domainOpacity=0)), + y=alt.Y('day(' + yField + '):O', axis=alt.Axis(title='Weekday', + labelPadding=20, tickOpacity=0, domainOpacity=0)), stroke=alt.value('black'), strokeWidth=alt.value(0.2), - fill=alt.Color('mean(temp_max):Q').scale(scheme='darkblue'), + fill=alt.Color('mean(temp_max):Q', scale=alt.Scale(scheme='darkblue')), tooltip=['month(' + xField + '):O', 'day(' + yField + '):O', 'mean(temp_max):Q'] ).transform_calculate( # This field is required for the hexagonal X-Offset diff --git a/altair/examples/histogram_heatmap.py b/altair/examples/histogram_heatmap.py index c697d1dd7..e284449f3 100644 --- a/altair/examples/histogram_heatmap.py +++ b/altair/examples/histogram_heatmap.py @@ -10,7 +10,7 @@ source = data.movies.url alt.Chart(source).mark_rect().encode( - alt.X('IMDB_Rating:Q').bin(maxbins=60), - alt.Y('Rotten_Tomatoes_Rating:Q').bin(maxbins=40), - alt.Color('count():Q').scale(scheme='greenblue') + alt.X('IMDB_Rating:Q', bin=alt.Bin(maxbins=60)), + alt.Y('Rotten_Tomatoes_Rating:Q', bin=alt.Bin(maxbins=40)), + alt.Color('count():Q', scale=alt.Scale(scheme='greenblue')) ) diff --git a/altair/examples/histogram_responsive.py b/altair/examples/histogram_responsive.py index e8ce16cb6..8e3cfdc48 100644 --- a/altair/examples/histogram_responsive.py +++ b/altair/examples/histogram_responsive.py @@ -24,11 +24,12 @@ alt.vconcat( base.encode( - alt.X('time:Q') - .bin(maxbins=30, extent=brush) - .scale(domain=brush) + alt.X('time:Q', + bin=alt.Bin(maxbins=30, extent=brush), + scale=alt.Scale(domain=brush) + ) ), base.encode( - alt.X('time:Q').bin(maxbins=30), + alt.X('time:Q', bin=alt.Bin(maxbins=30)), ).add_params(brush) ) diff --git a/altair/examples/histogram_scatterplot.py b/altair/examples/histogram_scatterplot.py index 6286b615e..482eee760 100644 --- a/altair/examples/histogram_scatterplot.py +++ b/altair/examples/histogram_scatterplot.py @@ -10,7 +10,7 @@ source = data.movies.url alt.Chart(source).mark_circle().encode( - alt.X('IMDB_Rating:Q').bin(), - alt.Y('Rotten_Tomatoes_Rating:Q').bin(), + alt.X('IMDB_Rating:Q', bin=True), + alt.Y('Rotten_Tomatoes_Rating:Q', bin=True), size='count()' ) diff --git a/altair/examples/histogram_with_a_global_mean_overlay.py b/altair/examples/histogram_with_a_global_mean_overlay.py index bcb91a216..f2cc9a390 100644 --- a/altair/examples/histogram_with_a_global_mean_overlay.py +++ b/altair/examples/histogram_with_a_global_mean_overlay.py @@ -12,7 +12,7 @@ base = alt.Chart(source) bar = base.mark_bar().encode( - alt.X('IMDB_Rating:Q').bin().axis(None), + x=alt.X('IMDB_Rating:Q', bin=True, axis=None), y='count()' ) diff --git a/altair/examples/horizon_graph.py b/altair/examples/horizon_graph.py index d2f534a73..833595789 100644 --- a/altair/examples/horizon_graph.py +++ b/altair/examples/horizon_graph.py @@ -22,18 +22,18 @@ area1 = alt.Chart(source).mark_area( clip=True, - interpolate='monotone', - opacity=0.6 + interpolate='monotone' ).encode( - alt.X('x').scale(zero=False, nice=False), - alt.Y('y').scale(domain=[0, 50]).title('y'), + alt.X('x', scale=alt.Scale(zero=False, nice=False)), + alt.Y('y', scale=alt.Scale(domain=[0, 50]), title='y'), + opacity=alt.value(0.6) ).properties( width=500, height=75 ) area2 = area1.encode( - alt.Y('ny:Q').scale(domain=[0, 50]) + alt.Y('ny:Q', scale=alt.Scale(domain=[0, 50])) ).transform_calculate( "ny", alt.datum.y - 50 ) diff --git a/altair/examples/interactive_cross_highlight.py b/altair/examples/interactive_cross_highlight.py index f862cb973..a167c0d20 100644 --- a/altair/examples/interactive_cross_highlight.py +++ b/altair/examples/interactive_cross_highlight.py @@ -14,22 +14,30 @@ pts = alt.selection(type="point", encodings=['x']) rect = alt.Chart(data.movies.url).mark_rect().encode( - alt.X('IMDB_Rating:Q').bin(), - alt.Y('Rotten_Tomatoes_Rating:Q').bin(), - alt.Color('count()').scale(scheme='greenblue').title('Total Records') + alt.X('IMDB_Rating:Q', bin=True), + alt.Y('Rotten_Tomatoes_Rating:Q', bin=True), + alt.Color('count()', + scale=alt.Scale(scheme='greenblue'), + legend=alt.Legend(title='Total Records') + ) ) circ = rect.mark_point().encode( alt.ColorValue('grey'), - alt.Size('count()').title('Records in Selection') + alt.Size('count()', + legend=alt.Legend(title='Records in Selection') + ) ).transform_filter( pts ) -bar = alt.Chart(source, width=550, height=200).mark_bar().encode( +bar = alt.Chart(source).mark_bar().encode( x='Major_Genre:N', y='count()', color=alt.condition(pts, alt.ColorValue("steelblue"), alt.ColorValue("grey")) +).properties( + width=550, + height=200 ).add_params(pts) alt.vconcat( diff --git a/altair/examples/interactive_layered_crossfilter.py b/altair/examples/interactive_layered_crossfilter.py index 831365996..6a945b22d 100644 --- a/altair/examples/interactive_layered_crossfilter.py +++ b/altair/examples/interactive_layered_crossfilter.py @@ -18,9 +18,12 @@ # Define the base chart, with the common parts of the # background and highlights -base = alt.Chart(width=160, height=130).mark_bar().encode( - x=alt.X(alt.repeat('column')).bin(maxbins=20), +base = alt.Chart().mark_bar().encode( + x=alt.X(alt.repeat('column'), type='quantitative', bin=alt.Bin(maxbins=20)), y='count()' +).properties( + width=160, + height=130 ) # gray background with selection diff --git a/altair/examples/interactive_legend.py b/altair/examples/interactive_legend.py index 80c47cf11..bd8b14b1a 100644 --- a/altair/examples/interactive_legend.py +++ b/altair/examples/interactive_legend.py @@ -14,9 +14,9 @@ selection = alt.selection_point(fields=['series'], bind='legend') alt.Chart(source).mark_area().encode( - alt.X('yearmonth(date):T').axis(domain=False, format='%Y', tickSize=0), - alt.Y('sum(count):Q').stack('center').axis(None), - alt.Color('series:N').scale(scheme='category20b'), + alt.X('yearmonth(date):T', axis=alt.Axis(domain=False, format='%Y', tickSize=0)), + alt.Y('sum(count):Q', stack='center', axis=None), + alt.Color('series:N', scale=alt.Scale(scheme='category20b')), opacity=alt.condition(selection, alt.value(1), alt.value(0.2)) ).add_params( selection diff --git a/altair/examples/interval_selection.py b/altair/examples/interval_selection.py index f0aa303e9..509c200b8 100644 --- a/altair/examples/interval_selection.py +++ b/altair/examples/interval_selection.py @@ -13,13 +13,16 @@ brush = alt.selection(type='interval', encodings=['x']) -base = alt.Chart(source, width=600, height=200).mark_area().encode( +base = alt.Chart(source).mark_area().encode( x = 'date:T', y = 'price:Q' +).properties( + width=600, + height=200 ) upper = base.encode( - alt.X('date:T').scale(domain=brush) + alt.X('date:T', scale=alt.Scale(domain=brush)) ) lower = base.properties( diff --git a/altair/examples/iowa_electricity.py b/altair/examples/iowa_electricity.py index 252cb0423..0f2081d99 100644 --- a/altair/examples/iowa_electricity.py +++ b/altair/examples/iowa_electricity.py @@ -10,10 +10,18 @@ source = data.iowa_electricity() alt.Chart(source, title="Iowa's renewable energy boom").mark_area().encode( - alt.X("year:T").title("Year"), - alt.Y("net_generation:Q") - .title("Share of net generation") - .stack("normalize") - .axis(format=".0%"), - alt.Color("source:N").title("Electricity source") + x=alt.X( + "year:T", + title="Year" + ), + y=alt.Y( + "net_generation:Q", + stack="normalize", + title="Share of net generation", + axis=alt.Axis(format=".0%"), + ), + color=alt.Color( + "source:N", + legend=alt.Legend(title="Electricity source"), + ) ) diff --git a/altair/examples/isotype.py b/altair/examples/isotype.py index 92850b729..23da6f4b3 100644 --- a/altair/examples/isotype.py +++ b/altair/examples/isotype.py @@ -67,15 +67,12 @@ ) alt.Chart(source).mark_point(filled=True, opacity=1, size=100).encode( - alt.X('x:O').axis(None), - alt.Y('animal:O').axis(None), - alt.Row('country:N').header(title=''), - alt.Shape('animal:N').legend(None).scale(shape_scale), - alt.Color('animal:N').legend(None).scale(color_scale), + alt.X('x:O', axis=None), + alt.Y('animal:O', axis=None), + alt.Row('country:N', header=alt.Header(title='')), + alt.Shape('animal:N', legend=None, scale=shape_scale), + alt.Color('animal:N', legend=None, scale=color_scale), ).transform_window( x='rank()', groupby=['country', 'animal'] -).properties( - width=550, - height=140 -) +).properties(width=550, height=140) diff --git a/altair/examples/isotype_emoji.py b/altair/examples/isotype_emoji.py index 313af8e82..92ab0f3ef 100644 --- a/altair/examples/isotype_emoji.py +++ b/altair/examples/isotype_emoji.py @@ -51,16 +51,13 @@ alt.Chart(source).mark_text(size=45, baseline='middle').encode( - alt.X('x:O').axis(None), - alt.Y('animal:O').axis(None), - alt.Row('country:N').title(''), + alt.X('x:O', axis=None), + alt.Y('animal:O', axis=None), + alt.Row('country:N', header=alt.Header(title='')), alt.Text('emoji:N') ).transform_calculate( emoji="{'cattle': '🐄', 'pigs': '🐖', 'sheep': '🐏'}[datum.animal]" ).transform_window( x='rank()', groupby=['country', 'animal'] -).properties( - width=550, - height=140 -) +).properties(width=550, height=140) diff --git a/altair/examples/isotype_grid.py b/altair/examples/isotype_grid.py index d0a9b6d4b..f90e9e8a8 100644 --- a/altair/examples/isotype_grid.py +++ b/altair/examples/isotype_grid.py @@ -27,9 +27,9 @@ filled=True, size=50 ).encode( - alt.X("col:O").axis(None), - alt.Y("row:O").axis(None), - alt.ShapeValue(person) + x=alt.X("col:O", axis=None), + y=alt.Y("row:O", axis=None), + shape=alt.ShapeValue(person) ).properties( width=400, height=400 diff --git a/altair/examples/lasagna_plot.py b/altair/examples/lasagna_plot.py index 0da7c44fd..6f603b8e1 100644 --- a/altair/examples/lasagna_plot.py +++ b/altair/examples/lasagna_plot.py @@ -17,15 +17,17 @@ alt.Chart(source, width=300, height=100).transform_filter( alt.datum.symbol != "GOOG" ).mark_rect().encode( - alt.X("yearmonthdate(date):O") - .title("Time") - .axis( + x=alt.X( + "yearmonthdate(date):O", + axis=alt.Axis( format="%Y", labelAngle=0, labelOverlap=False, labelColor=color_condition, tickColor=color_condition, ), - alt.Y("symbol:N").title(None), - alt.Color("sum(price)").title("Price") + title="Time", + ), + y=alt.Y("symbol:N", title=None), + color=alt.Color("sum(price)", title="Price"), ) diff --git a/altair/examples/layered_area_chart.py b/altair/examples/layered_area_chart.py index 83eb51b75..fe9e42c2c 100644 --- a/altair/examples/layered_area_chart.py +++ b/altair/examples/layered_area_chart.py @@ -11,6 +11,6 @@ alt.Chart(source).mark_area(opacity=0.3).encode( x="year:T", - y=alt.Y("net_generation:Q").stack(None), + y=alt.Y("net_generation:Q", stack=None), color="source:N" ) diff --git a/altair/examples/layered_bar_chart.py b/altair/examples/layered_bar_chart.py index ba485fea7..48d221e3b 100644 --- a/altair/examples/layered_bar_chart.py +++ b/altair/examples/layered_bar_chart.py @@ -11,6 +11,6 @@ alt.Chart(source).mark_bar(opacity=0.7).encode( x='year:O', - y=alt.Y('net_generation:Q').stack(None), + y=alt.Y('net_generation:Q', stack=None), color="source", ) diff --git a/altair/examples/layered_chart_with_dual_axis.py b/altair/examples/layered_chart_with_dual_axis.py index d14fbca57..8ef8f099b 100644 --- a/altair/examples/layered_chart_with_dual_axis.py +++ b/altair/examples/layered_chart_with_dual_axis.py @@ -11,18 +11,20 @@ source = data.seattle_weather() base = alt.Chart(source).encode( - alt.X('month(date):T').axis(title=None) + alt.X('month(date):T', axis=alt.Axis(title=None)) ) area = base.mark_area(opacity=0.3, color='#57A44C').encode( - alt.Y('average(temp_max)').title('Avg. Temperature (°C)', titleColor='#57A44C'), + alt.Y('average(temp_max)', + axis=alt.Axis(title='Avg. Temperature (°C)', titleColor='#57A44C')), alt.Y2('average(temp_min)') ) line = base.mark_line(stroke='#5276A7', interpolate='monotone').encode( - alt.Y('average(precipitation)').title('Precipitation (inches)', titleColor='#5276A7') + alt.Y('average(precipitation)', + axis=alt.Axis(title='Precipitation (inches)', titleColor='#5276A7')) ) alt.layer(area, line).resolve_scale( - y='independent' + y = 'independent' ) diff --git a/altair/examples/layered_heatmap_text.py b/altair/examples/layered_heatmap_text.py index 7a61c08cb..dc912ed8b 100644 --- a/altair/examples/layered_heatmap_text.py +++ b/altair/examples/layered_heatmap_text.py @@ -22,14 +22,15 @@ # Configure heatmap heatmap = base.mark_rect().encode( - alt.Color('mean_horsepower:Q') - .scale(scheme='viridis') - .title("Mean of Horsepower") + color=alt.Color('mean_horsepower:Q', + scale=alt.Scale(scheme='viridis'), + legend=alt.Legend(title="Mean of Horsepower"), + ) ) # Configure text text = base.mark_text(baseline='middle').encode( - alt.Text('mean_horsepower:Q', format=".0f"), + text=alt.Text('mean_horsepower:Q', format=".0f"), color=alt.condition( alt.datum.mean_horsepower > 150, alt.value('black'), diff --git a/altair/examples/layered_histogram.py b/altair/examples/layered_histogram.py index 62c7dccf6..f1af32625 100644 --- a/altair/examples/layered_histogram.py +++ b/altair/examples/layered_histogram.py @@ -23,7 +23,7 @@ opacity=0.3, binSpacing=0 ).encode( - alt.X('Measurement:Q').bin(maxbins=100), - alt.Y('count()').stack(None), + alt.X('Measurement:Q', bin=alt.Bin(maxbins=100)), + alt.Y('count()', stack=None), alt.Color('Experiment:N') ) diff --git a/altair/examples/line_chart_with_color_datum.py b/altair/examples/line_chart_with_color_datum.py index 77cad9574..17d3a1cec 100644 --- a/altair/examples/line_chart_with_color_datum.py +++ b/altair/examples/line_chart_with_color_datum.py @@ -1,7 +1,7 @@ """ Line Chart with Datum for Color ------------------------------- -An example of using ``repeat`` inside ``datum`` to color a multi-series line chart. +An example of using ``datum`` and ``repeat`` to color a multi-series line chart. This is adapted from this corresponding Vega-Lite Example: `Repeat and Layer to Show Different Movie Measures `_. """ @@ -13,11 +13,9 @@ source = data.movies() alt.Chart(source).mark_line().encode( - alt.X("IMDB_Rating").bin(True), - alt.Y(alt.repeat("layer")) - .aggregate("mean") - .title("Mean of US and Worldwide Gross"), + x=alt.X("IMDB_Rating", bin=True), + y=alt.Y( + alt.repeat("layer"), aggregate="mean", title="Mean of US and Worldwide Gross" + ), color=alt.datum(alt.repeat("layer")), -).repeat( - layer=["US_Gross", "Worldwide_Gross"] -) +).repeat(layer=["US_Gross", "Worldwide_Gross"]) diff --git a/altair/examples/line_chart_with_cumsum.py b/altair/examples/line_chart_with_cumsum.py index ef3144fe1..2b21b0845 100644 --- a/altair/examples/line_chart_with_cumsum.py +++ b/altair/examples/line_chart_with_cumsum.py @@ -9,7 +9,7 @@ source = data.wheat() -alt.Chart(source, width=600).mark_line().transform_window( +alt.Chart(source).mark_line().transform_window( # Sort the data chronologically sort=[{'field': 'year'}], # Include all previous records before the current record and none after @@ -21,4 +21,4 @@ x='year:O', # Plot the calculated field created by the transformation y='cumulative_wheat:Q' -) +).properties(width=600) \ No newline at end of file diff --git a/altair/examples/line_chart_with_custom_legend.py b/altair/examples/line_chart_with_custom_legend.py index 2ee60088e..992128232 100644 --- a/altair/examples/line_chart_with_custom_legend.py +++ b/altair/examples/line_chart_with_custom_legend.py @@ -12,7 +12,7 @@ source = data.stocks() base = alt.Chart(source).encode( - alt.Color("symbol").legend(None) + color=alt.Color("symbol", legend=None) ).transform_filter( "datum.symbol !== 'IBM'" ).properties( @@ -23,8 +23,8 @@ last_price = base.mark_circle().encode( - alt.X("last_date['date']:T"), - alt.Y("last_date['price']:Q") + x=alt.X("last_date['date']:T"), + y=alt.Y("last_date['price']:Q") ).transform_aggregate( last_date="argmax(date)", groupby=["symbol"] @@ -33,8 +33,8 @@ company_name = last_price.mark_text(align="left", dx=4).encode(text="symbol") chart = (line + last_price + company_name).encode( - x=alt.X().title("date"), - y=alt.Y().title("price") + x=alt.X(title="date"), + y=alt.Y(title="price") ) chart diff --git a/altair/examples/line_percent.py b/altair/examples/line_percent.py index 52e047034..fd23572de 100644 --- a/altair/examples/line_percent.py +++ b/altair/examples/line_percent.py @@ -11,8 +11,8 @@ alt.Chart(source).mark_line().encode( alt.X('year:O'), - alt.Y('perc:Q').axis(format='%'), - alt.Color('sex:N') + alt.Y('perc:Q', axis=alt.Axis(format='%')), + color='sex:N' ).transform_filter( alt.datum.job == 'Welder' ) diff --git a/altair/examples/line_with_ci.py b/altair/examples/line_with_ci.py index 744f453d0..5db97915a 100644 --- a/altair/examples/line_with_ci.py +++ b/altair/examples/line_with_ci.py @@ -16,7 +16,7 @@ band = alt.Chart(source).mark_errorband(extent='ci').encode( x='Year', - y=alt.Y('Miles_per_Gallon').title('Miles/Gallon'), + y=alt.Y('Miles_per_Gallon', title='Miles/Gallon'), ) band + line diff --git a/altair/examples/line_with_last_value_labeled b/altair/examples/line_with_last_value_labeled new file mode 100644 index 000000000..8793cab29 --- /dev/null +++ b/altair/examples/line_with_last_value_labeled @@ -0,0 +1,40 @@ +""" +Line Chart with Last Value Labeled +---------------------------------- +This chart shows a line chart with a label annotating the final value +""" +# category: line charts +import altair as alt +from vega_datasets import data + +# Import example data +source = data.stocks() + +# Create a common chart object +chart = alt.Chart(source).transform_filter( + alt.datum.symbol != "IBM" # A reducation of the dataset to clarify our example. Not required. +).encode( + color=alt.Color("symbol", legend=None) +) + +# Draw the line +line = chart.mark_line().encode( + x="date:T", + y="price:Q" +) + +# Use the `argmax` aggregate to limit the dataset to the final value +label = chart.encode( + x=alt.X('max(date):T'), + y=alt.Y('price:Q', aggregate=alt.ArgmaxDef(argmax='date')), + text='symbol' +) + +# Create a text label +text = label.mark_text(align='left', dx=4) + +# Create a circle annotation +circle = label.mark_circle() + +# Draw the chart with all the layers combined +line + circle + text diff --git a/altair/examples/line_with_log_scale.py b/altair/examples/line_with_log_scale.py index 740a670cb..b45fcd92e 100644 --- a/altair/examples/line_with_log_scale.py +++ b/altair/examples/line_with_log_scale.py @@ -11,5 +11,8 @@ alt.Chart(source).mark_line().encode( x='year:O', - y=alt.Y('sum(people)').scale(type="log") -) + y=alt.Y( + 'sum(people)', + scale=alt.Scale(type="log") # Here the scale is applied + ) +) \ No newline at end of file diff --git a/altair/examples/london_tube.py b/altair/examples/london_tube.py index b19ef9acc..3a39e6aef 100644 --- a/altair/examples/london_tube.py +++ b/altair/examples/london_tube.py @@ -13,11 +13,14 @@ tubelines = alt.topo_feature(data.londonTubeLines.url, 'line') centroids = data.londonCentroids.url -background = alt.Chart(boroughs, width=700, height=500).mark_geoshape( +background = alt.Chart(boroughs).mark_geoshape( stroke='white', strokeWidth=2 ).encode( color=alt.value('#eee'), +).properties( + width=700, + height=500 ) labels = alt.Chart(centroids).mark_text().encode( @@ -42,10 +45,15 @@ filled=False, strokeWidth=2 ).encode( - alt.Color('id:N') - .title(None) - .legend(orient='bottom-right', offset=0) - .scale(line_scale) + alt.Color( + 'id:N', + legend=alt.Legend( + title=None, + orient='bottom-right', + offset=0 + ), + scale=line_scale + ) ) background + labels + lines diff --git a/altair/examples/mosaic_with_labels.py b/altair/examples/mosaic_with_labels.py index d77ed05ab..2db0baff2 100644 --- a/altair/examples/mosaic_with_labels.py +++ b/altair/examples/mosaic_with_labels.py @@ -52,27 +52,29 @@ rect = base.mark_rect().encode( - x=alt.X("nx:Q").axis(None), + x=alt.X("nx:Q", axis=None), x2="nx2", y="ny:Q", y2="ny2", - color=alt.Color("Origin:N").legend(None), - opacity=alt.Opacity("Cylinders:Q").legend(None), + color=alt.Color("Origin:N", legend=None), + opacity=alt.Opacity("Cylinders:Q", legend=None), tooltip=["Origin:N", "Cylinders:Q"], ) text = base.mark_text(baseline="middle").encode( - alt.X("xc:Q").axis(None), - alt.Y("yc:Q").title("Cylinders"), - text="Cylinders:N" + x=alt.X("xc:Q", axis=None), y=alt.Y("yc:Q", title="Cylinders"), text="Cylinders:N" ) + mosaic = rect + text origin_labels = base.mark_text(baseline="middle", align="center").encode( - alt.X("min(xc):Q").title("Origin").axis(orient="top"), - alt.Color("Origin").legend(None), + x=alt.X( + "min(xc):Q", + axis=alt.Axis(title="Origin", orient="top"), + ), + color=alt.Color("Origin", legend=None), text="Origin", ) diff --git a/altair/examples/multifeature_scatter_plot.py b/altair/examples/multifeature_scatter_plot.py index 164b647bd..40e189bbf 100644 --- a/altair/examples/multifeature_scatter_plot.py +++ b/altair/examples/multifeature_scatter_plot.py @@ -10,8 +10,8 @@ source = data.iris() alt.Chart(source).mark_circle().encode( - alt.X('sepalLength').scale(zero=False), - alt.Y('sepalWidth').scale(zero=False, padding=1), + alt.X('sepalLength', scale=alt.Scale(zero=False)), + alt.Y('sepalWidth', scale=alt.Scale(zero=False, padding=1)), color='species', size='petalWidth' ) diff --git a/altair/examples/multiline_highlight.py b/altair/examples/multiline_highlight.py index 0e3f7781b..a6a172c4f 100644 --- a/altair/examples/multiline_highlight.py +++ b/altair/examples/multiline_highlight.py @@ -12,10 +12,8 @@ source = data.stocks() -highlight = alt.selection( - type='point', on='mouseover', - fields=['symbol'], nearest=True -) +highlight = alt.selection(type='point', on='mouseover', + fields=['symbol'], nearest=True) base = alt.Chart(source).encode( x='date:T', diff --git a/altair/examples/multiline_tooltip.py b/altair/examples/multiline_tooltip.py index 4dfa8d2c0..0a242e74e 100644 --- a/altair/examples/multiline_tooltip.py +++ b/altair/examples/multiline_tooltip.py @@ -18,10 +18,8 @@ import numpy as np np.random.seed(42) -source = pd.DataFrame( - np.cumsum(np.random.randn(100, 3), 0).round(2), - columns=['A', 'B', 'C'], index=pd.RangeIndex(100, name='x') -) +source = pd.DataFrame(np.cumsum(np.random.randn(100, 3), 0).round(2), + columns=['A', 'B', 'C'], index=pd.RangeIndex(100, name='x')) source = source.reset_index().melt('x', var_name='category', value_name='y') # Create a selection that chooses the nearest point & selects based on x-value diff --git a/altair/examples/multiple_interactions.py b/altair/examples/multiple_interactions.py index 3f85ab5aa..e11905018 100644 --- a/altair/examples/multiple_interactions.py +++ b/altair/examples/multiple_interactions.py @@ -19,11 +19,9 @@ format=alt.DataFormat(parse={"Release_Date":"date"}) ) ratings = ['G', 'NC-17', 'PG', 'PG-13', 'R'] -genres = [ - 'Action', 'Adventure', 'Black Comedy', 'Comedy', - 'Concert/Performance', 'Documentary', 'Drama', 'Horror', 'Musical', - 'Romantic Comedy', 'Thriller/Suspense', 'Western' -] +genres = ['Action', 'Adventure', 'Black Comedy', 'Comedy', + 'Concert/Performance', 'Documentary', 'Drama', 'Horror', 'Musical', + 'Romantic Comedy', 'Thriller/Suspense', 'Western'] base = alt.Chart(movies, width=200, height=200).mark_point(filled=True).transform_calculate( Rounded_IMDB_Rating = "floor(datum.IMDB_Rating)", @@ -34,18 +32,14 @@ ).transform_filter( alt.FieldOneOfPredicate(field='MPAA_Rating', oneOf=ratings) ).encode( - x=alt.X('Worldwide_Gross:Q').scale(domain=(100000,10**9), clamp=True), + x=alt.X('Worldwide_Gross:Q', scale=alt.Scale(domain=(100000,10**9), clamp=True)), y='IMDB_Rating:Q', tooltip="Title:N" ) # A slider filter year_slider = alt.binding_range(min=1969, max=2018, step=1) -slider_selection = alt.selection_point( - bind=year_slider, - fields=['Release_Year'], - name="Release Year_" -) +slider_selection = alt.selection_point(bind=year_slider, fields=['Release_Year'], name="Release Year_") filter_year = base.add_params( @@ -68,11 +62,9 @@ rating_radio = alt.binding_radio(options=ratings) rating_select = alt.selection_point(fields=['MPAA_Rating'], bind=rating_radio, name="Rating") -rating_color_condition = alt.condition( - rating_select, - alt.Color('MPAA_Rating:N').legend(None), - alt.value('lightgray') -) +rating_color_condition = alt.condition(rating_select, + alt.Color('MPAA_Rating:N', legend=None), + alt.value('lightgray')) highlight_ratings = base.add_params( rating_select diff --git a/altair/examples/natural_disasters.py b/altair/examples/natural_disasters.py index 31b50a151..031c1e987 100644 --- a/altair/examples/natural_disasters.py +++ b/altair/examples/natural_disasters.py @@ -17,20 +17,20 @@ strokeWidth=1, strokeOpacity=0.4 ).encode( - alt.X('Year:T') - .title(None) - .scale(domain=['1899','2018']), - alt.Y('Entity:N') - .title(None) - .sort(field="Deaths", op="sum", order='descending'), - alt.Size('Deaths:Q') - .scale(range=[0, 2500]) - .title('Deaths') - .legend(clipHeight=30, format='s'), - alt.Color('Entity:N').legend(None), + x=alt.X('Year:T', title=None, scale=alt.Scale(domain=['1899','2018'])), + y=alt.Y( + 'Entity:N', + sort=alt.EncodingSortField(field="Deaths", op="sum", order='descending'), + title=None + ), + size=alt.Size('Deaths:Q', + scale=alt.Scale(range=[0, 2500]), + legend=alt.Legend(title='Deaths', clipHeight=30, format='s') + ), + color=alt.Color('Entity:N', legend=None), tooltip=[ - "Entity:N", - alt.Tooltip("Year:T", format='%Y'), + "Entity:N", + alt.Tooltip("Year:T", format='%Y'), alt.Tooltip("Deaths:Q", format='~s') ], ).properties( diff --git a/altair/examples/normalized_stacked_area_chart.py b/altair/examples/normalized_stacked_area_chart.py index 5973d7174..a6bfec365 100644 --- a/altair/examples/normalized_stacked_area_chart.py +++ b/altair/examples/normalized_stacked_area_chart.py @@ -11,6 +11,6 @@ alt.Chart(source).mark_area().encode( x="year:T", - y=alt.Y("net_generation:Q").stack("normalize"), + y=alt.Y("net_generation:Q", stack="normalize"), color="source:N" ) diff --git a/altair/examples/normalized_stacked_bar_chart.py b/altair/examples/normalized_stacked_bar_chart.py index 71e48b9a1..307a452d2 100644 --- a/altair/examples/normalized_stacked_bar_chart.py +++ b/altair/examples/normalized_stacked_bar_chart.py @@ -10,7 +10,7 @@ source = data.barley() alt.Chart(source).mark_bar().encode( - x=alt.X('sum(yield)').stack("normalize"), + x=alt.X('sum(yield)', stack="normalize"), y='variety', color='site' ) diff --git a/altair/examples/parallel_coordinates.py b/altair/examples/parallel_coordinates.py index f5d7cbd6e..c46bc0129 100644 --- a/altair/examples/parallel_coordinates.py +++ b/altair/examples/parallel_coordinates.py @@ -15,8 +15,8 @@ source = data.iris() -alt.Chart(source, width=500).transform_window( - index='count()' +alt.Chart(source).transform_window( + index='count()' ).transform_fold( ['petalLength', 'petalWidth', 'sepalLength', 'sepalWidth'] ).mark_line().encode( @@ -25,4 +25,4 @@ color='species:N', detail='index:N', opacity=alt.value(0.5) -) +).properties(width=500) diff --git a/altair/examples/percentage_of_total.py b/altair/examples/percentage_of_total.py index addb9fd84..462353fde 100644 --- a/altair/examples/percentage_of_total.py +++ b/altair/examples/percentage_of_total.py @@ -8,16 +8,14 @@ import altair as alt import pandas as pd -source = pd.DataFrame({ - 'Activity': ['Sleeping', 'Eating', 'TV', 'Work', 'Exercise'], - 'Time': [8, 2, 4, 8, 2] -}) +source = pd.DataFrame({'Activity': ['Sleeping', 'Eating', 'TV', 'Work', 'Exercise'], + 'Time': [8, 2, 4, 8, 2]}) alt.Chart(source).transform_joinaggregate( TotalTime='sum(Time)', ).transform_calculate( PercentOfTotal="datum.Time / datum.TotalTime" ).mark_bar().encode( - alt.X('PercentOfTotal:Q').axis(format='.0%'), + alt.X('PercentOfTotal:Q', axis=alt.Axis(format='.0%')), y='Activity:N' ) diff --git a/altair/examples/pie_chart.py b/altair/examples/pie_chart.py index afc7515cb..230127a93 100644 --- a/altair/examples/pie_chart.py +++ b/altair/examples/pie_chart.py @@ -13,6 +13,6 @@ source = pd.DataFrame({"category": [1, 2, 3, 4, 5, 6], "value": [4, 6, 10, 3, 7, 8]}) alt.Chart(source).mark_arc().encode( - theta="value", - color="category" + theta=alt.Theta(field="value", type="quantitative"), + color=alt.Color(field="category", type="nominal"), ) diff --git a/altair/examples/pie_chart_with_labels.py b/altair/examples/pie_chart_with_labels.py index d82860853..15a3fb188 100644 --- a/altair/examples/pie_chart_with_labels.py +++ b/altair/examples/pie_chart_with_labels.py @@ -15,8 +15,7 @@ ) base = alt.Chart(source).encode( - alt.Theta("value:Q").stack(True), - alt.Color("category:N").legend(None) + theta=alt.Theta("value:Q", stack=True), color=alt.Color("category:N", legend=None) ) pie = base.mark_arc(outerRadius=120) diff --git a/altair/examples/poly_fit_regression.py b/altair/examples/poly_fit_regression.py index 8842b9d98..77163c940 100644 --- a/altair/examples/poly_fit_regression.py +++ b/altair/examples/poly_fit_regression.py @@ -20,8 +20,7 @@ degree_list = [1, 3, 5] base = alt.Chart(source).mark_circle(color="black").encode( - alt.X("x"), - alt.Y("y") + alt.X("x"), alt.Y("y") ) polynomial_fit = [ diff --git a/altair/examples/pyramid.py b/altair/examples/pyramid.py index 82aa854d0..676d77e88 100644 --- a/altair/examples/pyramid.py +++ b/altair/examples/pyramid.py @@ -11,13 +11,10 @@ color = ["#416D9D", "#674028", "#DEAC58"] df = pd.DataFrame({'category': category, 'value': [75, 10, 15]}) -alt.Chart(df, width=150, height=150).mark_arc(outerRadius=80).encode( - alt.Theta('value:Q').scale(range=[2.356, 8.639]), - alt.Color('category:N') - .title(None) - .scale(domain=category, range=color) - .legend(orient='none', legendX=160, legendY=50), +alt.Chart(df).mark_arc(outerRadius=80).encode( + alt.Theta('value:Q', scale=alt.Scale(range=[2.356, 8.639])), + alt.Color('category:N', + scale=alt.Scale(domain=category, range=color), + legend=alt.Legend(title=None, orient='none', legendX=160, legendY=50)), order='value:Q' -).configure_view( - strokeOpacity=0 -) +).properties(width=150, height=150).configure_view(strokeOpacity=0) diff --git a/altair/examples/radial_chart.py b/altair/examples/radial_chart.py index 1f844c945..3240d092f 100644 --- a/altair/examples/radial_chart.py +++ b/altair/examples/radial_chart.py @@ -13,8 +13,8 @@ source = pd.DataFrame({"values": [12, 23, 47, 6, 52, 19]}) base = alt.Chart(source).encode( - alt.Theta("values:Q").stack(True), - alt.Radius("values").scale(type="sqrt", zero=True, rangeMin=20), + theta=alt.Theta("values:Q", stack=True), + radius=alt.Radius("values", scale=alt.Scale(type="sqrt", zero=True, rangeMin=20)), color="values:N", ) diff --git a/altair/examples/ranged_dot_plot.py b/altair/examples/ranged_dot_plot.py index 340eeed32..d7efcf77c 100644 --- a/altair/examples/ranged_dot_plot.py +++ b/altair/examples/ranged_dot_plot.py @@ -32,7 +32,12 @@ ).encode( x='life_expect:Q', y='country:N', - color=alt.Color('year:O').scale(domain=[1955, 2000], range=['#e6959c', '#911a24']) + color=alt.Color('year:O', + scale=alt.Scale( + domain=[1955, 2000], + range=['#e6959c', '#911a24'] + ) + ) ).interactive() (line + points) diff --git a/altair/examples/ridgeline_plot.py b/altair/examples/ridgeline_plot.py index a04d6c566..54c1d6ff5 100644 --- a/altair/examples/ridgeline_plot.py +++ b/altair/examples/ridgeline_plot.py @@ -34,19 +34,23 @@ stroke='lightgray', strokeWidth=0.5 ).encode( - alt.X('bin_min:Q') - .bin(True) - .title('Maximum Daily Temperature (C)'), - alt.Y('value:Q') - .axis(None) - .scale(range=[step, -step * overlap]), - alt.Fill('mean_temp:Q') - .legend(None) - .scale(domain=[30, 5], scheme='redyellowblue') + alt.X('bin_min:Q', bin='binned', title='Maximum Daily Temperature (C)'), + alt.Y( + 'value:Q', + scale=alt.Scale(range=[step, -step * overlap]), + axis=None + ), + alt.Fill( + 'mean_temp:Q', + legend=None, + scale=alt.Scale(domain=[30, 5], scheme='redyellowblue') + ) ).facet( - alt.Row('Month:T') - .title(None) - .header(labelAngle=0, labelAlign='right', format='%B') + row=alt.Row( + 'Month:T', + title=None, + header=alt.Header(labelAngle=0, labelAlign='right', format='%B') + ) ).properties( title='Seattle Weather', bounds='flush' diff --git a/altair/examples/scatter_linked_table.py b/altair/examples/scatter_linked_table.py index a822d4ef3..167946824 100644 --- a/altair/examples/scatter_linked_table.py +++ b/altair/examples/scatter_linked_table.py @@ -1,7 +1,7 @@ """ Brushing Scatter Plot to Show Data on a Table --------------------------------------------- -A scatter plot of the cars dataset, with data tables for horsepower, MPG, and origin. +A scatter plot of the cars dataset, with data tables for horsepower, MPG, and origin. The tables update to reflect the selection on the scatter plot. """ # category: scatter plots @@ -12,36 +12,32 @@ source = data.cars() # Brush for selection -brush = alt.selection_interval() +brush = alt.selection(type='interval') # Scatter Plot points = alt.Chart(source).mark_point().encode( x='Horsepower:Q', y='Miles_per_Gallon:Q', - color=alt.condition(brush, alt.value('steelblue'), alt.value('grey')) + color=alt.condition(brush, 'Cylinders:O', alt.value('grey')) ).add_params(brush) # Base chart for data tables -ranked_text = alt.Chart(source).mark_text(align='right').encode( - y=alt.Y('row_number:O').axis(None) +ranked_text = alt.Chart(source).mark_text().encode( + y=alt.Y('row_number:O',axis=None) +).transform_window( + row_number='row_number()' ).transform_filter( brush ).transform_window( - row_number='row_number()' + rank='rank(row_number)' ).transform_filter( - 'datum.row_number < 15' + alt.datum.rank<20 ) # Data Tables -horsepower = ranked_text.encode(text='Horsepower:N').properties( - title=alt.TitleParams(text='Horsepower', align='right') -) -mpg = ranked_text.encode(text='Miles_per_Gallon:N').properties( - title=alt.TitleParams(text='MPG', align='right') -) -origin = ranked_text.encode(text='Origin:N').properties( - title=alt.TitleParams(text='Origin', align='right') -) +horsepower = ranked_text.encode(text='Horsepower:N').properties(title='Horsepower') +mpg = ranked_text.encode(text='Miles_per_Gallon:N').properties(title='MPG') +origin = ranked_text.encode(text='Origin:N').properties(title='Origin') text = alt.hconcat(horsepower, mpg, origin) # Combine data tables # Build chart @@ -50,6 +46,4 @@ text ).resolve_legend( color="independent" -).configure_view( - stroke=None ) diff --git a/altair/examples/scatter_marginal_hist.py b/altair/examples/scatter_marginal_hist.py index 02ddc37fe..52455dcc0 100644 --- a/altair/examples/scatter_marginal_hist.py +++ b/altair/examples/scatter_marginal_hist.py @@ -19,29 +19,31 @@ bar_args = {'opacity': .3, 'binSpacing': 0} points = base.mark_circle().encode( - alt.X('sepalLength').scale(xscale), - alt.Y('sepalWidth').scale(yscale), + alt.X('sepalLength', scale=xscale), + alt.Y('sepalWidth', scale=yscale), color='species', ) top_hist = base.mark_bar(**bar_args).encode( - alt.X('sepalLength:Q') + alt.X('sepalLength:Q', # when using bins, the axis scale is set through # the bin extent, so we do not specify the scale here # (which would be ignored anyway) - .bin(maxbins=20, extent=xscale.domain) - .stack(None) - .title(''), - alt.Y('count()').stack(None).title(''), + bin=alt.Bin(maxbins=20, extent=xscale.domain), + stack=None, + title='' + ), + alt.Y('count()', stack=None, title=''), alt.Color('species:N'), ).properties(height=60) right_hist = base.mark_bar(**bar_args).encode( - alt.Y('sepalWidth:Q') - .bin(maxbins=20, extent=yscale.domain) - .stack(None) - .title(''), - alt.X('count()').stack(None).title(''), + alt.Y('sepalWidth:Q', + bin=alt.Bin(maxbins=20, extent=yscale.domain), + stack=None, + title='', + ), + alt.X('count()', stack=None, title=''), alt.Color('species:N'), ).properties(width=60) diff --git a/altair/examples/scatter_with_layered_histogram.py b/altair/examples/scatter_with_layered_histogram.py index 995766ead..2268b055c 100644 --- a/altair/examples/scatter_with_layered_histogram.py +++ b/altair/examples/scatter_with_layered_histogram.py @@ -37,8 +37,8 @@ ).add_params(selector) points = base.mark_point(filled=True, size=200).encode( - x=alt.X('mean(height):Q').scale(domain=[0,84]), - y=alt.Y('mean(weight):Q').scale(domain=[0,250]), + x=alt.X('mean(height):Q', scale=alt.Scale(domain=[0,84])), + y=alt.Y('mean(weight):Q', scale=alt.Scale(domain=[0,250])), color=alt.condition( selector, 'gender:N', @@ -47,15 +47,17 @@ ) hists = base.mark_bar(opacity=0.5, thickness=100).encode( - x=alt.X('age') - .bin(step=5) # step keeps bin size the same - .scale(domain=[0,100]), - y=alt.Y('count()') - .stack(None) - .scale(domain=[0,350]), - color=alt.Color('gender:N', scale=color_scale) + x=alt.X('age', + bin=alt.Bin(step=5), # step keeps bin size the same + scale=alt.Scale(domain=[0,100])), + y=alt.Y('count()', + stack=None, + scale=alt.Scale(domain=[0,350])), + color=alt.Color('gender:N', + scale=color_scale) ).transform_filter( selector ) + points | hists diff --git a/altair/examples/scatter_with_minimap.py b/altair/examples/scatter_with_minimap.py index 0ad0c634c..a18a599cd 100644 --- a/altair/examples/scatter_with_minimap.py +++ b/altair/examples/scatter_with_minimap.py @@ -34,8 +34,13 @@ alt.Chart(source) .mark_point() .encode( - alt.X("date:T").scale(domain={"param": zoom.name, "encoding": "x"}), - alt.Y("temp_max:Q").scale(domain={"param": zoom.name, "encoding": "y"}), + x=alt.X( + "date:T", scale=alt.Scale(domain={"param": zoom.name, "encoding": "x"}) + ), + y=alt.Y( + "temp_max:Q", + scale=alt.Scale(domain={"param": zoom.name, "encoding": "y"}), + ), color="weather", ) .properties(width=600, height=400, title="Seattle weather -- detail view") diff --git a/altair/examples/scatter_with_rolling_mean.py b/altair/examples/scatter_with_rolling_mean.py index 914e32e4e..cf0b36cc1 100644 --- a/altair/examples/scatter_with_rolling_mean.py +++ b/altair/examples/scatter_with_rolling_mean.py @@ -23,8 +23,9 @@ ) points = alt.Chart(source).mark_point().encode( - x='date:T', - y=alt.Y('temp_max:Q').title('Max Temp') + x='date:T', + y=alt.Y('temp_max:Q', + axis=alt.Axis(title='Max Temp')) ) points + line diff --git a/altair/examples/seattle_weather_interactive.py b/altair/examples/seattle_weather_interactive.py index 46b7448e4..798cc4780 100644 --- a/altair/examples/seattle_weather_interactive.py +++ b/altair/examples/seattle_weather_interactive.py @@ -11,10 +11,8 @@ source = data.seattle_weather() -scale = alt.Scale( - domain=['sun', 'fog', 'drizzle', 'rain', 'snow'], - range=['#e7ba52', '#a7a7a7', '#aec7e8', '#1f77b4', '#9467bd'] -) +scale = alt.Scale(domain=['sun', 'fog', 'drizzle', 'rain', 'snow'], + range=['#e7ba52', '#a7a7a7', '#aec7e8', '#1f77b4', '#9467bd']) color = alt.Color('weather:N', scale=scale) # We create two selections: @@ -25,12 +23,13 @@ # Top panel is scatter plot of temperature vs time points = alt.Chart().mark_point().encode( - alt.X('monthdate(date):T').title('Date'), - alt.Y('temp_max:Q') - .title('Maximum Daily Temperature (C)') - .scale(domain=[-5, 40]), - alt.Size('precipitation:Q').scale(range=[5, 200]), + alt.X('monthdate(date):T', title='Date'), + alt.Y('temp_max:Q', + title='Maximum Daily Temperature (C)', + scale=alt.Scale(domain=[-5, 40]) + ), color=alt.condition(brush, color, alt.value('lightgray')), + size=alt.Size('precipitation:Q', scale=alt.Scale(range=[5, 200])) ).properties( width=550, height=300 diff --git a/altair/examples/select_detail.py b/altair/examples/select_detail.py index 4dead24c5..a6b558df7 100644 --- a/altair/examples/select_detail.py +++ b/altair/examples/select_detail.py @@ -56,8 +56,8 @@ timeseries = base.mark_line().encode( x='time', - y=alt.Y('value').scale(domain=(-15, 15)), - color=alt.Color('id:O').legend(None) + y=alt.Y('value', scale=alt.Scale(domain=(-15, 15))), + color=alt.Color('id:O', legend=None) ).transform_filter( selector ) diff --git a/altair/examples/simple_scatter_with_errorbars.py b/altair/examples/simple_scatter_with_errorbars.py index 434e6adca..691f3d893 100644 --- a/altair/examples/simple_scatter_with_errorbars.py +++ b/altair/examples/simple_scatter_with_errorbars.py @@ -29,8 +29,8 @@ size=50, color='black' ).encode( - alt.X('x').scale(domain=(0, 6)), - alt.Y('y').scale(zero=False) + x=alt.X('x', scale=alt.Scale(domain=(0, 6))), + y=alt.Y('y', scale=alt.Scale(zero=False)) ) # generate the error bars diff --git a/altair/examples/sorted_error_bars_with_ci.py b/altair/examples/sorted_error_bars_with_ci.py index ebda26a99..2baac1e1d 100644 --- a/altair/examples/sorted_error_bars_with_ci.py +++ b/altair/examples/sorted_error_bars_with_ci.py @@ -14,11 +14,14 @@ filled=True, color='black' ).encode( - x=alt.X('mean(yield)').title('Barley Yield'), - y=alt.Y('variety').sort( - field='yield', - op='mean', - order='descending' + x=alt.X('mean(yield)', title='Barley Yield'), + y=alt.Y( + 'variety', + sort=alt.EncodingSortField( + field='yield', + op='mean', + order='descending' + ) ) ).properties( width=400, diff --git a/altair/examples/stacked_bar_chart_with_text.py b/altair/examples/stacked_bar_chart_with_text.py index f2641e4e2..180d20871 100644 --- a/altair/examples/stacked_bar_chart_with_text.py +++ b/altair/examples/stacked_bar_chart_with_text.py @@ -12,13 +12,13 @@ source=data.barley() bars = alt.Chart(source).mark_bar().encode( - x=alt.X('sum(yield):Q').stack('zero'), + x=alt.X('sum(yield):Q', stack='zero'), y=alt.Y('variety:N'), color=alt.Color('site') ) text = alt.Chart(source).mark_text(dx=-15, dy=3, color='white').encode( - x=alt.X('sum(yield):Q').stack('zero'), + x=alt.X('sum(yield):Q', stack='zero'), y=alt.Y('variety:N'), detail='site:N', text=alt.Text('sum(yield):Q', format='.1f') diff --git a/altair/examples/stem_and_leaf.py b/altair/examples/stem_and_leaf.py index 9436d8eb2..cd8f7179e 100644 --- a/altair/examples/stem_and_leaf.py +++ b/altair/examples/stem_and_leaf.py @@ -27,12 +27,10 @@ baseline='middle', dx=-5 ).encode( - alt.X('position:Q') - .title('') - .axis(ticks=False, labels=False, grid=False), - alt.Y('stem:N') - .title('') - .axis(tickSize=0), + alt.X('position:Q', title='', + axis=alt.Axis(ticks=False, labels=False, grid=False) + ), + alt.Y('stem:N', title='', axis=alt.Axis(tickSize=0)), text='leaf:N', ).configure_axis( labelFontSize=20 diff --git a/altair/examples/streamgraph.py b/altair/examples/streamgraph.py index b9bdcb512..64b8e4176 100644 --- a/altair/examples/streamgraph.py +++ b/altair/examples/streamgraph.py @@ -10,7 +10,11 @@ source = data.unemployment_across_industries.url alt.Chart(source).mark_area().encode( - alt.X('yearmonth(date):T').axis(format='%Y', domain=False, tickSize=0), - alt.Y('sum(count):Q').stack('center').axis(None), - alt.Color('series:N').scale(scheme='category20b') + alt.X('yearmonth(date):T', + axis=alt.Axis(format='%Y', domain=False, tickSize=0) + ), + alt.Y('sum(count):Q', stack='center', axis=None), + alt.Color('series:N', + scale=alt.Scale(scheme='category20b') + ) ).interactive() diff --git a/altair/examples/strip_plot_jitter.py b/altair/examples/strip_plot_jitter.py index edf572b02..e0b7d1645 100644 --- a/altair/examples/strip_plot_jitter.py +++ b/altair/examples/strip_plot_jitter.py @@ -19,7 +19,7 @@ y="Major_Genre:N", x="IMDB_Rating:Q", yOffset="jitter:Q", - color=alt.Color('Major_Genre:N').legend(None) + color=alt.Color('Major_Genre:N', legend=None) ).transform_calculate( # Generate Gaussian jitter with a Box-Muller transform jitter="sqrt(-2*log(random()))*cos(2*PI*random())" @@ -29,7 +29,7 @@ # Generate uniform jitter jitter='random()' ).encode( - alt.Y('Major_Genre:N').axis(None) + y=alt.Y('Major_Genre:N', axis=None) ).properties( title='Uniformly distributed jitter' ) diff --git a/altair/examples/top_k_items.py b/altair/examples/top_k_items.py index 49285670e..0c8ade36c 100644 --- a/altair/examples/top_k_items.py +++ b/altair/examples/top_k_items.py @@ -15,9 +15,9 @@ alt.Chart( source, ).mark_bar().encode( - alt.X('Title:N').sort('-y'), - alt.Y('IMDB_Rating:Q'), - alt.Color('IMDB_Rating:Q') + x=alt.X('Title:N', sort='-y'), + y=alt.Y('IMDB_Rating:Q'), + color=alt.Color('IMDB_Rating:Q') ).transform_window( rank='rank(IMDB_Rating)', diff --git a/altair/examples/top_k_letters.py b/altair/examples/top_k_letters.py index ac56b02a8..b08fcc309 100644 --- a/altair/examples/top_k_letters.py +++ b/altair/examples/top_k_letters.py @@ -35,6 +35,6 @@ ).transform_filter( alt.datum.rank < 10 ).mark_bar().encode( - y=alt.Y('letters:N').sort('-x'), + y=alt.Y('letters:N', sort='-x'), x='count:Q', ) diff --git a/altair/examples/top_k_with_others.py b/altair/examples/top_k_with_others.py index 5a177e160..28cda2423 100644 --- a/altair/examples/top_k_with_others.py +++ b/altair/examples/top_k_with_others.py @@ -12,10 +12,12 @@ source = data.movies.url alt.Chart(source).mark_bar().encode( - alt.X("aggregate_gross:Q").aggregate("mean").title(None), - alt.Y("ranked_director:N") - .sort(op="mean", field="aggregate_gross", order="descending") - .title(None) + x=alt.X("aggregate_gross:Q", aggregate="mean", title=None), + y=alt.Y( + "ranked_director:N", + sort=alt.Sort(op="mean", field="aggregate_gross", order="descending"), + title=None, + ), ).transform_aggregate( aggregate_gross='mean(Worldwide_Gross)', groupby=["Director"], diff --git a/altair/examples/trellis_area_sort_array.py b/altair/examples/trellis_area_sort_array.py index 2dab32fde..a8c74532e 100644 --- a/altair/examples/trellis_area_sort_array.py +++ b/altair/examples/trellis_area_sort_array.py @@ -17,5 +17,5 @@ x='date:T', y='price:Q', color='symbol:N', - row=alt.Row('symbol:N').sort(['MSFT', 'AAPL', 'IBM', 'AMZN']) + row=alt.Row('symbol:N', sort=['MSFT', 'AAPL', 'IBM', 'AMZN']) ).properties(height=50, width=400) diff --git a/altair/examples/trellis_histogram.py b/altair/examples/trellis_histogram.py index 8c45ccf20..c124f2caf 100644 --- a/altair/examples/trellis_histogram.py +++ b/altair/examples/trellis_histogram.py @@ -11,7 +11,7 @@ source = data.cars() alt.Chart(source).mark_bar().encode( - alt.X("Horsepower:Q").bin(), + alt.X("Horsepower:Q", bin=True), y='count()', row='Origin' ) diff --git a/altair/examples/us_employment.py b/altair/examples/us_employment.py index 2dada0833..c62b45e17 100644 --- a/altair/examples/us_employment.py +++ b/altair/examples/us_employment.py @@ -26,8 +26,8 @@ source, title="The U.S. employment crash during the Great Recession" ).mark_bar().encode( - alt.X("month:T").title(""), - alt.Y("nonfarm_change:Q").title("Change in non-farm employment (in thousands)"), + x=alt.X("month:T", title=""), + y=alt.Y("nonfarm_change:Q", title="Change in non-farm employment (in thousands)"), color=alt.condition( alt.datum.nonfarm_change > 0, alt.value("steelblue"), diff --git a/altair/examples/us_population_over_time.py b/altair/examples/us_population_over_time.py index 75c4fa01c..db7403663 100644 --- a/altair/examples/us_population_over_time.py +++ b/altair/examples/us_population_over_time.py @@ -19,12 +19,14 @@ ) alt.Chart(source).mark_bar().encode( - alt.X("sex:N").title('').axis(labels=False, ticks=False), - alt.Y("people:Q").scale(domain=(0, 12000000)).title("Population"), - alt.Color("sex:N") - .scale(domain=("Male", "Female"), range=["steelblue", "salmon"]) - .title("Sex"), - alt.Column("age:O").title("Age") + x=alt.X("sex:N", axis=alt.Axis(labels=False, title=None, ticks=False)), + y=alt.Y("people:Q", scale=alt.Scale(domain=(0, 12000000)), title="Population"), + color=alt.Color( + "sex:N", + scale=alt.Scale(domain=("Male", "Female"), range=["steelblue", "salmon"]), + title="Sex", + ), + column=alt.Column("age:O", title="Age"), ).properties( width=20, title="U.S. Population by Age and Sex" diff --git a/altair/examples/us_population_over_time_facet.py b/altair/examples/us_population_over_time_facet.py index 6444e0d80..fc8001981 100644 --- a/altair/examples/us_population_over_time_facet.py +++ b/altair/examples/us_population_over_time_facet.py @@ -12,10 +12,14 @@ alt.Chart(source).mark_area().encode( x='age:O', - y=alt.Y('sum(people):Q').title('Population').axis(format='~s'), - facet=alt.Facet('year:O').columns(5), + y=alt.Y( + 'sum(people):Q', + title='Population', + axis=alt.Axis(format='~s') + ), + facet=alt.Facet('year:O', columns=5), ).properties( title='US Age Distribution By Year', width=90, height=80 -) +) \ No newline at end of file diff --git a/altair/examples/us_population_pyramid_over_time.py b/altair/examples/us_population_pyramid_over_time.py index f7418413d..4857adf6a 100644 --- a/altair/examples/us_population_pyramid_over_time.py +++ b/altair/examples/us_population_pyramid_over_time.py @@ -32,26 +32,24 @@ left = base.transform_filter( alt.datum.gender == 'Female' ).encode( - alt.Y('age:O').axis(None), - alt.X('sum(people):Q') - .title('population') - .sort('descending'), - alt.Color('gender:N') - .scale(color_scale) - .legend(None) + y=alt.Y('age:O', axis=None), + x=alt.X('sum(people):Q', + title='population', + sort=alt.SortOrder('descending')), + color=alt.Color('gender:N', scale=color_scale, legend=None) ).mark_bar().properties(title='Female') middle = base.encode( - alt.Y('age:O').axis(None), - alt.Text('age:Q'), + y=alt.Y('age:O', axis=None), + text=alt.Text('age:Q'), ).mark_text().properties(width=20) right = base.transform_filter( alt.datum.gender == 'Male' ).encode( - alt.Y('age:O').axis(None), - alt.X('sum(people):Q').title('population'), - alt.Color('gender:N').scale(color_scale).legend(None) + y=alt.Y('age:O', axis=None), + x=alt.X('sum(people):Q', title='population'), + color=alt.Color('gender:N', scale=color_scale, legend=None) ).mark_bar().properties(title='Male') alt.concat(left, middle, right, spacing=5) diff --git a/altair/examples/us_state_capitals.py b/altair/examples/us_state_capitals.py index 00dfdaea6..9296b9994 100644 --- a/altair/examples/us_state_capitals.py +++ b/altair/examples/us_state_capitals.py @@ -31,7 +31,7 @@ ) text = base.mark_text(dy=-5, align='right').encode( - alt.Text('city:N'), + alt.Text('city', type='nominal'), opacity=alt.condition(~hover, alt.value(0), alt.value(1)) ) diff --git a/altair/examples/violin_plot.py b/altair/examples/violin_plot.py index d09274d1e..09977b86e 100644 --- a/altair/examples/violin_plot.py +++ b/altair/examples/violin_plot.py @@ -7,22 +7,33 @@ import altair as alt from vega_datasets import data -alt.Chart(data.cars(), width=100).transform_density( +alt.Chart(data.cars()).transform_density( 'Miles_per_Gallon', as_=['Miles_per_Gallon', 'density'], extent=[5, 50], groupby=['Origin'] ).mark_area(orient='horizontal').encode( - alt.X('density:Q') - .stack('center') - .impute(None) - .title(None) - .axis(labels=False, values=[0], grid=False, ticks=True), - alt.Y('Miles_per_Gallon:Q'), - alt.Color('Origin:N'), - alt.Column('Origin:N') - .spacing(0) - .header(titleOrient='bottom', labelOrient='bottom', labelPadding=0) + y='Miles_per_Gallon:Q', + color='Origin:N', + x=alt.X( + 'density:Q', + stack='center', + impute=None, + title=None, + axis=alt.Axis(labels=False, values=[0],grid=False, ticks=True), + ), + column=alt.Column( + 'Origin:N', + header=alt.Header( + titleOrient='bottom', + labelOrient='bottom', + labelPadding=0, + ), + ) +).properties( + width=100 +).configure_facet( + spacing=0 ).configure_view( stroke=None ) diff --git a/altair/examples/waterfall_chart.py b/altair/examples/waterfall_chart.py new file mode 100644 index 000000000..50f8718f4 --- /dev/null +++ b/altair/examples/waterfall_chart.py @@ -0,0 +1,106 @@ +""" +Waterfall Chart +--------------- +This example shows how to recreate a Vega-Lite implementation of a waterfall chart. +Original inspiration is from https://vega.github.io/vega-lite/examples/waterfall_chart.html +""" +# category: advanced calculations + +import altair as alt +import pandas as pd + +data = [ + {"label": "Begin", "amount": 4000}, + {"label": "Jan", "amount": 1707}, + {"label": "Feb", "amount": -1425}, + {"label": "Mar", "amount": -1030}, + {"label": "Apr", "amount": 1812}, + {"label": "May", "amount": -1067}, + {"label": "Jun", "amount": -1481}, + {"label": "Jul", "amount": 1228}, + {"label": "Aug", "amount": 1176}, + {"label": "Sep", "amount": 1146}, + {"label": "Oct", "amount": 1205}, + {"label": "Nov", "amount": -1388}, + {"label": "Dec", "amount": 1492}, + {"label": "End", "amount": 0}, +] +source = pd.DataFrame(data) + +# The "base_chart" defines the transform_window, transform_calculate, and X axis +base_chart = alt.Chart(source).transform_window( + window_sum_amount="sum(amount)", + window_lead_label="lead(label)", +).transform_calculate( + calc_lead="datum.window_lead_label === null ? datum.label : datum.window_lead_label", + calc_prev_sum="datum.label === 'End' ? 0 : datum.window_sum_amount - datum.amount", + calc_amount="datum.label === 'End' ? datum.window_sum_amount : datum.amount", + calc_text_amount="(datum.label !== 'Begin' && datum.label !== 'End' && datum.calc_amount > 0 ? '+' : '') + datum.calc_amount", + calc_center="(datum.window_sum_amount + datum.calc_prev_sum) / 2", + calc_sum_dec="datum.window_sum_amount < datum.calc_prev_sum ? datum.window_sum_amount : ''", + calc_sum_inc="datum.window_sum_amount > datum.calc_prev_sum ? datum.window_sum_amount : ''", +).encode( + x=alt.X( + "label:O", + axis=alt.Axis(title="Months", labelAngle=0), + sort=None, + ) +) + +# alt.condition does not support multiple if else conditions which is why +# we use a dictionary instead. See https://stackoverflow.com/a/66109641 +# for more information +color_coding = { + "condition": [ + {"test": "datum.label === 'Begin' || datum.label === 'End'", "value": "#878d96"}, + {"test": "datum.calc_amount < 0", "value": "#24a148"}, + ], + "value": "#fa4d56", +} + +bar = base_chart.mark_bar(size=45).encode( + y=alt.Y("calc_prev_sum:Q", title="Amount"), + y2=alt.Y2("window_sum_amount:Q"), + color=color_coding, +) + +# The "rule" chart is for the horizontal lines that connect the bars +rule = base_chart.mark_rule( + xOffset=-22.5, + x2Offset=22.5, +).encode( + y="window_sum_amount:Q", + x2="calc_lead", +) + +# Add values as text +text_pos_values_top_of_bar = base_chart.mark_text( + baseline="bottom", + dy=-4 +).encode( + text=alt.Text("calc_sum_inc:N"), + y="calc_sum_inc:Q" +) +text_neg_values_bot_of_bar = base_chart.mark_text( + baseline="top", + dy=4 +).encode( + text=alt.Text("calc_sum_dec:N"), + y="calc_sum_dec:Q" +) +text_bar_values_mid_of_bar = base_chart.mark_text(baseline="middle").encode( + text=alt.Text("calc_text_amount:N"), + y="calc_center:Q", + color=alt.value("white"), +) + +alt.layer( + bar, + rule, + text_pos_values_top_of_bar, + text_neg_values_bot_of_bar, + text_bar_values_mid_of_bar +).properties( + width=800, + height=450 +) \ No newline at end of file diff --git a/altair/examples/wheat_wages.py b/altair/examples/wheat_wages.py index 81153712d..dd168b1fc 100644 --- a/altair/examples/wheat_wages.py +++ b/altair/examples/wheat_wages.py @@ -22,31 +22,31 @@ ) bars = base_wheat.mark_bar(**{"fill": "#aaa", "stroke": "#999"}).encode( - alt.X("year:Q").axis(format='d', tickCount=5), - alt.Y("wheat:Q").axis(zindex=1), - alt.X2("year_end") + x=alt.X("year:Q", axis=alt.Axis(format='d', tickCount=5)), + y=alt.Y("wheat:Q", axis=alt.Axis(zindex=1)), + x2=alt.X2("year_end") ) area = base_wheat.mark_area(**{"color": "#a4cedb", "opacity": 0.7}).encode( - alt.X("year:Q"), - alt.Y("wages:Q") + x=alt.X("year:Q"), + y=alt.Y("wages:Q") ) area_line_1 = area.mark_line(**{"color": "#000", "opacity": 0.7}) area_line_2 = area.mark_line(**{"yOffset": -2, "color": "#EE8182"}) top_bars = base_monarchs.mark_bar(stroke="#000").encode( - alt.X("start:Q"), - alt.X2("end"), - alt.Y("y:Q"), - alt.Y2("offset"), - alt.Fill("commonwealth:N").legend(None).scale(range=["black", "white"]) + x=alt.X("start:Q"), + x2=alt.X2("end"), + y=alt.Y("y:Q"), + y2=alt.Y2("offset"), + fill=alt.Fill("commonwealth:N", legend=None, scale=alt.Scale(range=["black", "white"])) ) top_text = base_monarchs.mark_text(**{"yOffset": 14, "fontSize": 9, "fontStyle": "italic"}).encode( - alt.X("x:Q"), - alt.Y("off2:Q"), - alt.Text("name:N") + x=alt.X("x:Q"), + y=alt.Y("off2:Q"), + text=alt.Text("name:N") ) (bars + area + area_line_1 + area_line_2 + top_bars + top_text).properties( @@ -55,4 +55,4 @@ title=None, gridColor="white", gridOpacity=0.25, domain=False ).configure_view( stroke="transparent" -) +) \ No newline at end of file diff --git a/altair/examples/wilkinson-dot-plot.py b/altair/examples/wilkinson-dot-plot.py index 55e31296c..d8a9889f0 100644 --- a/altair/examples/wilkinson-dot-plot.py +++ b/altair/examples/wilkinson-dot-plot.py @@ -16,10 +16,12 @@ } ) -alt.Chart(source, height=100).mark_circle(opacity=1).transform_window( - id='rank()', +alt.Chart(source).mark_circle(opacity=1).transform_window( + id='rank()', groupby=['data'] ).encode( - alt.X('data:O'), - alt.Y('id:O').axis(None).sort('descending') -) + alt.X('data:O'), + alt.Y('id:O', + axis=None, + sort='descending') +).properties(height=100) diff --git a/altair/examples/wind_vector_map.py b/altair/examples/wind_vector_map.py index 56dcd674b..1235ec33a 100644 --- a/altair/examples/wind_vector_map.py +++ b/altair/examples/wind_vector_map.py @@ -14,15 +14,20 @@ df_wind = data.windvectors() data_world = alt.topo_feature(data.world_110m.url, "countries") -wedge = alt.Chart(df_wind).mark_point(shape="wedge", filled=True).encode( - alt.Latitude("latitude"), - alt.Longitude("longitude"), - alt.Color("dir") - .scale(domain=[0, 360], scheme="rainbow") - .legend(None), - alt.Angle("dir").scale(domain=[0, 360], range=[180, 540]), - alt.Size("speed").scale(rangeMax=500) -).project("equalEarth") +wedge = ( + alt.Chart(df_wind) + .mark_point(shape="wedge", filled=True) + .encode( + latitude="latitude", + longitude="longitude", + color=alt.Color( + "dir", scale=alt.Scale(domain=[0, 360], scheme="rainbow"), legend=None + ), + angle=alt.Angle("dir", scale=alt.Scale(domain=[0, 360], range=[180, 540])), + size=alt.Size("speed", scale=alt.Scale(rangeMax=500)), + ) + .project("equalEarth") +) xmin, xmax, ymin, ymax = ( df_wind.longitude.min(), @@ -54,4 +59,4 @@ .project(type="equalEarth", fit=extent) ) -base + wedge +base + wedge \ No newline at end of file diff --git a/altair/examples/window_rank.py b/altair/examples/window_rank.py index 35796dffe..1e33fac06 100644 --- a/altair/examples/window_rank.py +++ b/altair/examples/window_rank.py @@ -31,7 +31,7 @@ ) alt.Chart(source).mark_line().encode( - x="matchday:O", y="rank:O", color=alt.Color("team:N").scale(color_scale) + x="matchday:O", y="rank:O", color=alt.Color("team:N", scale=color_scale) ).transform_window( rank="rank()", sort=[ From e7ae0ba671a60f759a4136825c3f042b0f71b55e Mon Sep 17 00:00:00 2001 From: Christopher Davis Date: Fri, 30 Dec 2022 11:06:22 -0600 Subject: [PATCH 22/26] Basic documentation for attribute setter methods --- doc/user_guide/encodings/index.rst | 52 ++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/doc/user_guide/encodings/index.rst b/doc/user_guide/encodings/index.rst index 8d3821010..8a3da4fc8 100644 --- a/doc/user_guide/encodings/index.rst +++ b/doc/user_guide/encodings/index.rst @@ -44,6 +44,44 @@ the chart. For example, below we adjust the y-axis title and increase the step b ) +.. _method-based-attribute-setting: + +Alternative Syntax +~~~~~~~~~~~~~~~~~~ + +Altair 5.0 introduced an alternative method-based syntax for setting channel attributes. In the example above, the ``axis`` attribute of the x channel encoding is set using the ``axis`` keyword argument: ``x=alt.X('Horsepower', axis=alt.Axis(tickMinStep=50))``. To define the same :class:`X` object using the method-based syntax (new as of Altair 5.0), we can use ``x=alt.X('Horsepower').axis(tickMinStep=50)``. In other words, the use of the ``axis`` keyword argument is replaced by the use of the ``axis`` method. + +The same technique works with all encoding channels and all channel attributes. For example, notice how we make the analogous change with respect to the ``title`` attribute of the y channel. The following produces the same chart as the previous example. + +.. altair-plot:: + import altair as alt + from vega_datasets import data + cars = data.cars() + + alt.Chart(cars).mark_point().encode( + x=alt.X('Horsepower').axis(tickMinStep=50), + y=alt.Y('Miles_per_Gallon').title("Miles per Gallon"), + color='Origin', + shape='Origin' + ) + +These attribute-setter methods can also be chained together, as in the following, in which we set the ``axis``, ``bin``, and ``scale`` attributes of the x channel by using the corresponding methods (``axis``, ``bin``, and ``scale``). We break the ``x`` definition over multiple lines to improve readability. (This is valid syntax because of the enclosing parentheses from ``encode``.) + +.. altair-plot:: + import altair as alt + from vega_datasets import data + cars = data.cars() + + alt.Chart(cars).mark_point().encode( + x=alt.X('Horsepower') + .axis(ticks=False) + .bin(maxbins=10) + .scale(domain=(30,300), reverse=True), + y=alt.Y('Miles_per_Gallon').title("Miles per Gallon"), + color='Origin', + shape='Origin' + ) + .. _encoding-data-types: Encoding Data Types @@ -504,6 +542,20 @@ the color scale used for the lines, you can use ``value``, e.g. ``alt.value("red lines + rule +One caution is that ``alt.datum`` and ``alt.value`` do not possess the (newly introduced as of Altair 5.0) method-based attribute setter syntax described in :ref:`method-based-attribute-setting`. If you are using ``alt.datum`` for the y channel encoding (for example) and you wish to use an attribute setter method (e.g., ``scale``), then you should probably be using :class:`YDatum` instead. Here is a simple example. + +.. altair-plot:: + + import altair as alt + + bar = alt.Chart().mark_bar().encode( + y=alt.YDatum(220).scale(domain=(0,500)), + color=alt.value("darkkhaki") + ) + + bar + +If you were to instead use ``y=alt.datum(220).scale(domain=(0,500))``, an ``AttributeError`` would be raised, due to the fact that ``alt.datum(220)`` is simply a Python dictionary and does not possess a ``scale`` attribute. If you insisted on producing the preceding example using ``alt.datum``, one option would be to use ``y=alt.datum(220, scale={"domain": (0,500)})``. Nevertheless, the ``alt.YDatum`` approach is strongly preferred to this "by-hand" approach of supplying a dictionary to ``scale``. As one benefit, tab-completions are available using the ``alt.YDatum`` approach. For example, typing ``alt.YDatum(220).scale(do`` and hitting ``tab`` in an environment such as JupyterLab will offer ``domain``, ``domainMax``, ``domainMid``, and ``domainMin`` as possible completions. .. toctree:: :hidden: From 29169bc6960c6e6b8e0bbe1cb2ed244c3c74cfe8 Mon Sep 17 00:00:00 2001 From: Christopher Davis <82750240+ChristopherDavisUCI@users.noreply.github.com> Date: Fri, 30 Dec 2022 16:23:38 -0600 Subject: [PATCH 23/26] Apply suggestions from code review Co-authored-by: Stefan Binder --- doc/user_guide/encodings/index.rst | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/user_guide/encodings/index.rst b/doc/user_guide/encodings/index.rst index 8a3da4fc8..b46acf6b6 100644 --- a/doc/user_guide/encodings/index.rst +++ b/doc/user_guide/encodings/index.rst @@ -46,12 +46,12 @@ the chart. For example, below we adjust the y-axis title and increase the step b .. _method-based-attribute-setting: -Alternative Syntax -~~~~~~~~~~~~~~~~~~ +Alternative Syntax for Channel Options +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Altair 5.0 introduced an alternative method-based syntax for setting channel attributes. In the example above, the ``axis`` attribute of the x channel encoding is set using the ``axis`` keyword argument: ``x=alt.X('Horsepower', axis=alt.Axis(tickMinStep=50))``. To define the same :class:`X` object using the method-based syntax (new as of Altair 5.0), we can use ``x=alt.X('Horsepower').axis(tickMinStep=50)``. In other words, the use of the ``axis`` keyword argument is replaced by the use of the ``axis`` method. +Altair 5.0 introduced an alternative method-based syntax for setting channel options. In the example above, the ``axis`` option of the ``x`` channel encoding is set using the ``axis`` keyword argument: ``x=alt.X('Horsepower', axis=alt.Axis(tickMinStep=50))``. To define the same :class:`X` object using the alternative method-based syntax, we can use ``x=alt.X('Horsepower').axis(tickMinStep=50)``. In other words, the use of the ``axis`` keyword argument is replaced by the use of the ``axis`` method. -The same technique works with all encoding channels and all channel attributes. For example, notice how we make the analogous change with respect to the ``title`` attribute of the y channel. The following produces the same chart as the previous example. +The same technique works with all encoding channels and all channel options. For example, notice how we make the analogous change with respect to the ``title`` option of the ``y`` channel. The following produces the same chart as the previous example. .. altair-plot:: import altair as alt @@ -60,12 +60,12 @@ The same technique works with all encoding channels and all channel attributes. alt.Chart(cars).mark_point().encode( x=alt.X('Horsepower').axis(tickMinStep=50), - y=alt.Y('Miles_per_Gallon').title("Miles per Gallon"), + y=alt.Y('Miles_per_Gallon').title('Miles per Gallon'), color='Origin', shape='Origin' ) -These attribute-setter methods can also be chained together, as in the following, in which we set the ``axis``, ``bin``, and ``scale`` attributes of the x channel by using the corresponding methods (``axis``, ``bin``, and ``scale``). We break the ``x`` definition over multiple lines to improve readability. (This is valid syntax because of the enclosing parentheses from ``encode``.) +These option-setter methods can also be chained together, as in the following, in which we set the ``axis``, ``bin``, and ``scale`` options of the ``x`` channel by using the corresponding methods (``axis``, ``bin``, and ``scale``). We can break the ``x`` definition over multiple lines to improve readability. (This is valid syntax because of the enclosing parentheses from ``encode``.) .. altair-plot:: import altair as alt @@ -77,7 +77,7 @@ These attribute-setter methods can also be chained together, as in the following .axis(ticks=False) .bin(maxbins=10) .scale(domain=(30,300), reverse=True), - y=alt.Y('Miles_per_Gallon').title("Miles per Gallon"), + y=alt.Y('Miles_per_Gallon').title('Miles per Gallon'), color='Origin', shape='Origin' ) @@ -542,7 +542,7 @@ the color scale used for the lines, you can use ``value``, e.g. ``alt.value("red lines + rule -One caution is that ``alt.datum`` and ``alt.value`` do not possess the (newly introduced as of Altair 5.0) method-based attribute setter syntax described in :ref:`method-based-attribute-setting`. If you are using ``alt.datum`` for the y channel encoding (for example) and you wish to use an attribute setter method (e.g., ``scale``), then you should probably be using :class:`YDatum` instead. Here is a simple example. +One caution is that ``alt.datum`` and ``alt.value`` do not possess the (newly introduced as of Altair 5.0) method-based syntax to set channel options described in :ref:`method-based-attribute-setting`. For example, if you are using ``alt.datum`` for the ``y`` channel encoding and you wish to use an option setter method (e.g., ``scale``), then you can use :class:`YDatum` instead. Here is a simple example. .. altair-plot:: @@ -555,7 +555,7 @@ One caution is that ``alt.datum`` and ``alt.value`` do not possess the (newly in bar -If you were to instead use ``y=alt.datum(220).scale(domain=(0,500))``, an ``AttributeError`` would be raised, due to the fact that ``alt.datum(220)`` is simply a Python dictionary and does not possess a ``scale`` attribute. If you insisted on producing the preceding example using ``alt.datum``, one option would be to use ``y=alt.datum(220, scale={"domain": (0,500)})``. Nevertheless, the ``alt.YDatum`` approach is strongly preferred to this "by-hand" approach of supplying a dictionary to ``scale``. As one benefit, tab-completions are available using the ``alt.YDatum`` approach. For example, typing ``alt.YDatum(220).scale(do`` and hitting ``tab`` in an environment such as JupyterLab will offer ``domain``, ``domainMax``, ``domainMid``, and ``domainMin`` as possible completions. +If you were to instead use ``y=alt.datum(220).scale(domain=(0,500))``, an ``AttributeError`` would be raised, due to the fact that ``alt.datum(220)`` simply returns a Python dictionary and does not possess a ``scale`` attribute. If you insisted on producing the preceding example using ``alt.datum``, one option would be to use ``y=alt.datum(220, scale={"domain": (0,500)})``. Nevertheless, the ``alt.YDatum`` approach is strongly preferred to this "by-hand" approach of supplying a dictionary to ``scale``. As one benefit, tab-completions are available using the ``alt.YDatum`` approach. For example, typing ``alt.YDatum(220).scale(do`` and hitting ``tab`` in an environment such as JupyterLab will offer ``domain``, ``domainMax``, ``domainMid``, and ``domainMin`` as possible completions. .. toctree:: :hidden: From d7d48064c56797c3e5883103664a84b13f50ec7c Mon Sep 17 00:00:00 2001 From: mattijn Date: Sat, 31 Dec 2022 10:55:33 +0100 Subject: [PATCH 24/26] include attribute_syntax charts in tests --- altair/examples/attribute_syntax/__init__.py | 16 ++++++++++++++++ altair/examples/tests/test_examples.py | 17 +++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 altair/examples/attribute_syntax/__init__.py diff --git a/altair/examples/attribute_syntax/__init__.py b/altair/examples/attribute_syntax/__init__.py new file mode 100644 index 000000000..5046eda13 --- /dev/null +++ b/altair/examples/attribute_syntax/__init__.py @@ -0,0 +1,16 @@ +import os + + +def iter_attribute_syntax(): + """Iterate over the examples in this directory. + + Each item is a dict with the following keys: + - "name" : the unique name of the example + - "filename" : the full file path to the example + """ + attribute_syntax_dir = os.path.abspath(os.path.dirname(__file__)) + for filename in os.listdir(attribute_syntax_dir): + name, ext = os.path.splitext(filename) + if name.startswith("_") or ext != ".py": + continue + yield {"name": name, "filename": os.path.join(attribute_syntax_dir, filename)} diff --git a/altair/examples/tests/test_examples.py b/altair/examples/tests/test_examples.py index 125539946..6495232e6 100644 --- a/altair/examples/tests/test_examples.py +++ b/altair/examples/tests/test_examples.py @@ -1,10 +1,12 @@ import io +from itertools import chain import pkgutil import pytest from altair.utils.execeval import eval_block from altair import examples +from altair.examples import attribute_syntax try: import altair_saver # noqa: F401 @@ -24,7 +26,16 @@ def iter_example_filenames(): yield modname + ".py" -@pytest.mark.parametrize("filename", iter_example_filenames()) +def iter_attribute_syntax_filenames(): + for importer, modname, ispkg in pkgutil.iter_modules(attribute_syntax.__path__): + if ispkg or modname.startswith("_"): + continue + yield modname + ".py" + + +@pytest.mark.parametrize( + "filename", chain(iter_example_filenames(), iter_attribute_syntax_filenames()) +) def test_examples(filename: str): source = pkgutil.get_data(examples.__name__, filename) chart = eval_block(source) @@ -35,7 +46,9 @@ def test_examples(filename: str): @pytest.mark.parametrize("engine", ["vl-convert", "altair_saver"]) -@pytest.mark.parametrize("filename", iter_example_filenames()) +@pytest.mark.parametrize( + "filename", chain(iter_example_filenames(), iter_attribute_syntax_filenames()) +) def test_render_examples_to_png(engine, filename): if engine == "vl-convert" and vlc is None: pytest.skip("vl_convert not importable; cannot run mimebundle tests") From f30d0374a4bd9f01ae5285e0b3b2d3b3913f5796 Mon Sep 17 00:00:00 2001 From: mattijn Date: Sat, 31 Dec 2022 10:56:04 +0100 Subject: [PATCH 25/26] add pacman chart with datum variant --- .../examples/attribute_syntax/pacman_chart.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 altair/examples/attribute_syntax/pacman_chart.py diff --git a/altair/examples/attribute_syntax/pacman_chart.py b/altair/examples/attribute_syntax/pacman_chart.py new file mode 100644 index 000000000..c6c6f98c6 --- /dev/null +++ b/altair/examples/attribute_syntax/pacman_chart.py @@ -0,0 +1,17 @@ +""" +Pacman Chart +------------ +Chart made using ``mark_arc`` and constant values. +This could also be made using +``alt.Chart(source).mark_arc(color = "gold", theta = (5/8)*np.pi, theta2 = (19/8)*np.pi,radius=100)``. +""" +# category: circular plots + +import numpy as np +import altair as alt + +alt.Chart().mark_arc(color="gold").encode( + theta=alt.ThetaDatum((5 / 8) * np.pi).scale(None), + theta2=alt.Theta2Datum((19 / 8) * np.pi), + radius=alt.RadiusDatum(100).scale(None), +) From 32b039077a66d25a3f087ceb4a8eb5d0566c4519 Mon Sep 17 00:00:00 2001 From: mattijn Date: Sat, 31 Dec 2022 10:56:40 +0100 Subject: [PATCH 26/26] chart had extension missing --- ...abeled => line_with_last_value_labeled.py} | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) rename altair/examples/{line_with_last_value_labeled => line_with_last_value_labeled.py} (57%) diff --git a/altair/examples/line_with_last_value_labeled b/altair/examples/line_with_last_value_labeled.py similarity index 57% rename from altair/examples/line_with_last_value_labeled rename to altair/examples/line_with_last_value_labeled.py index 8793cab29..481f4e044 100644 --- a/altair/examples/line_with_last_value_labeled +++ b/altair/examples/line_with_last_value_labeled.py @@ -11,27 +11,26 @@ source = data.stocks() # Create a common chart object -chart = alt.Chart(source).transform_filter( - alt.datum.symbol != "IBM" # A reducation of the dataset to clarify our example. Not required. -).encode( - color=alt.Color("symbol", legend=None) +chart = ( + alt.Chart(source) + .transform_filter( + alt.datum.symbol != "IBM" + ) # A reduction of the dataset to clarify our example. Not required. + .encode(color=alt.Color("symbol", legend=None)) ) # Draw the line -line = chart.mark_line().encode( - x="date:T", - y="price:Q" -) +line = chart.mark_line().encode(x="date:T", y="price:Q") # Use the `argmax` aggregate to limit the dataset to the final value label = chart.encode( - x=alt.X('max(date):T'), - y=alt.Y('price:Q', aggregate=alt.ArgmaxDef(argmax='date')), - text='symbol' + x=alt.X("max(date):T"), + y=alt.Y("price:Q", aggregate=alt.ArgmaxDef(argmax="date")), + text="symbol", ) # Create a text label -text = label.mark_text(align='left', dx=4) +text = label.mark_text(align="left", dx=4) # Create a circle annotation circle = label.mark_circle()