ManimCommunity / ManimCommunity/manim

Easily animate x and y range in a plot and crop NumberPlane

Open
#3,804 1 comment 0 reactions 0 assignees View on GitHub
new feature
Dominant language
Python
Stars
40.9k
Forks
3.1k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

## Description of proposed feature
I think it would be usefull to be able to something like:
```
plane = always_redraw(lambda:
NumberPlane(
y_range = (0, 5),

)
self.play(plane.y_range(0,2))
```
to be able to animate a new axis. It's kinda like zooming in. Currently we must do something like:

```
class Test(Scene):
def construct(self):
x_max = ValueTracker(5)

plane = always_redraw(lambda:
NumberPlane(
x_range = (0, 7),
y_range = (0, x_max.get_value()),
x_length = 7,
y_length = 5,
axis_config={"include_numbers": True},
)
)

line_graph = always_redraw(lambda:
NumberPlane(
x_range = (0, 7),
y_range = (0, x_max.get_value()),
x_length = 7,
y_length = 5,
axis_config={"include_numbers": True},
).plot_line_graph(
x_values = [0, 1.5, 2, 2.8, 4, 6.25],
y_values = [1, 3, 2.25, 4, 2.5, 1.75],
line_color=WHITE,
vertex_dot_style=dict(stroke_width=3, fill_color=WHITE),
stroke_width = 4,
)
)
self.add(plane)
self.add(line_graph)
self.wait()
self.play(x_max.animate.set_value(2), run_time=1)
self.wait()
```

This was made by the brilliant Uwezi on the discord forum [here](https://discord.com/channels/581738731934056449/1250107037908471858).

result:

https://github.com/ManimCommunity/manim/assets/40211569/624c5308-dd95-436c-9e83-46ef83a03325

I also think `NumberPlane` should crop the lines automatically, when going out of the numberPLane

Contributor guide

Open the contributing guide

Research direction

Start with NumberPlane and its handling of x_range and y_range, then compare it with the always_redraw and ValueTracker approach shown in the issue. Done should provide an animatable way to change the axis ranges and crop lines that extend outside the NumberPlane.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.