1) Instead of positioning annotations above the highest datapoint in the relevant categories, 'calculate_ymaxes' determines the highest drawn object in each x axis category.
2) Converts all coordinates into axes coordinates, and works in those coordinates. This allows for annotations to be drawn independently of the y axis scale. (This feature was very important for the paper I'm working on).
When working in axes coordinates, I've found that setting the ylim to the max y-axis point 1.05 is better than 1.03, but that's an aesthetic decision.
Otherwise I've done my best to minimize the changes from your code.
This update does a few things:
1) Instead of positioning annotations above the highest datapoint in the relevant categories, 'calculate_ymaxes' determines the highest drawn object in each x axis category.
2) Converts all coordinates into axes coordinates, and works in those coordinates. This allows for annotations to be drawn independently of the y axis scale. (This feature was very important for the paper I'm working on).
When working in axes coordinates, I've found that setting the ylim to the max y-axis point 1.05 is better than 1.03, but that's an aesthetic decision.
Otherwise I've done my best to minimize the changes from your code.