Skip to content
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

plot shrinks faster than x_axis when changing x_range #3975

Open
e-dervieux opened this issue Oct 24, 2024 · 0 comments
Open

plot shrinks faster than x_axis when changing x_range #3975

e-dervieux opened this issue Oct 24, 2024 · 0 comments

Comments

@e-dervieux
Copy link

e-dervieux commented Oct 24, 2024

Description of bug / unexpected behavior

When plotting a function in an axis environment, if the x_axis range is changed using a ValueTracker, and the same ValueTracker is used as function range, the function does not plot on the expected range. Here is a MWE:

from manim import *

class VaryingSupportSineWave(MovingCameraScene):

    def construct(self):
        
        x_max = ValueTracker(10)
        ax = always_redraw(lambda: Axes(
            x_range=[0, x_max.get_value(), 1],
            y_range=[-1, 1, 0.5],
            x_length=x_max.get_value()
        ).to_edge(LEFT))
        self.add(ax)
        
        sine_wave = always_redraw(lambda: ax.plot(lambda x: np.sin(x),
                                                  x_range=(0, x_max.get_value())))
        
        self.play(Create(sine_wave))
        self.play(x_max.animate.set_value(6))
        self.wait(0.5)

Expected behavior

  • the axes are drawn and the x_axis is ten units wide
  • the sine wave is added and plotted up to ten units
  • the x_axis shrinks down to six units, each unit is still one munit wide (no scaling effect, the axis only gets shorter), and the sine wave is now drawn also on only six units

image

Actual behavior

  • the axes are drawn and the x_axis is ten units wide
  • the sine wave is added and plotted up to ten units
  • the x_axis shrinks down to six units, each unit is still one munit wide (no scaling effect, the axis only gets shorter), BUT the sine wave is now drawn on only about 3.5 units, and it has been scaled down!

image

Logs

Terminal output
Manim Community v0.18.1

