ManimCommunity / ManimCommunity/manim

get_axis_labels() not working properly for rotated axis

Open
#4,281 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
40.9k
Forks
3.1k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

## Description of bug / unexpected behavior

get_axis_labels() is the function needed to add labels to the axes. It is not working properly when I rotated the axis.
This problem is especially prominent for:
1. Rotations not integer multiple of PI/2
2. Axis that has only positive direction

## Expected behavior

The labels should be near the tips of each axis.

## How to reproduce the issue

Case 1

```py
class GetAxisLabelsExample(Scene):
def construct(self):
ax = Axes(x_length=4, y_length=4).rotate(0.5*PI/2)
labels = ax.get_axis_labels(Tex("x"), Text("y"))
self.add(ax, labels)
```

Case 2

```py
class GetAxisLabelsExample(Scene):
def construct(self):
ax = Axes(x_length=4, y_length=4, x_range=[0, 12]).rotate(2*PI/2)
labels = ax.get_axis_labels(Tex("x"), Text("y"))
self.add(ax, labels)
```

## Additional media files

Case 1

![Image](https://github.com/user-attachments/assets/82d37332-1c19-4cfa-8b09-2d77b881a60e)

Case 2

![Image](https://github.com/user-attachments/assets/e1baaacd-0cf7-4d20-9407-7973cef83b69)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at Axes.get_axis_labels and run the two Python reproductions in the issue, comparing label placement after rotation and with x_range=[0, 12]. Done means both labels are positioned near their axis tips for arbitrary rotations and axes with only positive direction.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.