I have a jupyter notebook. When I run a (python) cell that produces a plot, the plot is contained within the notebook. If someone downloads the notebook, the image is there. Whether I open the notebook in vs code or in anaconda, I see it. Even if I use it as a jupyter book and generate an .html page from the notebook, the image is there.
However, if I try to insert an image that I've created elsewhere (as a .png), it's really inserting a link to where the image is. When I build a .html page, the image is not there. If I send the .ipynb file to someone else, I have to send along the .png file for it to be visible. I want it to behave exactly like it does if I generate the image within the notebook. So I want it to really be within the notebook file, not just linked from it. All advice I've seen gives instructions for how to give the path to the image. I've seen some suggestion that this will make the image part of the .ipynb file, but in my experience it is not.
Is this possible? It seems it should be given that the system can handle images created by the code.
.pngin the next paragraph, you have to be careful how you do this. The modern way is with attachments. Those will get embedded into the notebook file. You don't say how you are putting your.pngimage file into the ...from IPython.display import Imageto set this up and then point at the image withImage("image.png"). When you run that code cell the image will get displayed and when you save the file if is embed in the document in base64 format. (Here is an example that is a variation on that for using a.gif.) Of course if the image is somewhere on the web you can use%%HTMLcell magic at the start of a cell and point at the image with an html<img=..tag. This won't get embedded and so only useful for things you know won't go missing. (Plus, not for nbconvert.)