2017-12-23 4 views
2

Ich versuche, eine PNG-Datei mit pyplot.savegig Funktion zu speichern. Funktioniert gut, wenn es über die jupyter Web-Benutzeroberfläche ausgeführt wird. Aber wenn ich es über die Befehlszeile ausführe, wird das Image nicht erstellt.jupyter nbconvert speichert keine Datei für matplotlib.savefig

Befehlszeile: jupyter nbconvert FILE_NAME.ipynb

Code:

import matplotlib.pyplot as plt 

# evenly sampled time at 200ms intervals 
t = np.arange(0., 5., 0.2) 

# red dashes, blue squares and green triangles 
plt.plot(t, t, 'r--', t, t**2, 'bs', t, t**3, 'g^') 

plt.savefig('test-image-2.png', format='png', dpi=1200) 

plt.show() 

Was mache ich hier falsch?

Antwort

1

Sie benötigen Befehl zu ändern:

jupyter nbconvert FILE_NAME.ipynb --execute

Ansonsten gut, keine der Zellen ausgeführt werden.

$ jupyter nbconvert --help 
This application is used to convert notebook files (*.ipynb) to various other 
formats. 

WARNING: THE COMMANDLINE INTERFACE MAY CHANGE IN FUTURE RELEASES. 

Options 
------- 

Arguments that take values are actually convenience aliases to full 
Configurables, whose aliases are listed on the help line. For more information 
on full configurables, see '--help-all'. 

--debug 
    set log level to logging.DEBUG (maximize logging output) 
--generate-config 
    generate default config file 
-y 
    Answer yes to any questions instead of prompting. 
--execute 
    Execute the notebook prior to export. 
[snip] 
:

Dies wird in der Dokumentation mit jupyter nbconvert --help gezeigt angegeben

Verwandte Themen