plot-likert icon indicating copy to clipboard operation
plot-likert copied to clipboard

Suggestion: add option to specify x-axis limits

Open willov opened this issue 3 years ago • 7 comments

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!

willov avatar Jun 09 '21 13:06 willov

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): image

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())

image

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.

nmalkin avatar Jun 10 '21 06:06 nmalkin

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!

willov avatar Jun 10 '21 14:06 willov

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!

nmalkin avatar Jun 11 '21 06:06 nmalkin

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!

maxdeze avatar Sep 07 '22 20:09 maxdeze

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.

nmalkin avatar Sep 08 '22 04:09 nmalkin

amazing! thanks

maxdeze avatar Sep 08 '22 16:09 maxdeze

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!

H53-OOF avatar Mar 27 '24 16:03 H53-OOF