Comments (5)
Ah I missed what you said "ahead of MPL API". Now I got it how it works, thanks! @neutrinoceros
from yt.
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.
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.
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.
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)
- [4.3.0] Compilation error, PyArrayObject misses some attributes HOT 3
- BUG: annotating a sphere then setting font size in a plot results in a crash HOT 3
- BUG: `urllib.*` modules are never imported HOT 2
- Package Cython-generated *.cpp and *.c files HOT 5
- depth keyword in off-axis projections with sph particles has no effect? HOT 4
- yt.add_field with units=yt.dimensions.length does not work HOT 4
- `get_psize` struggles with weirdly-shaped arrays
- error using annotate_contour with exodus II data HOT 8
- DOCS: Notebooks are blank HOT 6
- MNT: automatic issues for nightly failures are broken
- Threshold by a different field in quivers HOT 1
- resetting Streamlines properties? HOT 1
- STY: switching from black to ruff-format ? HOT 7
- MNT: how should we handle Python 3.10 becoming our oldest supported version ?
- off-axis slice in spherical coordinates HOT 7
- can't read openPMD files that use the ADIOS2 format HOT 4
- Problems with the particle_trajectories documentation/module (1/2) HOT 3
- Problems with the particle_trajectories documentation/module (2/2) HOT 2
- pooch HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yt.