Skip to content

Commit 7463f60

Browse files
committed
update (r, c) convention:
- make start cell corresp to (1, 1)
1 parent 964daff commit 7463f60

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

plotly/tools.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ def _checks(item, defaults):
760760
# Default inset key-values
761761
if insets:
762762
INSET_defaults = dict(
763-
cell=(0, 0),
763+
cell=(1, 1),
764764
is_3d=False,
765765
l=0.0,
766766
w='to_end',
@@ -793,71 +793,71 @@ def _checks(item, defaults):
793793

794794
# Function handling logic around 2d axis labels
795795
# Returns 'x{}' | 'y{}'
796-
def _get_label(x_or_y, row, col, cnt, shared_axes):
796+
def _get_label(x_or_y, r, c, cnt, shared_axes):
797797
# Default label (given strictly by cnt)
798798
label = "{x_or_y}{cnt}".format(x_or_y=x_or_y, cnt=cnt)
799799

800800
if isinstance(shared_axes, bool):
801801
if shared_axes:
802802
if x_or_y == 'x':
803-
label = "{x_or_y}{c}".format(x_or_y=x_or_y, c=col+1)
803+
label = "{x_or_y}{c}".format(x_or_y=x_or_y, c=c+1)
804804
if x_or_y == 'y':
805-
label = "{x_or_y}{r}".format(x_or_y=x_or_y, r=row+1)
805+
label = "{x_or_y}{r}".format(x_or_y=x_or_y, r=r+1)
806806

807807
if isinstance(shared_axes, list):
808808
if isinstance(shared_axes[0], tuple):
809809
shared_axes = [shared_axes] # TODO put this elsewhere
810810
for shared_axis in shared_axes:
811-
if (row, col) in shared_axis:
811+
if (r+1, c+1) in shared_axis:
812812
label = {
813-
'x': "x{0}".format(shared_axis[0][1]+1),
814-
'y': "y{0}".format(shared_axis[0][0]+1)
813+
'x': "x{0}".format(shared_axis[0][1]),
814+
'y': "y{0}".format(shared_axis[0][0])
815815
}[x_or_y]
816816

817817
return label
818818

819819
# Function handling logic around 2d axis anchors
820820
# Return 'x{}' | 'y{}' | 'free' | False
821-
def _get_anchors(row, col, x_cnt, y_cnt, shared_xaxes, shared_yaxes):
821+
def _get_anchors(r, c, x_cnt, y_cnt, shared_xaxes, shared_yaxes):
822822
# Default anchors (give strictly by cnt)
823823
x_anchor = "y{y_cnt}".format(y_cnt=y_cnt)
824824
y_anchor = "x{x_cnt}".format(x_cnt=x_cnt)
825825

826826
if isinstance(shared_xaxes, bool):
827827
if shared_xaxes:
828-
if row == 0:
829-
x_anchor = "y{col_cnt}".format(col_cnt=col+1)
828+
if r == 0:
829+
x_anchor = "y{col_cnt}".format(col_cnt=c+1)
830830
else:
831831
x_anchor = False
832832
y_anchor = 'free'
833-
if shared_yaxes and col > 0: # TODO covers all cases?
833+
if shared_yaxes and c > 0: # TODO covers all cases?
834834
y_anchor = False
835835
return x_anchor, y_anchor
836836

837837
elif isinstance(shared_xaxes, list):
838838
if isinstance(shared_xaxes[0], tuple):
839839
shared_xaxes = [shared_xaxes] # TODO put this elsewhere
840840
for shared_xaxis in shared_xaxes:
841-
if (row, col) in shared_xaxis[1:]:
841+
if (r+1, c+1) in shared_xaxis[1:]:
842842
x_anchor = False
843843
y_anchor = 'free' # TODO covers all cases?
844844

845845
if isinstance(shared_yaxes, bool):
846846
if shared_yaxes:
847-
if col == 0:
848-
y_anchor = "x{row_cnt}".format(row_cnt=row+1)
847+
if c == 0:
848+
y_anchor = "x{row_cnt}".format(row_cnt=r+1)
849849
else:
850850
y_anchor = False
851851
x_anchor = 'free'
852-
if shared_xaxes and row > 0: # TODO covers all cases?
852+
if shared_xaxes and r > 0: # TODO covers all cases?
853853
x_anchor = False
854854
return x_anchor, y_anchor
855855

856856
elif isinstance(shared_yaxes, list):
857857
if isinstance(shared_yaxes[0], tuple):
858858
shared_yaxes = [shared_yaxes] # TODO put this elsewhere
859859
for shared_yaxis in shared_yaxes:
860-
if (row, col) in shared_yaxis[1:]:
860+
if (r+1, c+1) in shared_yaxis[1:]:
861861
y_anchor = False
862862
x_anchor = 'free' # TODO covers all cases?
863863

0 commit comments

Comments
 (0)