Saved Matplotlib plot not displayed or detected
h
PaoloAmoroso

According to the Repl.it documentation it’s possible to save a Matplotlib plot to a file from Python with code such as plt.savefig('plot.png') so that the environment detects the file and displays it in a preview pane. However, this doesn’t seem to work with other Matplotlib-based libraries such as Poliastro.

Poliastro is an astrodynamics Python package that uses Matplotlib’s plotting features. In a fresh Python 3 REPL I install Poliastro from the package manager. Then I evaluate in the REPL the following lines of code on the home page of Poliastro’s documentation site, one after the other:

Finally I evaluate:

From the shell I can see the saved molniya.png plot file with ls or file:

However, the plot is not displayed in a preview pane and the file is missing from the file tree, which doesn’t make it possible to save it locally or otherwise export it from Repl.it.

What am I doing wrong? Is this a Repl.it issue?

You are viewing a single comment. View All
tcheng

@PaoloAmoroso Hi, I find that the only way to consistently get the preview file to show up while using plt.savefig is by changing the main.py. For example: add a comment to the main.py. I don't know why it has to be that way but this is what the tutorial page says "The preview pane will appear whenever the file has been changed." I know it sounds stupid but I am new to this environment. And, I am waiting to hear a better as well.