[10/24/24 09:00:31] ERROR                                                 module_ops.py:92
                                VaryingSupportSineWave is not in the                      
                             script                                                       
                                                                                          
                    DEBUG    Hashing ...                                    hashing.py:352
                    DEBUG    Hashing done in 0.006856 s.                    hashing.py:364
                    DEBUG    Hash generated :                               hashing.py:367
                             3348903278_2543047096_4133455014                             
                    INFO     Animation 0 : Using cached data (hash :  cairo_renderer.py:88
                             3348903278_2543047096_4133455014)                            
                    DEBUG    List of the first few animation hashes   cairo_renderer.py:97
                             of the scene:                                                
                             ['3348903278_2543047096_4133455014']                         
                    DEBUG    Hashing ...                                    hashing.py:352
                    DEBUG    Hashing done in 0.006311 s.                    hashing.py:364
                    DEBUG    Hash generated :                               hashing.py:367
                             2784548031_3175177803_765666942                              
                    INFO     Animation 1 : Using cached data (hash :  cairo_renderer.py:88
                             2784548031_3175177803_765666942)                             
                    DEBUG    List of the first few animation hashes   cairo_renderer.py:97
                             of the scene:                                                
                             ['3348903278_2543047096_4133455014',                         
                             '2784548031_3175177803_765666942']                           
                    DEBUG    Animation with empty mobject                 animation.py:175
                    DEBUG    Hashing ...                                    hashing.py:352
                    DEBUG    Hashing done in 0.006665 s.                    hashing.py:364
                    DEBUG    Hash generated :                               hashing.py:367
                             2784548031_774239770_1835257284                              
                    INFO     Animation 2 : Using cached data (hash :  cairo_renderer.py:88
                             2784548031_774239770_1835257284)                             
                    DEBUG    List of the first few animation hashes   cairo_renderer.py:97
                             of the scene:                                                
                             ['3348903278_2543047096_4133455014',                         
                             '2784548031_3175177803_765666942',                           
                             '2784548031_774239770_1835257284']                           
                    INFO     Combining to Movie file.             scene_file_writer.py:617
                    DEBUG    Partial movie files to combine (3    scene_file_writer.py:561
                             files):                                                      
                             ['/Users/username/Library/Cl                         
                             oudStorage/someplace/Python/                         
                             18_manim/src/media/videos/test_script/                         
                             720p30/partial_movie_files/VaryingAm                         
                             plitudeSineWave/3348903278_254304709                         
                             6_4133455014.mp4',                                           
                             '/Users/username/Library/Clo                         
                             udStorage/someplace/Python/1                         
                             8_manim/src/media/videos/test_script/7                         
                             20p30/partial_movie_files/VaryingAmp                         
                             litudeSineWave/2784548031_3175177803                         
                             _765666942.mp4',                                             
                             '/Users/username/Library/Clo                         
                             udStorage/someplace/Python/1                         
                             8_manim/src/media/videos/test_script/7                         
                             20p30/partial_movie_files/VaryingAmp                         
                             litudeSineWave/2784548031_774239770_                         
                             1835257284.mp4']                                             
                    INFO                                          scene_file_writer.py:737
                             File ready at                                                
                             '/Users/username/Library/Clo                         
                             udStorage/someplace/Python/1                         
                             8_manim/src/media/videos/test_script/7                         
                             20p30/VaryingAmplitudeSineWave.mp4'                          
                                                                                          
                    INFO     Rendered VaryingAmplitudeSineWave                scene.py:247
                             Played 3 animations                                          
[10/24/24 09:00:32] INFO     Previewed File at:                            file_ops.py:231
                             '/Users/username/Library/CloudStorage                
                             /someplace/Python/18_manim/src/media/                
                             videos/test_script/720p30/VaryingAmplitudeSineW                
                             ave.mp4'                                                     

System specifications

System Details
  • OS: macOS Sonoma 14.2.1 (23C71)
  • RAM: 32Go
  • Python version (python/py/python3 --version): 3.12
  • Installed modules (provide output from pip list):
Package                   Version
------------------------- ---------------
ansi2html                 1.9.1
anyio                     4.2.0
appnope                   0.1.3
argon2-cffi               23.1.0
argon2-cffi-bindings      21.2.0
arrow                     1.3.0
asttokens                 2.4.1
async-lru                 2.0.4
attrs                     23.2.0
Babel                     2.14.0
beautifulsoup4            4.12.3
bleach                    6.1.0
blinker                   1.7.0
Brotli                    1.1.0
certifi                   2023.11.17
cffi                      1.16.0
charset-normalizer        3.3.2
click                     8.1.7
cloup                     3.0.5
colour                    0.1.5
comm                      0.2.1
contourpy                 1.2.0
cycler                    0.11.0
Cython                    3.0.11
dash                      2.14.2
dash-core-components      2.0.0
dash-html-components      2.0.0
dash-table                5.0.0
dataclasses               0.6
debugpy                   1.8.0
decorator                 5.1.1
defusedxml                0.7.1
et-xmlfile                1.1.0
executing                 2.0.1
fastjsonschema            2.19.1
Flask                     3.0.0
fonttools                 4.25.0
fqdn                      1.5.1
glcontext                 3.0.0
idna                      3.6
importlib-metadata        7.0.0
ipykernel                 6.29.0
ipython                   8.20.0
ipywidgets                8.1.1
isoduration               20.11.0
isosurfaces               0.1.2
itsdangerous              2.1.2
jedi                      0.19.1
Jinja2                    3.1.2
joblib                    1.3.2
json5                     0.9.14
jsonpickle                3.0.2
jsonpointer               2.4
jsonschema                4.21.1
jsonschema-specifications 2023.12.1
jupyter                   1.0.0
jupyter_client            8.6.0
jupyter-console           6.6.3
jupyter_core              5.7.1
jupyter-events            0.9.0
jupyter-lsp               2.2.2
jupyter_server            2.12.5
jupyter_server_terminals  0.5.2
jupyterlab                4.0.11
jupyterlab_pygments       0.3.0
jupyterlab_server         2.25.2
jupyterlab-widgets        3.0.9
kiwisolver                1.4.4
manim                     0.18.1
ManimPango                0.4.4
mapbox_earcut             1.0.2
markdown-it-py            3.0.0
MarkupSafe                2.1.3
matplotlib                3.8.2
matplotlib-inline         0.1.6
mdurl                     0.1.2
mistune                   3.0.2
moderngl                  5.11.1
moderngl-window           2.4.6
mpmath                    1.3.0
multipledispatch          1.0.0
munkres                   1.1.4
music-tag                 0.4.3
mutagen                   1.47.0
nbclient                  0.9.0
nbconvert                 7.14.2
nbformat                  5.9.2
nest-asyncio              1.5.8
networkx                  3.3
notebook                  7.0.7
notebook_shim             0.2.3
numpy                     1.26.2
openpyxl                  3.1.2
overrides                 7.7.0
packaging                 23.1
pandas                    2.1.4
pandas-flavor             0.6.0
pandocfilters             1.5.1
parso                     0.8.3
patsy                     0.5.6
pexpect                   4.9.0
Pillow                    10.0.1
pingouin                  0.5.5
pip                       23.3.1
platformdirs              4.1.0
plotly                    5.18.0
prometheus-client         0.19.0
prompt-toolkit            3.0.43
psutil                    5.9.8
ptyprocess                0.7.0
pure-eval                 0.2.2
pycairo                   1.27.0
pycparser                 2.21
pycryptodomex             3.20.0
pydub                     0.25.1
pyglet                    2.0.17
Pygments                  2.17.2
pyobjc-core               10.3.1
pyobjc-framework-Cocoa    10.3.1
PyOpenGL                  3.1.7
pyparsing                 3.0.9
PyQt5                     5.15.10
PyQt5-Qt5                 5.15.11
PyQt5-sip                 12.13.0
PyQt6                     6.6.1
PyQt6-Qt6                 6.6.1
PyQt6-sip                 13.6.0
pyrr                      0.10.3
pyserial                  3.5
python-dateutil           2.8.2
python-json-logger        2.0.7
pytz                      2023.3.post1
PyYAML                    6.0.1
pyzmq                     25.1.2
qtconsole                 5.5.1
QtPy                      2.4.1
referencing               0.32.1
requests                  2.32.3
retrying                  1.3.4
rfc3339-validator         0.1.4
rfc3986-validator         0.1.1
rich                      13.9.2
rpds-py                   0.17.1
scikit-learn              1.3.2
scipy                     1.11.4
screeninfo                0.8.1
seaborn                   0.13.2
Send2Trash                1.8.2
setuptools                68.0.0
si-prefix                 1.3.3
six                       1.16.0
skia-pathops              0.8.0.post1
sniffio                   1.3.0
soundfile                 0.12.1
soupsieve                 2.5
srt                       3.5.3
stack-data                0.6.3
statsmodels               0.14.3
sty                       1.0.6
svgelements               1.9.6
sympy                     1.13.3
tabulate                  0.9.0
tenacity                  8.2.3
terminado                 0.18.0
threadpoolctl             3.2.0
tikzplotlib               0.10.1
tinycss2                  1.2.1
tornado                   6.3.3
tqdm                      4.66.5
traitlets                 5.14.1
types-python-dateutil     2.8.19.20240106
typing_extensions         4.9.0
tzdata                    2023.3
uri-template              1.3.0
urllib3                   2.1.0
validators                0.34.0
watchdog                  5.0.3
wcwidth                   0.2.13
webcolors                 1.13
webencodings              0.5.1
websocket-client          1.7.0
websockets                12.0
Werkzeug                  3.0.1
wheel                     0.41.2
widgetsnbextension        4.0.9
xarray                    2024.9.0
yt-dlp                    2024.7.25
zipp                      3.17.0
LaTeX details
  • LaTeX distribution: TeX Live 2023
  • Installed LaTeX packages: no other than TeX Live 2023 base install.

Note: the issue has been evoked here.

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

1 participant