CoordinateSystemExample Not Working
- Dominant language
- Python
- Stars
- 93.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
### Describe the error
When using the code provided by the CoordinateSystemExample in the documentation, I do not get the results that are displayed in the recorded video. Instead, the lines that are connected to the dot remain in place and do not move with the always_redraw command. Have tried to search for lots of tutorials online but doesn't seem to provide the solution to this problem.
It would be great if someone could provide a solution to this issue.
https://user-images.githubusercontent.com/68827992/172761991-f9456ba7-38b9-414c-bb9b-311f3d0c90be.mp4
### Code and Error
**Code**:
```py
from manimlib import *
class CoordinateSystemExample(Scene):
def construct(self):
axes = Axes(
# x-axis ranges from -1 to 10, with a default step size of 1
x_range=(-1, 10),
# y-axis ranges from -2 to 2 with a step size of 0.5
y_range=(-2, 2, 0.5),
# The axes will be stretched so as to match the specified
# height and width
height=6,
width=10,
# Axes is made of two NumberLine mobjects. You can specify
# their configuration with axis_config
axis_config={
"stroke_color": GREY_A,
"stroke_width": 2,
},
# Alternatively, you can specify configuration for just one
# of them, like this.
y_axis_config={
"include_tip": False,
}
)
# Keyword arguments of add_coordinate_labels can be used to
# configure the DecimalNumber mobjects which it creates and
# adds to the axes
axes.add_coordinate_labels(
font_size=20,
num_decimal_places=1,
)
self.add(axes)
# Axes descends from the CoordinateSystem class, meaning
# you can call call axes.coords_to_point, abbreviated to
# axes.c2p, to associate a set of coordinates with a point,
# like so:
dot = Dot(color=RED)
dot.move_to(axes.c2p(0, 0))
self.play(FadeIn(dot, scale=0.5))
self.play(dot.animate.move_to(axes.c2p(3, 2)))
self.wait()
self.play(dot.animate.move_to(axes.c2p(5, 0.5)))
self.wait()
# Similarly, you can call axes.point_to_coords, or axes.p2c
# print(axes.p2c(dot.get_center()))
# We can draw lines from the axes to better mark the coordinates
# of a given point.
# Here, the always_redraw command means that on each new frame
# the lines will be redrawn
h_line = always_redraw(lambda: axes.get_h_line(dot.get_left()))
v_line = always_redraw(lambda: axes.get_v_line(dot.get_bottom()))
self.play(
ShowCreation(h_line),
ShowCreation(v_line),
)
self.play(dot.animate.move_to(axes.c2p(3, -2)))
self.wait()
self.play(dot.animate.move_to(axes.c2p(1, 1)))
self.wait()
# If we tie the dot to a particular set of coordinates, notice
# that as we move the axes around it respects the coordinate
# system defined by them.
f_always(dot.move_to, lambda: axes.c2p(1, 1))
self.play(
axes.animate.scale(0.75).to_corner(UL),
run_time=2,
)
self.wait()
self.play(FadeOut(VGroup(axes, dot, h_line, v_line)))
# Other coordinate systems you can play around with include
# ThreeDAxes, NumberPlane, and ComplexPlane.
```
**Error**:
Logic error, shown in the video above
### Environment
**OS System**: Windows
**manim version**: master
**python version**: 3.10.5
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue is in the CoordinateSystemExample code from the documentation. The lines h_line and v_line are created with always_redraw but may not be updating correctly. Look at the axes.get_h_line and axes.get_v_line methods in the manim source, likely in the coordinate_systems.py file. Test the example locally to reproduce the bug, then trace why the lines aren't moving with the dot. Check if the lambda functions are capturing the correct dot position or if there's an issue with the always_redraw implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100