-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Fixed issue with bar plots not stacking correctly when 'stacked' and 'subplots' are used together #61340
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
base: main
Are you sure you want to change the base?
Conversation
…clarification if it matters)
self.subplots: list[Any] | ||
if self.subplots: | ||
subplots_flag = 1 | ||
else: | ||
subplots_flag = 0 | ||
|
||
if subplots_flag & self.stacked: |
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.
self.subplots: list[Any] | |
if self.subplots: | |
subplots_flag = 1 | |
else: | |
subplots_flag = 0 | |
if subplots_flag & self.stacked: | |
if self.subplots and self.stacked: |
sub_range = range(len(self.subplots)) | ||
ss_temp = { | ||
x: self.subplots[x] for x in sub_range if len(self.subplots[x]) > 1 | ||
} | ||
for k, v in ss_temp.items(): | ||
for x in v: | ||
_stacked_subplots_ind.setdefault(int(x), k) | ||
|
||
_stacked_subplots_offsets.append([0, 0]) | ||
|
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.
sub_range = range(len(self.subplots)) | |
ss_temp = { | |
x: self.subplots[x] for x in sub_range if len(self.subplots[x]) > 1 | |
} | |
for k, v in ss_temp.items(): | |
for x in v: | |
_stacked_subplots_ind.setdefault(int(x), k) | |
_stacked_subplots_offsets.append([0, 0]) | |
for i, sub_plot in enumerate(self.subplots): | |
if len(sub_plot) <= 1: | |
continue | |
for plot in sub_plot: | |
_stacked_subplots_ind[int(plot)] = i | |
_stacked_subplots_offsets.append([0, 0]) |
@pytest.fixture(scope="class") | ||
def BSS_data(): | ||
return np.random.default_rng(3).integers(0, 100, 5) | ||
|
||
|
||
@pytest.fixture(scope="class") | ||
def BSS_df(BSS_data) -> DataFrame: | ||
BSS_df = DataFrame( | ||
{"A": BSS_data, "B": BSS_data[::-1], "C": BSS_data[0], "D": BSS_data[-1]} | ||
) | ||
return BSS_df |
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.
@pytest.fixture(scope="class") | |
def BSS_data(): | |
return np.random.default_rng(3).integers(0, 100, 5) | |
@pytest.fixture(scope="class") | |
def BSS_df(BSS_data) -> DataFrame: | |
BSS_df = DataFrame( | |
{"A": BSS_data, "B": BSS_data[::-1], "C": BSS_data[0], "D": BSS_data[-1]} | |
) | |
return BSS_df | |
@pytest.fixture | |
def BSS_data(): | |
return np.random.default_rng(3).integers(0, 100, 5) | |
@pytest.fixture | |
def BSS_df(BSS_data) -> DataFrame: | |
return DataFrame( | |
{"A": BSS_data, "B": BSS_data[::-1], "C": BSS_data[0], "D": BSS_data[-1]} | |
) |
Also what's the BBS abbreviation? It would be better to use a clearer name
sliced_df = subplot_sliced_by_source[i] | ||
if i == 0: | ||
# Checks that the bar chart starts y=0 | ||
assert (sliced_df["y_coord"] == 0).all |
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.
assert (sliced_df["y_coord"] == 0).all | |
assert (sliced_df["y_coord"] == 0).all() |
?
) | ||
|
||
|
||
class TestBarSubplotStacked: |
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 remove the test class? We're moving away from using this style
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.Added check for when stacked and subplots are used in conjunction for bar plots. And logic dictating offsets for individual subplots to account for plots with non-concurrent columns being graphed.
Currently, does not take into account column order in subplot entry (eg: (A, B) vs (B, A)) when stacking