plot-likert
plot-likert copied to clipboard
Suggestion: add option to specify x-axis limits
Thanks for a great package!
It would be great if it was possible to specify the limit on the x-axis. In my case, I am comparing two groups in two different figures, and the scales are different. Which in turn makes it hard to compare the figures. Being able to set the range would be great. Or, at least set it to +/- 100%.
Thanks again!
Thank you for the suggestion! I started thinking a little about how this could be implemented.
My first idea was to see if this could be done entirely with matplotlib handles:
ax1 = plot_likert.plot_likert(data1, scale);
ax2 = plot_likert.plot_likert(data2, scale);
ax2.set_xlim(ax1.get_xlim())
Unfortunately, this only sort of works. The plot is scaled to the right size, but the tick marks look bad (because they're laid out assuming the original scale):
You can actually make them look better with the xtick_interval
argument we introduced a while back.
ax1 = plot_likert.plot_likert(data1, scale);
ax2 = plot_likert.plot_counts(plot_likert.likert_counts(data2, scale),
scale,
xtick_interval=5);
ax2.set_xlim(ax.get_xlim())
I think the main issue with this approach is that the plot will always be left-aligned, so even if it's the same scale as the other plot, it's still not a perfect side-by-side comparison.
Doing this the right way (i.e., allowing the x-axis to be specified as an argument) will probably require messing with how the padding in the generated plot gets calculated.
Thanks for the quick reply!
I agree that the left alignment isn't perfect, but for my application it is perfectly fine.
I had missed the xtick_interval
argument, that surely helps.
Maybe I should open another issue, but having the argument in plot_likert.plot_likert
would be nice as well :)
Again, thanks for a nice package!
Maybe I should open another issue, but having the argument in plot_likert.plot_likert would be nice as well :)
I went ahead and did this; it seemed quite easy to do, no reason not to.
I'll go ahead and keep this issue open for now, I think, in case someone wants to contribute an improvement, or if I get around to it eventually.
Thanks again for the suggestion, and I'm glad the library has been useful for you!
Hi, great package! :) I was wonder if there is any update for the possibility of setting the x axis (when plotting the %) to +/- 100%. (e.g., 100%, 75%, 50%, 25%, 0, 25%, 50%, 75%, 100%)
thanks!
Hi @maxdeze,
I threw together a quick proof-of-concept in 55721a8 on the set-axis-100
branch.
You can try it out yourself with:
pip install git+https://github.com/nmalkin/plot-likert.git@set-axis-100
That code special-cases the [-100%,100%] situation; I'll need to think more about how to make it generic so it works for other custom axis limits.
I welcome PRs on this (from anyone) because I don't know when I'll get to it next.
amazing! thanks
Any chance the above workaround could be added to 0.50? In general a symmetrical axis limits option would be nice since likert plots commonly represent balanced scales. Equal axis limits either side of zero makes them easier to interpret at a glance. Thanks!