Skip to content
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

Improve handling of percentages for plot_counts #24

Merged
merged 5 commits into from
Dec 28, 2021
Merged

Conversation

nmalkin
Copy link
Owner

@nmalkin nmalkin commented Dec 28, 2021

Issue #17 pointed out an awkwardness in the behavior of the plot_counts function:

When using plot_count to plot a graph, plot_percentages seemed to only just add a percentage sign on to the end of the number of respondents rather than convert the number of responses to percentages.

As I wrote at the time:

the reason this behavior exists is because plot_counts is honestly mostly an internal method […]
That said, since plot_counts is being exposed, I agree that its behavior is confusing and unexpected, so I think the change you're proposing [computing percentages] makes sense.

To address this issue, the commits that are part of this PR make the following changes to the plot_counts function:

  1. Deprecate the plot_percentage parameter with a warning (but keep it around for backwards compatibility)
  2. Add new parameter compute_percentages that converts the count to percentages

Note that these changes only affect plot_counts. plot_likert.plot_likert, which is the primary entry point of this library, has not changed.

As pointed out in #17, its behavior is somewhat confusing:
> plot_percentages seemed to only just add a percentage sign on to the end of the number of respondents rather than convert the number of responses to percentages

As a first step towards fixing that problem, this commit gives the
argument a (hopefully) more descriptive name.
In this second part of the fix for #17, a new more intuitive behavior is
introduced:
given a set of pre-computed counts, setting the `compute_percentages` option
will re-calculate the counts as percentages, and display the plot accordingly.
and deprecate `likert_percentages`

Commit 45e992a added a new `compute_percentages` argument that allows
aggregation of response counts into percentages.
The current commit adds a warning, like the one we already had for the
`plot_likert` function, if the counts vary between questions
(making percentages misleading).

With this change, the new argument can be used instead of the
`likert_percentages` function, so that function is now deprecated.
While it's supposed to be internal, I'm keeping it around in case anyone
was using it directly.
I changed my mind about its necessity:
people who still need this behavior can keep using `plot_percentage`
(but face the deprecation warning),
whereas new users should be encouraged to use `compute_percentages`,
since its aggregation is harmless for fully precomputed percentages.
@nmalkin nmalkin changed the title Better handling of percentages for plot_counts Improve handling of percentages for plot_counts Dec 28, 2021
@nmalkin nmalkin merged commit eaff1e5 into master Dec 28, 2021
@nmalkin nmalkin deleted the plot-percentage branch December 28, 2021 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant