Git Product home page Git Product logo

Comments (5)

xshaokun avatar xshaokun commented on June 22, 2024 1

Ah I missed what you said "ahead of MPL API". Now I got it how it works, thanks! @neutrinoceros

from yt.

neutrinoceros avatar neutrinoceros commented on June 22, 2024 1

I think what you described is an unfortunate but known limitation of yt's callback system: in general, using yt API to modify a plot has, by design, no immediate effect, and most computations and IO operations are delayed until the figure is rendered (in a REPL, or when render or save are called). This system helps a lot with performance, however it works by redrawing the entire figure each time a render is needed, which means that any modification done directly with MPL (bypassing yt) will be erased on the next render.
I never could find a nice way to better support this usage, but if we could better integrate with MPL API, it'd make part of yt's completely redundant and lead to great simplifications.

from yt.

neutrinoceros avatar neutrinoceros commented on June 22, 2024

hi @xshaokun , thanks for noticing !

I think what's happening is that the image (and most of the plot) is lazy-generated at some point ™️ between calls to MPL API and .save(), which invalidates everything done by the script.
It's trivially fixed by forcing rendering at a controlled point ahead of MPL API calls with slc.render(), though I wonder why this wasn't necessary when this example was written.

from yt.

xshaokun avatar xshaokun commented on June 22, 2024

Thank @neutrinoceros for your reply!

It's trivially fixed by forcing rendering at a controlled point ahead of MPL API calls with slc.render(), though I wonder why this wasn't necessary when this example was written.

It can produce an expected output in docs. However, if some plot window methods are called, it will break again. For example, methods like slc.set_origin("lower-center-window") or slc.annotate_timestamp() will make slc.save() and fig.savefig("sloshing.png") giving different results. Output from the former only applied the modifications by plot_window methods, while output from the latter only applied the modifications by matplotlib engine, even if slc.render() is used (actually it will overwrite the modifications from matplotlib engine).

It seems like I was modifying different objects with different approaches. Does it make sense?

from yt.

xshaokun avatar xshaokun commented on June 22, 2024

I'm okay with the current design as soon as I know what's happening inside the box. I have to dive into the source code to figure out that render will erase old axes, which should be told explicitly in docs so that users can use MPL API properly. Many thanks for your help!

from yt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.