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

Legend placement overlaps plot #39

Open nmalkin opened 2 years ago

nmalkin commented 2 years ago

By the way, this is how a Plot looks finally. Somehow the legend is shifted into the plotting canvas. If someone has a solution for that as well?!

question_B222

Originally posted by @hbxbgrw7913 in https://github.com/nmalkin/plot-likert/discussions/37#discussioncomment-3812488

nmalkin commented 2 years ago

The positioning of the legend is fairly straightforward to control:

axes = plot_likert.plot_likert(df, scale)

legend = axes.get_legend()
legend.set_bbox_to_anchor((1.5, 1))  # or whatever

This might be a good thing to add to the user guide. (PRs welcome until I get to it myself).

Another option might be to allow passing in additional arguments for the legend, as is done, for example, in 533b5700ec72b5e36c7713afb27d175512113736 in a fork. I'm reluctant to add features that don't seem strictly necessary, but I'm curious if there's a lot of demand for this.

(This is all side-stepping the question of why the legend's placement is off in the first place. I don't know the answer to that, but I'm inclined to keep the default behavior rather than trying to second-guess matplotlib.)

eliotwrobson commented 7 months ago

I think this should be added to the examples as well, being able to control the position of the legend is super useful for generating plots in publications with page limits / other space restrictions.