Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Phlya/adjustText
Browse files Browse the repository at this point in the history
  • Loading branch information
Phlya committed May 20, 2018
2 parents 7f4b549 + 1d931b1 commit 273bfd3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
10 changes: 5 additions & 5 deletions adjustText/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def optimally_align_text(x, y, texts, expand=(1., 1.), add_bboxes=[],
if 'y' not in direction:
va = ['']
else:
va = ['bottom', 'top', 'center']
va = ['center', 'top', 'bottom']
alignment = list(product(ha, va))
# coords = np.array(zip(x, y))
for i, text in enumerate(texts):
Expand All @@ -128,8 +128,8 @@ def optimally_align_text(x, y, texts, expand=(1., 1.), add_bboxes=[],
bbox = text.get_window_extent(r).expanded(*expand).\
transformed(ax.transData.inverted())
c = len(get_points_inside_bbox(x, y, bbox))
intersections = [bbox.intersection(bbox, bbox2) for bbox2 in
bboxes+add_bboxes if bbox!=bbox2]
intersections = [bbox.intersection(bbox, bbox2) if i!=j else None
for j, bbox2 in enumerate(bboxes+add_bboxes) ]
intersections = sum([abs(b.width*b.height) if b is not None else 0
for b in intersections])
# Check for out-of-axes position
Expand Down Expand Up @@ -417,7 +417,7 @@ def adjust_text(texts, x=None, y=None, add_objects=None, ax=None,
True
on_basemap (bool): whether your plot uses the basemap library, stops
labels going over the edge of the map; default False
args and kwargs: any arguments will be fed into plt.annotate after
all the optimization is done just for plotting
Expand Down Expand Up @@ -568,7 +568,7 @@ def adjust_text(texts, x=None, y=None, add_objects=None, ax=None,
# are both greater than the max over the last 10 iterations (suggesting a
# failure to converge)
if (qx < precision_x and qy < precision_y) or np.all([qx, qy] >= histm):
break
break
for j, text in enumerate(texts):
a = ax.annotate(text.get_text(), xy = (orig_xy[j]),
xytext=text.get_position(), *args, **kwargs)
Expand Down
3 changes: 3 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ The repository with the issue tracker can be found here: https://github.com/Phly

Examples.ipynb

adjustText is a small library to help you adjust text positions on matplotlib plots to remove or minimize overlaps with each other and data points. The approach is based on overlaps of bounding boxes and iteratively moving them to reduce overlaps. The idea is from the ggrepel package for R/ggplot2 (https://github.com/slowkow/ggrepel).

The repository with the issue tracker can be found here: https://github.com/Phlya/adjustText/
Please see usage examples here: https://github.com/Phlya/adjustText/blob/master/examples/Examples.ipynb

Indices and tables
==================
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from setuptools import setup

setup(name='adjustText',
version='0.7',
version='0.7.1',
description='Iteratively adjust text position in matplotlib plots to minimize overlaps',
author='Ilya Flyamer',
author_email='flyamer@gmail.com',
Expand Down

0 comments on commit 273bfd3

Please sign in to comment.