Skip to content

Commit

Permalink
Merge pull request #25 from nschloe/pass-args
Browse files Browse the repository at this point in the history
pass through text kwargs
  • Loading branch information
nschloe committed Jan 11, 2022
2 parents a17c493 + de88c63 commit 15dc949
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = matplotx
version = 0.3.0
version = 0.3.1
author = Nico Schlömer
author_email = nico.schloemer@gmail.com
description = Useful styles and extensions for Matplotlib
Expand Down
8 changes: 6 additions & 2 deletions src/matplotx/_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ def _move_min_distance(targets: ArrayLike, min_distance: float) -> np.ndarray:
return sol[idx2]


def line_labels(ax=None, min_label_distance: float | str = "auto", alpha: float = 1.0):
def line_labels(
ax=None, min_label_distance: float | str = "auto", alpha: float = 1.0, **text_kwargs
):
ax = ax or plt.gca()

logy = ax.get_yscale() == "log"
Expand Down Expand Up @@ -111,7 +113,9 @@ def line_labels(ax=None, min_label_distance: float | str = "auto", alpha: float
axis_to_data = ax.transAxes + ax.transData.inverted()
xpos = axis_to_data.transform([1.03, 1.0])[0]
for label, ypos, color in zip(labels, targets, colors):
plt.text(xpos, ypos, label, verticalalignment="center", color=color)
plt.text(
xpos, ypos, label, verticalalignment="center", color=color, **text_kwargs
)


def ylabel_top(string: str) -> None:
Expand Down

0 comments on commit 15dc949

Please sign in to comment.