Skip to content

NumberPlane ignoring x_axis_config and y_axis_config setting #4239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
edowson opened this issue May 6, 2025 · 3 comments
Closed

NumberPlane ignoring x_axis_config and y_axis_config setting #4239

edowson opened this issue May 6, 2025 · 3 comments

Comments

@edowson
Copy link

edowson commented May 6, 2025

Description of bug / unexpected behavior

I am trying to get the NumberPlane to display the co-ordinates in steps of 2, but the NumberPlane class ignores the x_axis_config and y_axis_config attributes inherited from the Axes base class

Expected behavior

The NumberPlane should display alternating co-ordinates.

How to reproduce the issue

Code for reproducing the problem
from manim import *
import numpy as np

class NumberPlaneExample(Scene):
    def construct(self):
        number_plane = NumberPlane(
            x_range=[-6, 6, 1],
            y_range=[-6, 6, 1],
            x_length=6,
            y_length=8,
            x_axis_config={"numbers_to_include": np.arange(-6, 6, 2)},
            y_axis_config={"numbers_to_include": np.arange(-6, 6, 2)},
        )

        number_plane.add_coordinates()

        self.add(number_plane)

System specifications

System Details
  • OS: Ubuntu-24.04
  • RAM: 128GB
  • Python version: 3.12
  • Installed modules (provide output from pip list):
Package             Version
------------------- -----------
anyio               4.9.0
av                  13.1.0
backports.tarfile   1.2.0
beautifulsoup4      4.13.4
Brotli              1.1.0
build               1.2.2.post1
CacheControl        0.14.3
certifi             2025.1.31
cffi                1.17.1
charset-normalizer  3.4.2
cleo                2.1.0
click               8.1.8
cloup               3.0.7
colorama            0.4.6
crashtest           0.4.1
cryptography        44.0.3
decorator           5.2.1
distlib             0.3.9
dulwich             0.22.8
exceptiongroup      1.2.2
fastjsonschema      2.21.1
filelock            3.18.0
findpython          0.6.3
glcontext           3.0.0
h11                 0.16.0
h2                  4.2.0
hpack               4.1.0
httpcore            1.0.9
httpx               0.28.1
hyperframe          6.1.0
idna                3.10
importlib_metadata  8.6.1
importlib_resources 6.5.2
installer           0.7.0
isosurfaces         0.1.2
jaraco.classes      3.4.0
jaraco.context      6.0.1
jaraco.functools    4.1.0
jeepney             0.9.0
keyring             25.6.0
manim               0.19.0
ManimPango          0.6.0
mapbox_earcut       1.0.3
markdown-it-py      3.0.0
mdurl               0.1.2
moderngl            5.11.1
moderngl-window     3.1.1
more-itertools      10.7.0
msgpack             1.1.0
networkx            3.4.2
numpy               2.2.5
packaging           25.0
pbs-installer       2025.4.9
pillow              11.1.0
pip                 25.1.1
pkginfo             1.12.1.2
platformdirs        4.3.7
poetry              2.1.2
poetry-core         2.1.2
pycairo             1.28.0
pycparser           2.22
pydub               0.25.1
pyglet              2.1.6
pyglm               2.8.2
Pygments            2.19.1
pyproject_hooks     1.2.0
PySocks             1.7.1
PyYAML              6.0.2
RapidFuzz           3.13.0
requests            2.32.3
requests-toolbelt   1.0.0
rich                14.0.0
scipy               1.15.2
screeninfo          0.8.1
SecretStorage       3.3.3
setuptools          80.1.0
shellingham         1.5.4
skia-pathops        0.8.0.post2
sniffio             1.3.1
soupsieve           2.5
srt                 3.5.3
svgelements         1.9.6
tomli               2.2.1
tomlkit             0.13.2
tqdm                4.67.1
trove-classifiers   2025.5.1.12
typing_extensions   4.13.2
urllib3             2.4.0
virtualenv          20.30.0
watchdog            6.0.0
wheel               0.45.1
zipp                3.21.0
zstandard           0.23.0
@edowson
Copy link
Author

edowson commented May 6, 2025

The image below shows the output of the NumberPlane example:

from manim import *
import numpy as np

class NumberPlaneExample(Scene):
    def construct(self):
        number_plane = NumberPlane(
            x_range=[-6, 6, 1],
            y_range=[-6, 6, 1],
            x_length=6,
            y_length=8,
            x_axis_config={"numbers_to_include": np.arange(-6, 6, 2)},
            y_axis_config={"numbers_to_include": np.arange(-6, 6, 2)},
        )

        number_plane.add_coordinates()

        self.add(number_plane)

Image

As you can see, the it doesn't respect the x or y axis config step in terms of 2 for the range -6 to 6.

If I use the Axis class, it works as intended.

from manim import *

class Graph2DExample(Scene):
    def construct(self):
        ax = Axes(
            x_range=[-6, 6, 1],
            y_range=[-6, 6, 1],
            x_length=6,
            y_length=6,
            x_axis_config={"numbers_to_include": np.arange(-6, 6, 2)},
            y_axis_config={"numbers_to_include": np.arange(-6, 6, 2)},
            tips=False,
        )

        labels = ax.get_axis_labels(
            x_label=Tex(r"$x$"), y_label=Tex(r"$y$")
        )

        self.add(ax, labels)

Image

Q01: Since the NumberPlane class inherits from Axes class, why is it ignoring the x_axis_config and y_axis_config?

@uwezi
Copy link
Contributor

uwezi commented May 6, 2025

so what is the difference between your usage of the Axes() and the NumberPlane()? In the NumberPlane case you added an unnecessary and unhelpful .add_coordinates() which will show all values.

class NumberPlaneExample(Scene):
    def construct(self):
        number_plane = NumberPlane(
            x_range=[-6, 6, 1],
            y_range=[-6, 6, 1],
            x_length=6,
            y_length=8,
            x_axis_config={"numbers_to_include": np.arange(-6, 6, 2)},
            y_axis_config={"numbers_to_include": np.arange(-6, 6, 2)},
        )

        #number_plane.add_coordinates()

        self.add(number_plane)

results in this rendering:

Image

@edowson
Copy link
Author

edowson commented May 6, 2025

Thank you. I wasn't aware

number_plane.add_coordinates()

adds all co-ordinate values.

@edowson edowson closed this as completed May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 New
Development

No branches or pull requests

2 participants