Skip to content

Suggestion: add option to specify x-axis limits #18

Description

@willov

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!

Activity

  1. nmalkin commented on Jun 10, 2021

    @nmalkin
    Owner

    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.

  2. willov commented on Jun 10, 2021

    @willov
    Author

    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!

  3. nmalkin commented on Jun 11, 2021

    @nmalkin
    Owner

    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!

  4. maxdeze commented on Sep 7, 2022

    @maxdeze

    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!

  5. nmalkin commented on Sep 8, 2022

    @nmalkin
    Owner

    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.

  6. maxdeze commented on Sep 8, 2022

    @maxdeze

    amazing! thanks

  7. H53-OOF commented on Mar 27, 2024

    @H53-OOF

    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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions