endangeredoxen / fivecentplots

A Python plotting analgesic
https://endangeredoxen.github.io/fivecentplots
11 stars 6 forks source link

Groups in box plot slides out of their frame #47

Closed KerenHagitStern closed 2 days ago

KerenHagitStern commented 2 years ago

Hi, I noticed that when my group headers don't fit the total plot size, they slide out the frames. Is there a way that the package can fit the plot size/the headers fonts/expend the headers frame, automatically (without an input ) ,so the group headers will be separated well? I attached some examples to illustrate the problem. thanks example_1 example_2 example_3 example_4

endangeredoxen commented 2 years ago

I love this example data set.

The vertical label size should auto-expand to fit the long group names so this might be a bug (will check). I purposely avoided trying to auto-scale the font size in cases like this and hadn't allowed wide labels to expand the width to honor the global setting for ax_size. Perhaps a good compromise is to auto-expand the width unless the user explicitly defines the image size. I will think about it and get back to you

endangeredoxen commented 2 years ago

Disregard my message from 15 min ago. Still investigating

endangeredoxen commented 2 years ago

Just a quick update, you have indeed found a bug. I am working to fix it and will keep you posted.

endangeredoxen commented 2 years ago

OK, I have a bug fix and a new feature for you using pip install fivecentplots==0.5.0b3

By default, fcp boxplots will continue to use a default axes size of [400, 400], giving you something like this (notice the vertical label bug is gone, but the first row of labels is getting squished): default

You still have the option to manually set the ax_size to deal with the labels not fitting horizontally (here I used [700, 400]): manual

Now I give you the option to use ax_size='auto' which attempts to automatically resize ax_size[0] to fit the contents (note, I still consider this "experimental" so your mileage may vary): auto

Let me know if you find any issues with this. Hope this gives you what you need.

KerenHagitStern commented 2 years ago

Thanks a lot! I will try it

endangeredoxen commented 2 years ago

Great. Also note that you no longer need to install the beta version to try this as I've released v0.5.0. So a regular pip install fivecentplots is enough

KerenHagitStern commented 2 years ago

Capture Hi, I tried the auto option and it worked. Can it plot the graph in a way that the X-axis is shortened to a minimum size? for example, if I changed the order of the categories on the x-axis, the ChickenId labels will be printed vertically and not horizontally ( and I prefer they will be printed vertically). thanks

endangeredoxen commented 1 year ago

I will make a ticket for this for a future release. Right now the only option is to make the ax_size small to force the rotation and I don't think this will be perfect in some cases.

endangeredoxen commented 2 days ago

As of v0.6.0, if you want to print vertically with auto scaling, just add box_group_label_rotation=90 to your plot call. Thanks!