FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix `clabel` manual argument not accepting unit-typed coordinates by aman-coder03 · Pull Request #31278 · matplotlib/matplotlib · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 2 additions & 0 deletions lib/matplotlib/contour.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,8 @@ def add_label_near(self, x, y, inline=True, inline_spacing=5,
if transform is None:
transform = self.axes.transData
if transform:
Comment thread
story645 marked this conversation as resolved.
x = self.axes.convert_xunits(x)
y = self.axes.convert_yunits(y)
x, y = transform.transform((x, y))

idx_level_min, idx_vtx_min, proj = self._find_nearest_contour(
Expand Down
15 changes: 13 additions & 2 deletions lib/matplotlib/tests/test_datetime.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,22 @@ def test_bxp(self):
ax.xaxis.set_major_formatter(mpl.dates.DateFormatter("%Y-%m-%d"))
ax.set_title('Box plot with datetime data')

@pytest.mark.xfail(reason="Test for clabel not written yet")
@mpl.style.context("default")
def test_clabel(self):
dates = [datetime.datetime(2023, 10, 1) + datetime.timedelta(days=i)
for i in range(10)]
x = np.arange(-10.0, 5.0, 0.5)
X, Y = np.meshgrid(x, dates)
Z = np.arange(X.size).reshape(X.shape)

fig, ax = plt.subplots()
ax.clabel(...)
CS = ax.contour(X, Y, Z)
labels = ax.clabel(CS, manual=[(x[0], dates[0])])
assert len(labels) == 1
assert labels[0].get_text() == '0'
x_pos, y_pos = labels[0].get_position()
assert x_pos == pytest.approx(-10.0, abs=1e-3)
assert y_pos == pytest.approx(mpl.dates.date2num(dates[0]), abs=1e-3)

@mpl.style.context("default")
def test_contour(self):
Expand Down
Loading

Back | FazBrowse Home | New Git URL