Plot a figure in the tutorial

Hi,

I’ve been through the first steps of the openmc tutorial : Modeling a Pin-Cell — OpenMC Documentation

However at step [23], where we are supposed to plot the hemisphere:

universe.plot(width=(2.0, 2.0))
image

I can’t see the drawing displaying on my screen.

Is there a command like universe.show() to actually plot the drawing ?

thank you for your help,
Djinekioule

In your Jupyter notebook, try putting %matplotlib inline in the very first cell to indicate that Matplotlib images should be displayed inline.

Ok thank you,
However, if I’m editing python on another text editor (let’s say vim) is there another way to display the figure when I run the python code ?
But maybe it’s out of the openmc topics.

[EDIT]
I’ve done something like this:
image

and download it from my “my_openmc” container to windows:

Is there an easier way to just display figure while being in the container prompt terminal ?
(I’ve tried eog “eog pin_cell.png” but it doesn’t work)

If you’re not inside a Jupyter notebook, you need to run:

import matplotlib.pyplot as plt
...
universe.plot(...)
plt.show()  # <-- causes figure to be displayed

Yes, I’ve also tried this option, unfortunately I’ve got no figure output :confused:
Maybe my session is not correctly configured ? ( I’m pretty noob with docker :slight_smile: )

Thank you for your help

@Djinekioule Did you try matplotlib.use() function to render figures inside docker?

import matplotlib
matplotlib.use('qt5agg')

No I didn’t know this command !
But it still doesn’t work, I’ve got several error messages by calling matplotlib.use(‘qt5agg’), it look like it requires the ‘PyQt5’ package. But even after installing the pyqt5 package I still get an error message, " ‘Qt5Agg’ requires the ‘qt5’ interactive framework, as ‘headless’ is currently running".

After some investigations the problem has been faced here https://www.py4u.net/discuss/220645
I’ve enabled the terminal.integrated.inheritEnv but now docker fails to launch lol
(it’s in french, sorry “Pour pouvoir utiliser cette fonctionnalité, la console hérité doit être désactivée” means ->“For this functionnallity to be used, consol inheritence has to be disabled”)

image

@Djinekioule Sorry, I couldn’t come up with any workable solution. If you really want this, please post on https://discourse.matplotlib.org/

Ok thank you for your help anyway :slight_smile: