Skip to content

Commit

Permalink
Allow directly specifying bboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
Phlya committed Mar 12, 2019
1 parent a8a0527 commit 1feb1ae
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion adjustText/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import numpy as np
from operator import itemgetter
from matplotlib.path import get_path_collection_extents
import matplotlib

if sys.version_info >= (3, 0):
xrange = range
Expand Down Expand Up @@ -58,6 +59,8 @@ def get_text_position(text, ax=None):
def get_bboxes(objs, r, expand, ax):
if ax is None:
ax = plt.gca()
if all([isinstance(obj, matplotlib.transforms.BboxBase) for obj in objs]):
return objs
try:
return [i.get_window_extent(r).expanded(*expand).transformed(ax.\
transData.inverted()) for i in objs]
Expand Down Expand Up @@ -416,7 +419,8 @@ def adjust_text(texts, x=None, y=None, add_objects=None, ax=None,
coordinates
add_objects : list or PathCollection
a list of additional matplotlib objects to avoid; they must have a
`.get_window_extent()` method; alternatively, a PathCollection.
`.get_window_extent()` method; alternatively, a PathCollection or a
list of Bbox objects.
ax : matplotlib axe, default is current axe (plt.gca())
axe object with the plot
expand_text : array_like, default (1.05, 1.2)
Expand Down

1 comment on commit 1feb1ae

@Phlya
Copy link
Owner Author

@Phlya Phlya commented on 1feb1ae Apr 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, this wasn't great actually, since it breaks the PathCollection feature...

Please sign in to comment.