Skip to content

Use 'rel axis cs' for text with transAxes transform#57

Merged
ErwindeGelder merged 1 commit intoErwindeGelder:mainfrom
krishna-ji:fix/issue-52-rel-axis-cs
Mar 23, 2026
Merged

Use 'rel axis cs' for text with transAxes transform#57
ErwindeGelder merged 1 commit intoErwindeGelder:mainfrom
krishna-ji:fix/issue-52-rel-axis-cs

Conversation

@krishna-ji
Copy link
Copy Markdown
Collaborator

Fixes #52

Problem

When \�x.text()\ uses \ ransform=ax.transAxes, the coordinates are relative to the axes (0–1 range). However, the generated TikZ code was using \�xis cs:\ which interprets them as data coordinates, placing the text at the wrong position.

Before (incorrect):
\\latex
\draw (axis cs:0.05,0.95) node[...]
\\

After (correct):
\\latex
\draw (rel axis cs:0.05,0.95) node[...]
\\

Fix

In _text.py's _get_tikz_pos(), detect when the text object's transform is \�x.transAxes\ and emit
el axis cs:\ instead of \�xis cs:. Updated \ est_fancybox_reference.tex\ (4 occurrences) to match the corrected output.

All tests pass (113/113), ruff and mypy clean.

…der#52)

When ax.text() uses transform=ax.transAxes, the coordinates are relative to the
axes (0-1 range), not data coordinates. The generated TikZ code was incorrectly
using 'axis cs:' which places text at data coordinates. Now correctly uses
'rel axis cs:' for axes-relative positioning.

Updated test_fancybox_reference.tex to match the corrected output.
@ErwindeGelder ErwindeGelder merged commit 8d76db0 into ErwindeGelder:main Mar 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ax.text() relative axes position is not converted correctly by matplot2tikz

2 participants