@@ -1559,19 +1559,8 @@ def _add_annotation_like(
15591559 subplot_type = refs [0 ].subplot_type ,
15601560 )
15611561 )
1562- '''
1563- if len(refs) == 1 and secondary_y:
1564- raise ValueError(
1565- """
1566- Cannot add {prop_singular} to secondary y-axis of subplot at position ({r}, {c})
1567- because subplot does not have a secondary y-axis""".format(
1568- prop_singular=prop_singular, r=row, c=col
1569- )
1570- )
1571- '''
15721562
1573- #'''
1574- # If the new_object was created with an yref specified, the specified yref should be used otherwise assign the xref from the layout_keys
1563+ # If the new_object was created with an yref specified, the specified yref should be used otherwise assign the xref and yref from the layout_keys
15751564 if new_obj .yref == None or new_obj .yref == "y" :
15761565 if len (refs ) == 1 and secondary_y :
15771566 raise ValueError (
@@ -1582,27 +1571,14 @@ def _add_annotation_like(
15821571 )
15831572 )
15841573 if secondary_y :
1585- yaxis = refs [1 ].layout_keys [1 ]
1586- xaxis = refs [1 ].layout_keys [0 ]
1574+ xaxis , yaxis = refs [1 ].layout_keys
15871575 else :
1588- yaxis = refs [0 ].layout_keys [1 ]
1589- xaxis = refs [0 ].layout_keys [0 ]
1590- yref = yaxis .replace ("axis" , "" )
1591- xref = xaxis .replace ("axis" , "" )
1576+ xaxis , yaxis = refs [0 ].layout_keys
1577+ xref , yref = xaxis .replace ("axis" , "" ), yaxis .replace ("axis" , "" )
15921578 else :
15931579 yref = new_obj .yref
15941580 xaxis = refs [0 ].layout_keys [0 ]
15951581 xref = xaxis .replace ("axis" , "" )
1596- #'''
1597-
1598- """
1599- if secondary_y:
1600- xaxis, yaxis = refs[1].layout_keys
1601- else:
1602- xaxis, yaxis = refs[0].layout_keys
1603- xref, yref = xaxis.replace("axis", ""), yaxis.replace("axis", "")
1604- """
1605-
16061582 # if exclude_empty_subplots is True, check to see if subplot is
16071583 # empty and return if it is
16081584 if exclude_empty_subplots and (
@@ -1625,8 +1601,9 @@ def _add_domain(ax_letter, new_axref):
16251601
16261602 self .layout [prop_plural ] += (new_obj ,)
16271603 # The 'new_obj.xref' and 'new_obj.yref' parameters need to be reset otherwise it
1628- # will appear as if user supplied yref params and will force annotation to
1629- # be on the axis of the last drawn annotation (they all end up on the same axis)
1604+ # will appear as if user supplied yref params when looping through subplots and
1605+ # will force annotation to be on the axis of the last drawn annotation
1606+ # i.e. they all end up on the same axis.
16301607 new_obj .update (xref = None , yref = None )
16311608
16321609 return self
@@ -4084,7 +4061,7 @@ def _process_multiple_axis_spanning_shapes(
40844061 # self.add_{layout_obj} succeeded)
40854062 # however, in the case of a single plot, xref and yref MAY not be
40864063 # specified, IF they are not specified we specify them here so the following routines can work
4087- # (they need to append " domain" to xref or yref)
4064+ # (they need to append " domain" to xref or yref). If they are specified, we leave them alone.
40884065 if self .layout [layout_obj ][- 1 ].xref == None :
40894066 self .layout [layout_obj ][- 1 ].update (xref = "x" )
40904067 # self.layout[layout_obj][-1].update(xref="x")
0 commit comments