Mi chiedo se sia possibile generare output HTML statici e grafici inline utilizzando Bokeh nello stesso notebook IPython. Quello che sto vedendo attualmente è che una volta chiamata o output_notebook()
o output_file("myfile.html")
sono bloccato usando quella modalità di output. Ad esempio, se inizialmente utilizzo output_notebook
, successivamente chiamare output_file
non crea un file di output.È possibile passare da output_notebook a output_file in una sessione di notebook IPython con Bokeh?
È possibile passare da output_notebook a output_file in una sessione di notebook IPython con Bokeh?
risposta
reset_output()
prima del prossimo output_notebook
o output_file
chiamata lavora almeno nella versione 0.10.0.
# cell 1
from bokeh.plotting import figure, show, output_notebook, output_file, reset_output
p = figure(width=300, height=300)
p.line(range(5), range(5))
output_notebook()
show(p)
# cell 2
reset_output()
output_file('foo.html')
show(p)
# cell 3
reset_output()
output_notebook()
show(p)
Primo e terzo spettacolo in notebook, secondi spettacoli nel browser.
È possibile creare un HTML statico utilizzando il seguente codice (adattato dall'esempio here):
from bokeh.plotting import figure
from bokeh.resources import CDN
from bokeh.embed import file_html
plot = figure()
plot.circle([1,2], [3,4])
html = file_html(plot, CDN, "my plot")
with open('test.html', 'w') as f:
f.write(html)
Questo funziona senza problemi in combinazione con output_notebook()
Ho una situazione simile, ma i miei grafici sono creati in un ciclo. È possibile aggiungere ogni trama per creare un singolo file html con tutti i file su di esso? – mad5245
Scusate per il trascurare. Stavo pensando molto a quello. Per riferimento è sufficiente cambiare la 'w' in 'a' proprio come con qualsiasi file. – mad5245
- 1. bokeh con widget di IPython Notebook: figure addizionali in riproduzione
- 2. È effettivamente possibile passare dati (callback) da mpld3 a ipython?
- 3. Notebook IPython con optirun
- 4. È possibile accedere da remoto a un notebook IPython senza utilizzare il plotting in linea?
- 5. Collegamenti tra notebook IPython
- 6. utilizzando rpy2 con i notebook IPython?
- 7. display SVG in IPython notebook da una funzione
- 8. Stampa dell'anteprima di iPython Notebook a colori?
- 9. Download CSV da un notebook iPython
- 10. Come fare riferimento a una cella notebook IPython in markdown?
- 11. scorciatoie vi in notebook ipython
- 12. Notebook IPython: qual è la codifica predefinita?
- 13. Avvio del notebook ipython
- 14. Esegui notebook ipython da un server remoto
- 15. Notebook IPython su Heroku
- 16. Bokeh: passa le vars a CustomJS per i widget
- 17. È possibile creare il raggruppamento di celle di input in IPython Notebook?
- 18. Notebook Ipython: dov'è jupyter_notebook_config.py in Mac?
- 19. Come si sopprime l'output in IPython Notebook?
- 20. "Salva come" nel notebook IPython
- 21. Errore Pyzmq nel notebook IPython
- 22. Escaping dollar sign in ipython notebook
- 23. equivalente di raw_input nel notebook Ipython
- 24. Stile CSS di HTML nell'output Notebook IPython
- 25. Riavvia il kernel ipython con un comando da una cella
- 26. come salvare l'output di una cella nel notebook iPython?
- 27. Esiste un'API per notebook IPython?
- 28. Come chiudere correttamente Notebook IPython?
- 29. Carica dati locali nel server notebook IPython
- 30. Download file di trigger nel notebook iPython
Una correzione: Sembra che inizialmente possa usare 'output_file' seguito da' output_notebook', ma non viceversa. –