nmalkin / plot-likert

Python library to visualize results from Likert scale survey questions
BSD 3-Clause "New" or "Revised" License
102 stars 25 forks source link

Plot correct percentages when using plot_counts #17

Closed charliertm closed 2 years ago

charliertm commented 3 years ago

Issue

When using _plotcount to plot a graph, _plotpercentages 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.

Soloution

Modified the _likertpercentage function to be able to accept dataframes which are already counted and then added a conditional in _plotcount to modify the dataframe accordingly if _plotpercentages=True.

nmalkin commented 3 years ago

Hi! Thank you for identifying this issue and submitting a PR for it. I appreciate your taking the time to improve this library!

Issue

When using _plotcount to plot a graph, _plotpercentages 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.

I think the reason this behavior exists is because _plotcounts is honestly mostly an internal method, and the preferred/main method to use for plotting is _plotlikert, which already does the exact conversion you're suggesting:

https://github.com/nmalkin/plot-likert/blob/b83b70dea5805d92008a5c4b27b309b766a2109b/plot_likert/plot_likert.py#L222-L223

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 makes sense.

I'll try out your patch when I have a bit more time, but thanks again for submitting it! I'll try to get around to it soon.

nmalkin commented 2 years ago

I finally got around to fixing this issue in #24 . Thanks again for raising this and proposing a fix!