@@ -4234,6 +4234,54 @@ def _process_multiple_axis_spanning_shapes(
42344234 exclude_empty_subplots = exclude_empty_subplots ,
42354235 yref = shape_kwargs .get ("yref" , "y" ),
42364236 )
4237+ elif shape_type == "vrect" :
4238+ # Split kwargs into shape vs legacy annotation_* (which we map to label)
4239+ shape_kwargs , legacy_ann = shapeannotation .split_dict_by_key_prefix (kwargs , "annotation_" )
4240+
4241+ # Build/merge label dict: start with explicit label=..., then copy safe legacy fields
4242+ label_dict = (kwargs .get ("label" ) or {}).copy ()
4243+ if "annotation_text" in legacy_ann and "text" not in label_dict :
4244+ label_dict ["text" ] = legacy_ann ["annotation_text" ]
4245+ if "annotation_font" in legacy_ann and "font" not in label_dict :
4246+ label_dict ["font" ] = legacy_ann ["annotation_font" ]
4247+ if "annotation_textangle" in legacy_ann and "textangle" not in label_dict :
4248+ label_dict ["textangle" ] = legacy_ann ["annotation_textangle" ]
4249+
4250+ # NOTE: Label does not support bgcolor/bordercolor; keep emitting a warning when present
4251+ if "annotation_bgcolor" in legacy_ann or "annotation_bordercolor" in legacy_ann :
4252+ import warnings
4253+ warnings .warn (
4254+ "annotation_bgcolor/annotation_bordercolor are not supported on shape.label "
4255+ "and will be ignored; use label.font/color or a background shape instead." ,
4256+ FutureWarning ,
4257+ )
4258+
4259+ # Build the shape
4260+ shape_to_add = _combine_dicts ([shape_args , shape_kwargs ])
4261+ if label_dict :
4262+ shape_to_add ["label" ] = label_dict
4263+
4264+ # Add the shape
4265+ self .add_shape (
4266+ row = row ,
4267+ col = col ,
4268+ exclude_empty_subplots = exclude_empty_subplots ,
4269+ ** shape_to_add ,
4270+ )
4271+
4272+ # Run legacy annotation logic only if an explicit annotation object was provided
4273+ augmented_annotation = shapeannotation .axis_spanning_shape_annotation (
4274+ annotation , shape_type , shape_args , legacy_ann
4275+ )
4276+ if augmented_annotation is not None :
4277+ self .add_annotation (
4278+ augmented_annotation ,
4279+ row = row ,
4280+ col = col ,
4281+ exclude_empty_subplots = exclude_empty_subplots ,
4282+ yref = shape_kwargs .get ("yref" , "y" ),
4283+ )
4284+
42374285 else :
42384286
42394287 # shapes are always added at the end of the tuple of shapes, so we see
@@ -4357,6 +4405,9 @@ def add_vrect(
43574405 annotation = None ,
43584406 ** kwargs ,
43594407 ):
4408+ # NEW (Step 2): translate legacy annotation_* → label (non-destructive; warns if used)
4409+ kwargs = _coerce_shape_label_from_legacy_annotation_kwargs (kwargs )
4410+
43604411 self ._process_multiple_axis_spanning_shapes (
43614412 dict (type = "rect" , x0 = x0 , x1 = x1 , y0 = 0 , y1 = 1 ),
43624413 row ,
0 commit comments