python-ternary icon indicating copy to clipboard operation
python-ternary copied to clipboard

Reposition tick labels

Open czlee opened this issue 5 years ago • 1 comments

This one's a little more involved and changes functionality a little, in a way that I should point out is arguably not backwards-compatible, if other users have been picky about their tick label positioning.

My idea here is to anchor (or align) the tick labels by the point that's "closest" to where the tick is, rather than the horizontal center and vertical baseline. This way, particularly with the parallel axis labels, if lengths of labels of different ticks are different (e.g. "0", "0.25", "0.5"), the length doesn't affect how far the label appears from the tick, and (sometimes) whether it "spills" onto the plot.

For example, on the left axis, when the ticks run horizontally, this PR makes them anchored right-middle, and when they run right-parallel, it makes them anchored right-bottom.

Because the anchors have moved to the nearest point, their offsets could be reduced a little.

There might be other considerations this risks breaking that I don't know about, so happy to discuss. I've just picked up on this package and am using it to plot probability simplex heatmaps, so thanks so much for making your project available!

To illustrate the effect:

Before image

After image

Before, clockwise image

After, clockwise image

czlee avatar Mar 23 '20 02:03 czlee

Hi, it looks pretty good on the notebook of examples. However on the example in colorbar_kwargs.py the lower labels intersect the lower axis labels so I think we'd need to adjust the offsets on those as well in line with what you've done here.

marcharper avatar Mar 30 '20 06:03 marcharper