plotly.py icon indicating copy to clipboard operation
plotly.py copied to clipboard

unwanted change in spacing for marginal x and y plots

Open joelostblom opened this issue 6 years ago • 7 comments

Previously, the marginal y plot was closer to the main plot compared to the marginal x plot:

image

After this change, both the marginal plots appear to be as far from the main plot: image

I also increased the distance of both plots a tiny bit over the previous max distance because I think it looks better, but happy to change that if you disagree. The improvement is clearer (but still subtle) when using axes lines and a white background:

Old max: image

New max: image

joelostblom avatar Nov 03 '19 23:11 joelostblom

The failing test seems unrelated to the changes I made.

joelostblom avatar Nov 03 '19 23:11 joelostblom

While I’m not opposed to tweaking these values, please note that the actual physical spacing in the output depends on the height and width of the whole figure, as well as anything that pushes margins, such as tick labels, legends, color bars, multi-line titles etc... it’s going to be hard to claim that one pair of values makes the spacing “equal” in more than a few specific cases ;)

nicolaskruchten avatar Nov 04 '19 00:11 nicolaskruchten

I see, I tested with a few different widths initially but didn't go extreme enough to notice a difference. Just tried it with more than twice the width compared to height and I can see what you mean.

I made a new commit that normalized based on the figure size. It looks good for me, so if you like it and don't any negative implications elsewhere, I can make the change to the other three places as well and drop the previous commits.

joelostblom avatar Nov 04 '19 01:11 joelostblom

where does the 600 come from?

nicolaskruchten avatar Nov 04 '19 02:11 nicolaskruchten

That's the value I used for width and height when I optimized the distance between the margins and main plot to an arbitrary value that I thought looked good (0.012). So now it will adjust this value based on the figure size.

It doesn't look perfect and could be adjusted to account for legends changing the effective width of the plot, but the principle works. Both the plots below look good with a square 600x600, but changes differently when elongated.

Without adjustment (much different) image

With adjustment (still quite even) image

joelostblom avatar Nov 04 '19 02:11 joelostblom

Rebased

joelostblom avatar Nov 06 '19 16:11 joelostblom

Not sure how to deal with autoscaling figures since their width is not known until the fig is created, which means that the marginal plot spacing can't be calculated before the fig is created.

joelostblom avatar Nov 06 '19 17:11 joelostblom