Skip to content

Commit

Permalink
Refine annotateplot kwarg handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mmore500 committed Dec 26, 2023
1 parent eede40d commit 15eab76
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/outset/patched/_annotateplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def annotateplot(
y: str,
text: str,
ax: typing.Optional[plt.Axes] = None,
adjust_text_kws: typing.Mapping = frozendict(),
adjusttext_kws: typing.Mapping = frozendict(),
**kwargs: dict,
) -> plt.Axes:
"""Annotate a plot coordinates with text labels, then apply adjustText to
Expand All @@ -32,7 +32,7 @@ def annotateplot(
The name of the column in `data` to use for text values.
ax : Optional[plt.Axes], default None
The matplotlib Axes object to draw the plot onto, if provided.
adjust_text_kws : Mapping, default {}
adjusttext_kws : Mapping, default {}
Additional keyword arguments forward to adjustText.
**kwargs : dict
Additional keyword arguments forward to seaborn's regplot.
Expand All @@ -49,10 +49,13 @@ def annotateplot(
if ax is None:
ax = plt.gca()

kwargs.pop("legend", None)
kwargs.pop("label", None)

texts = [
ax.text(row[x], row[y], row[text], **kwargs)
for _idx, row in data.iterrows()
]
adjust_text(texts, ax=ax, **adjust_text_kws)
adjust_text(texts, ax=ax, **adjusttext_kws)

return ax

0 comments on commit 15eab76

Please sign in to comment.