python - Exporting jupyter notebook to pdf with offline plotly graph; missing graphs -


i trying create pdf export of lesson plans , use plotly offline graphs. in mwe below, plot display in jupyter notebook not show when export pdf. export using file-->download as-->pdf via latex (.pdf).

i'd make pdf instead of using html. understand might take step convert html export pdf, wondering if there more direct route (a code modification?) allow me export directly through file-->download as-->pdf via latex (.pdf)

from plotly.offline import download_plotlyjs, init_notebook_mode, iplot init_notebook_mode(connected=true) import plotly.graph_objs go  data = [go.scatter(     x=[1, 2, 3],     y=[3, 2, 1]) ] iplot(data) 

i think because plotly graphs svg objects , generated javascript, dont have export pdf working in jupyter notebook, unable check , confirm answer.

plotly offline not have show image, can use plotly online this, free generate graphs,

you need create online account, need paste username , api key plotly website (api key can found in settings).

note: please check in plotly if plots shared in public or private, not responsible plots becoming public.

anyway give image output of graph, , can export pdf

code:

import plotly import plotly.graph_objs go  plotly.plotly.sign_in('<<username goes here>>', '<<api key goes here>>') trace = go.bar(x=[2, 4, 6], y= [10, 12, 15]) data = [trace] layout = go.layout(title='a simple plot', width=800, height=640) fig = go.figure(data=data, layout=layout)  plotly.plotly.image.save_as(fig, filename='a-simple-plot.png')  ipython.display import image image('a-simple-plot.png') 

Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -