manim icon indicating copy to clipboard operation
manim copied to clipboard

`~.get_axis_labels()` implemented for `Axes`, but not `ThreeDAxes`

Open alembcke opened this issue 3 years ago • 2 comments

Description of bug / unexpected behavior

Shouldn't the method ~.get_axis_labels() work for both Axes and ThreeDAxes? At the moment it only works for Axes and returns an error when trying to use with ThreeDAxes. This doesn't make sense, it should work for both.

Expected behavior

The method ~.get_axis_labels() should work the same for both Axes and ThreeDAxes.

How to reproduce the issue

Code for reproducing the problem
class Test(ThreeDScene):
    def construct(self):
        axes = ThreeDAxes()
        axes_labels = axes.get_axis_labels(Tex("x"), Tex("y"), Tex("z"))
        self.add(VGroup(axes, axes_labels))

Logs

Terminal output
Manim Community v0.15.2

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│                                                                                                  │
│ /home/alexlembcke/.local/lib/python3.10/site-packages/manim/cli/render/commands.py:118 in render │
│                                                                                                  │
│   115 │   │   for SceneClass in scene_classes_from_file(file):                                   │
│   116 │   │   │   try:                                                                           │
│   117 │   │   │   │   scene = SceneClass()                                                       │
│ ❱ 118 │   │   │   │   scene.render()                                                             │
│   119 │   │   │   except Exception:                                                              │
│   120 │   │   │   │   error_console.print_exception()                                            │
│   121 │   │   │   │   sys.exit(1)                                                                │
│ /home/alexlembcke/.local/lib/python3.10/site-packages/manim/scene/scene.py:222 in render         │
│                                                                                                  │
│    219 │   │   """                                                                               │
│    220 │   │   self.setup()                                                                      │
│    221 │   │   try:                                                                              │
│ ❱  222 │   │   │   self.construct()                                                              │
│    223 │   │   except EndSceneEarlyException:                                                    │
│    224 │   │   │   pass                                                                          │
│    225 │   │   except RerunSceneException as e:                                                  │
│                                                                                                  │
│ /home/alexlembcke/video.py:877 in construct                     │
│                                                                                                  │
│   874 class Test(ThreeDScene):                                                                   │
│   875 │   def construct(self):                                                                   │
│   876 │   │   axes = ThreeDAxes()                                                                │
│ ❱ 877 │   │   axes_labels = axes.get_axis_labels(Tex("x"), Tex("y"), Tex("z"))                  │
│   878 │   │   self.add(VGroup(axes, axes_labels))                                                │
│   879                                                                                            │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: CoordinateSystem.get_axis_labels() takes from 1 to 3 positional arguments but 4 were given

System specifications

System Details
  • OS (with version, e.g., Windows 10 v2004 or macOS 10.15 (Catalina)):
  • RAM:
  • Python version (python/py/python3 --version):
  • Installed modules (provide output from pip list):
PASTE HERE
LaTeX details
  • LaTeX distribution (e.g. TeX Live 2020):
  • Installed LaTeX packages:
FFMPEG

Output of ffmpeg -version:

PASTE HERE

Additional comments

alembcke avatar Jun 26 '22 18:06 alembcke

Yes and no, there is a degree of freedom associated with labels in 3D space. Do you want them always facing the camera, aligned with the axis itself. At the end of the axis or above that you can always read it no matter the orientation.

In 2D it's simply just putting it beside the axis. So unless you propose a system which is sticking to the original function behavior but also solves the problem, sure we can add it!

MrDiver avatar Jun 26 '22 19:06 MrDiver

I would say there should be reasonable defaults for those parameters. You can already add numbers to the axes by passing axis_config = {"include_numbers": True} when creating ThreeDAxes, so why not use the defaults used by the numbers?

alembcke avatar Jun 26 '22 19:06 alembcke