Ovito render to matplotlib


I am able to render the pipeline and save to file. But I would like to plot a polygon, which I generate using a different python script. Is there a way to capture the render to Matplotlib? So I can plot both together?
I know I can use overlays to define python functions to plot different things, but the polygon is generated using a complicated and long script.

I am trying to avoid reading the saved PNG and plot over it.

Another question: How can use zoom_all(size=(…)) to plot as close as possible to pipeline cell (LAMMPS simulation boundary)?

Thank you

@utt , can you please help here?

Currently I can give you 4 possible solutions:

  1. You can render into a memory buffer (QImage object) that you may be able to include into matplotlib using the render_image method.

  2. The canonical OVITO solution would be writing a User-defined viewport layer that combines your polygon code and the atomic structure in the OVITO viewport.

  3. Alternatively, you can also build the polygon in the OVITO scene using lines and meshes. This solution is employed in the ring finder extension.

  4. As you suggested, rendering to disk can be an option as well.

We can assist you with transforming your code into the form of an OVITO python viewport overlay. If you have a paid license, you are welcome to contact the OVITO Pro support team by email for specialized support.