-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
subplot titles respecting row_width and column_width #1245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
c613ccc
e83207a
b9ec250
13f491e
54d9065
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1001,7 +1001,6 @@ def _checks(item, defaults): | |
) for c in col_seq | ||
] for r in row_seq | ||
] | ||
|
||
# [grid_ref] Initialize the grid and insets' axis-reference lists | ||
grid_ref = [[None for c in range(cols)] for r in range(rows)] | ||
insets_ref = [None for inset in range(len(insets))] if insets else None | ||
|
@@ -1080,6 +1079,7 @@ def _get_anchors(r, c, x_cnt, y_cnt, shared_xaxes, shared_yaxes): | |
return x_anchor, y_anchor | ||
|
||
list_of_domains = [] # added for subplot titles | ||
list_of_domains_complete = [] # hold onto every domain used, even if shared axes | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this used anywhere? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nope - I'll ⚡️ |
||
|
||
# Function pasting x/y domains in layout object (2d case) | ||
def _add_domain(layout, x_or_y, label, domain, anchor, position): | ||
|
@@ -1323,20 +1323,33 @@ def _pad(s, cell_len=cell_len): | |
subtitle_pos_x.append(sum(x_domains) / 2) | ||
for y_domains in y_dom: | ||
subtitle_pos_y.append(y_domains[1]) | ||
|
||
# If shared_axes is True the domin of each subplot is not returned so the | ||
# title position must be calculated for each subplot | ||
else: | ||
subtitle_pos_x = [None] * cols | ||
subtitle_pos_y = [None] * rows | ||
delt_x = (x_e - x_s) | ||
x_dom = [layout[k]['domain'] for k in sorted(layout.to_plotly_json().keys()) if 'xaxis' in k] | ||
y_dom = [layout[k]['domain'] for k in sorted(layout.to_plotly_json().keys()) if 'yaxis' in k] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this sort going to break down when there are more than 9 xaxes? e.g. ['xaxis', 'xaxis10', 'xaxis2', 'xaxis3', ...] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. great catch - I'll make sure it's full proof |
||
for index in range(cols): | ||
subtitle_pos_x[index] = ((delt_x / 2) + | ||
((delt_x + horizontal_spacing) * index)) | ||
subtitle_pos_x *= rows | ||
for index in range(rows): | ||
subtitle_pos_y[index] = (1 - ((y_e + vertical_spacing) * index)) | ||
subtitle_pos_y *= cols | ||
subtitle_pos_y = sorted(subtitle_pos_y, reverse=True) | ||
subtitle_pos_x = [] | ||
for x_domains in x_dom: | ||
subtitle_pos_x.append(sum(x_domains) / 2) | ||
subtitle_pos_x *= rows | ||
|
||
if shared_yaxes: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have any tests that specify There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, i'll write one |
||
for index in range(rows): | ||
subtitle_pos_y = [] | ||
for y_domain in y_dom: | ||
subtitle_pos_y.append(y_domain[1]) | ||
subtitle_pos_y *= cols | ||
subtitle_pos_y = sorted(subtitle_pos_y, reverse=True) | ||
|
||
else: | ||
for index in range(rows): | ||
subtitle_pos_y = [] | ||
for y_domain in y_dom: | ||
subtitle_pos_y.append(y_domain[1]) | ||
subtitle_pos_y = sorted(subtitle_pos_y, reverse=True) | ||
subtitle_pos_y *= cols | ||
|
||
plot_titles = [] | ||
for index in range(len(subplot_titles)): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add an image of this expected figure to the PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a png in the file? I am not aware of image tests for this repo but I could be wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I just meant in the GitHub PR so I could see what it looks like 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.