In Webots with a Python controller: I have a PNG-File (640x480) which displays a Matrix-Numpy-Array-figure which is getting produced by my code. I would like to display it on an Display overlay. But display.imageLoad(filename.png) produces no visable image on the Display. It seems to load it, because if i remove the ".png" than it produces an error. What can I change to see it?

Hier is my world file: https://github.com/MaximilianKlein92/Webots-Breitenberg/commit/25f6645ee3c4184fe4b46559735472f17f07ec24

Here my Controller: https://github.com/MaximilianKlein92/Webots-Breitenberg/commit/59ceafb0833c29ffbb7e7b7562b0fba4dae587be

And here a short Video: https://webots.cloud/AcRB4U4?upload=webots


1 Answer 1


The Display.imageLoad simply reads the image from file and store it internally in Webots. To actually show the image in the Display, you have to call Display.imagePaste that will copy the image data into the Display board.

I saw in your code that you tried to call Display.imagePaste but the arguments are wrong:

  • the first expected argument is the image reference returned by Display.imageLoad (and not the image file name)
  • the second (x) and third (y) arguments specify the top left position of the copied image in the Display board: so if you set x=imageWidth, y=imageHeight, the figure won't be visible in the Display board

So the correct code will be something like:

figure_ref = display.imageLoad(filename+".jpeg")
display.imagePaste(figure_ref, 0, 0, False)

For reference, here is the link to the complete Display API documentation.

Just note that you should also change the line 305 where the figure is saved and specify the extension by adding +'.jpeg':

plt.savefig(filename + '.jpeg',format="jpeg")

Disclaimer: I am a Webots developer working at Cyberbotics.

  • $\begingroup$ Thank you very much! this was the problem! Greate Answer :) $\endgroup$
    – HackMack
    Jan 31, 2023 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.