Repository navigation
System Names Missing from ProportionShift #47
Description
When I plot other kinds of divergence such as JSD, the system names are written next to purple and orange bars at the top of the plot. However, with ProportionShift those top bars are unlabeled (see attached).
Comparing the two get_shift_graph definitions in shifts.py the main differences appears to be that JSD passes all_pos_contributions while ProportionShift does not, and ProportionShift passes an explicit show_total=False. Here's the JSD definition:
shifterator/shifterator/shifts.py
Lines 396 to 424 in ce7f00b
| def get_shift_graph( | |
| self, | |
| top_n=50, | |
| show_plot=True, | |
| detailed=False, | |
| text_size_inset=True, | |
| cumulative_inset=True, | |
| title=None, | |
| filename=None, | |
| **kwargs | |
| ): | |
| if self.alpha == 1 and self.reference_value == 0: | |
| all_pos_contributions = True | |
| else: | |
| all_pos_contributions = False | |
| if title is None: | |
| title = "" | |
| ax = super().get_shift_graph( | |
| top_n=top_n, | |
| text_size_inset=text_size_inset, | |
| cumulative_inset=cumulative_inset, | |
| detailed=detailed, | |
| show_plot=show_plot, | |
| filename=filename, | |
| title=title, | |
| all_pos_contributions=all_pos_contributions, | |
| **kwargs | |
| ) | |
| return ax |
And the ProportionShift definition:
shifterator/shifterator/shifts.py
Lines 114 to 138 in ce7f00b
| def get_shift_graph( | |
| self, | |
| top_n=50, | |
| show_plot=True, | |
| detailed=False, | |
| text_size_inset=True, | |
| cumulative_inset=True, | |
| title=None, | |
| filename=None, | |
| **kwargs | |
| ): | |
| if title is None: | |
| title = "" | |
| ax = super().get_shift_graph( | |
| top_n=top_n, | |
| text_size_inset=text_size_inset, | |
| cumulative_inset=cumulative_inset, | |
| detailed=detailed, | |
| show_plot=show_plot, | |
| filename=filename, | |
| show_total=False, | |
| title=title, | |
| **kwargs | |
| ) | |
| return ax |
When I add all_pos_contributions=True to ProportionShift it does add the system names as desired, but also breaks the plot and puts all bars on the right-hand side. I haven't been able to track down exactly where the system names are added to the plot, but hopefully this can help with debugging.
Activity
andyreagan commentedon Jun 30, 2026
@milo-trujillo I had claude take a swing at this in #48, and it looks good to me. Could you install from the branch and confirm it looks right on your end?
Force a reinstall over an existing copy with
pip install --force-reinstall --no-deps.To know that the pip install worked, confirm that you have version 0.5.1 via
import shifterator; print(shifterator.__version__).Then re-run your
ProportionShift(...).get_shift_graph(...).milo-trujillo commentedon Jun 30, 2026
I've confirmed that this has the desired effect on my end.
If the fix is separating out "top bar system names" from the logic of "flip bar direction for metrics where sign indicates directionality," would it make more sense to remove the system name logic from
all_pos_contributionsand setlabel_total_with_system_namesto default true for all plot types?Additionally, the pull request doesn't add the new parameter to the plotting documentation ;)
In any case, thanks so much for your help!
andyreagan commentedon Aug 27, 2026
Thanks for confirming! Good catch on the docs — added
label_total_with_system_namesto the plotting options in #48 (87b5546).Merge pull request #48 from ryanjgallagher/fix/issue-47-proportionshi…