@@ -1559,19 +1559,8 @@ def _add_annotation_like(
1559
1559
subplot_type = refs [0 ].subplot_type ,
1560
1560
)
1561
1561
)
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
- '''
1572
1562
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
1575
1564
if new_obj .yref == None or new_obj .yref == "y" :
1576
1565
if len (refs ) == 1 and secondary_y :
1577
1566
raise ValueError (
@@ -1582,27 +1571,14 @@ def _add_annotation_like(
1582
1571
)
1583
1572
)
1584
1573
if secondary_y :
1585
- yaxis = refs [1 ].layout_keys [1 ]
1586
- xaxis = refs [1 ].layout_keys [0 ]
1574
+ xaxis , yaxis = refs [1 ].layout_keys
1587
1575
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" , "" )
1592
1578
else :
1593
1579
yref = new_obj .yref
1594
1580
xaxis = refs [0 ].layout_keys [0 ]
1595
1581
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
-
1606
1582
# if exclude_empty_subplots is True, check to see if subplot is
1607
1583
# empty and return if it is
1608
1584
if exclude_empty_subplots and (
@@ -1625,8 +1601,9 @@ def _add_domain(ax_letter, new_axref):
1625
1601
1626
1602
self .layout [prop_plural ] += (new_obj ,)
1627
1603
# 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.
1630
1607
new_obj .update (xref = None , yref = None )
1631
1608
1632
1609
return self
@@ -4084,7 +4061,7 @@ def _process_multiple_axis_spanning_shapes(
4084
4061
# self.add_{layout_obj} succeeded)
4085
4062
# however, in the case of a single plot, xref and yref MAY not be
4086
4063
# 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.
4088
4065
if self .layout [layout_obj ][- 1 ].xref == None :
4089
4066
self .layout [layout_obj ][- 1 ].update (xref = "x" )
4090
4067
# self.layout[layout_obj][-1].update(xref="x")
0 commit comments