@@ -4281,7 +4281,56 @@ def _process_multiple_axis_spanning_shapes(
42814281 exclude_empty_subplots = exclude_empty_subplots ,
42824282 yref = shape_kwargs .get ("yref" , "y" ),
42834283 )
4284+
4285+ elif shape_type == "hrect" :
4286+ # Split kwargs into shape vs legacy annotation_* (which we map to label)
4287+ shape_kwargs , legacy_ann = shapeannotation .split_dict_by_key_prefix (kwargs , "annotation_" )
4288+
4289+ # Build/merge label dict: start with explicit label=..., then copy safe legacy fields
4290+ label_dict = (kwargs .get ("label" ) or {}).copy ()
4291+ if "annotation_text" in legacy_ann and "text" not in label_dict :
4292+ label_dict ["text" ] = legacy_ann ["annotation_text" ]
4293+ if "annotation_font" in legacy_ann and "font" not in label_dict :
4294+ label_dict ["font" ] = legacy_ann ["annotation_font" ]
4295+ if "annotation_textangle" in legacy_ann and "textangle" not in label_dict :
4296+ label_dict ["textangle" ] = legacy_ann ["annotation_textangle" ]
4297+
4298+ # NOTE: Label does not support bgcolor/bordercolor; warn when present
4299+ if "annotation_bgcolor" in legacy_ann or "annotation_bordercolor" in legacy_ann :
4300+ import warnings
4301+ warnings .warn (
4302+ "annotation_bgcolor/annotation_bordercolor are not supported on shape.label "
4303+ "and will be ignored; use label.font/color or a background shape instead." ,
4304+ FutureWarning ,
4305+ )
4306+
4307+ # Build the shape
4308+ shape_to_add = _combine_dicts ([shape_args , shape_kwargs ])
4309+ if label_dict :
4310+ shape_to_add ["label" ] = label_dict
42844311
4312+ # Add the shape
4313+ self .add_shape (
4314+ row = row ,
4315+ col = col ,
4316+ exclude_empty_subplots = exclude_empty_subplots ,
4317+ ** shape_to_add ,
4318+ )
4319+
4320+ # Run legacy annotation logic only if an explicit annotation object was provided
4321+ augmented_annotation = shapeannotation .axis_spanning_shape_annotation (
4322+ annotation , shape_type , shape_args , legacy_ann
4323+ )
4324+ if augmented_annotation is not None :
4325+ self .add_annotation (
4326+ augmented_annotation ,
4327+ row = row ,
4328+ col = col ,
4329+ exclude_empty_subplots = exclude_empty_subplots ,
4330+ xref = shape_kwargs .get ("xref" , "x" ),
4331+ )
4332+
4333+
42854334 else :
42864335
42874336 # shapes are always added at the end of the tuple of shapes, so we see
@@ -4431,6 +4480,9 @@ def add_hrect(
44314480 annotation = None ,
44324481 ** kwargs ,
44334482 ):
4483+ # NEW (Step 2): translate legacy annotation_* → label (non-destructive; warns if used)
4484+ kwargs = _coerce_shape_label_from_legacy_annotation_kwargs (kwargs )
4485+
44344486 self ._process_multiple_axis_spanning_shapes (
44354487 dict (type = "rect" , x0 = 0 , x1 = 1 , y0 = y0 , y1 = y1 ),
44364488 row ,
0 commit comments