Manim: Y labels not displayed left to the y-axe, but down the tick in graphs

Created on 23 Dec 2018  路  6Comments  路  Source: 3b1b/manim

Here is my code:

from big_ol_pile_of_manim_imports import *

class Graf(GraphScene):
    CONFIG = {
        "y_max" : 1,
        "y_min" : -1,
        "x_max" : 1,
        "x_min" : -1,
        "graph_origin" : ORIGIN,
        "x_labeled_nums" : [-1,1],
        "y_labeled_nums" : [-1,1],
    }
    def construct(self):
        self.setup_axes(animate=False)
        graphique = self.get_graph(lambda x : x**2)
        self.add(graphique)
        self.wait()

As you can see in the screenshot, "-1" and "1" for y-axis are displayed below the correspondant tick, not in the left. Why this?

On file mobject/coordinate_systems.py, lines 29-31, I read:

        "y_axis_config": {
            "label_direction": LEFT,
        },

I tried to add these lines in CONFIG of my code, but this change nothing.

Is there a bug in the code? How can I have my labels for y-axis displayed on left?

image

Most helpful comment

Ah, yes, a vestige of an older change I think. What you say is correct.

"Probably 3b1b missed it by accident."

When in doubt, that will almost certainly be the right answer :)

All 6 comments

On the line 104 of scene/graph_scene.py you have

        y_axis = NumberLine(
            x_min=self.y_min,
            x_max=self.y_max,
            unit_size=self.space_unit_to_y,
            tick_frequency=self.y_tick_frequency,
            leftmost_tick=self.y_bottom_tick,
            numbers_with_elongated_ticks=self.y_labeled_nums,
            color=self.axes_color,
            line_to_number_vect=LEFT,
        )

Add: label_direction = LEFT, like

        y_axis = NumberLine(
            x_min=self.y_min,
            x_max=self.y_max,
            unit_size=self.space_unit_to_y,
            tick_frequency=self.y_tick_frequency,
            leftmost_tick=self.y_bottom_tick,
            numbers_with_elongated_ticks=self.y_labeled_nums,
            color=self.axes_color,
            line_to_number_vect=LEFT,
            label_direction = LEFT # <<----------- 
        )

You can see this code in mobject/number_line.py

Thanks, this is correct after the change you suggest. But why this isn't the default?

Probably 3b1b missed it by accident.

I just had the same issue and after an hour of research (but not googling 馃槵) I got to the same solution. However I think I have nailed down the issue more: line_to_number_vect is only ever set but never used, it has probably at some point in the past been partially renamed to label_direction. So a more correct solution would be to not add that line, but replace the one before.

Ah, yes, a vestige of an older change I think. What you say is correct.

"Probably 3b1b missed it by accident."

When in doubt, that will almost certainly be the right answer :)

This issue can probably be closed now

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Sir-Teo picture Sir-Teo  路  6Comments

SuperVegetaSon picture SuperVegetaSon  路  4Comments

Planeuge picture Planeuge  路  6Comments

lkevinzc picture lkevinzc  路  3Comments

WeiruLin picture WeiruLin  路  5Comments