Is it possible to move the axis position? I want to plot more scientific data, e.g., voltage over time. If some of the voltage values are negative they cross the x axis which makes the plot look bad as I also want to have labels for x and y.
See the following code:
from manim import *
class LineGraphExample(Scene):
def construct(self):
plane = NumberPlane(
x_range = (0, 7),
y_range = (-2, 5),
x_length = 7,
y_length = 5,
axis_config={"include_numbers": True},
)
plane.center()
y_label = plane.get_y_axis_label("\\text{Voltage [V]}", edge=LEFT, direction=LEFT, buff=0.4)
x_label = plane.get_x_axis_label("\\text{Time [$\mu$s]}", edge=DOWN, direction=DOWN, buff=0.4)
self.add(y_label)
self.add(x_label)
line_graph = plane.plot_line_graph(
x_values = [0, 1.5, 2, 2.8, 4, 6.25],
y_values = [1, 3, 2.25, -1.5, 2.5, 1.75],
line_color=GOLD_E,
vertex_dot_style=dict(stroke_width=3, fill_color=PURPLE),
stroke_width = 4,
)
self.add(plane, line_graph)
Here, I would like the x axes to intersect with y at -2 (i.e., having the x axes at the bottom of the graph).
It appears that this is not directly possible using the NumberPlane parameters. I found a kind of hacky approach to solve this:
I removed the -2 tick on the y-axis and added the 0 one. Hope this is fine.