Jupyter笔记本Matplotlib数字在导出的pdf中丢失

阿里斯

在jupyter笔记本中生成pdf时,一切工作正常,但我想将内联图形以及pdf保留在pdf中。

这是我的代码:

%matplotlib notebook
import matplotlib.pyplot as plt
import numpy as np
from IPython.display import set_matplotlib_formats
set_matplotlib_formats('png', 'pdf')

save_figures = True

x = np.arange(0, 20, 0.1)
y = np.sin(x)
plt.figure()
plt.plot(x, y)
if save_figures:
    plt.savefig('test.png')
plt.show()

这些图是内联显示的,但是在pdf中打印的是:

<IPython.core.display.Javascript object>

<IPython.core.display.HTML object>

如果我从Webnbconvert导出或用于从命令行导出到pdf ,则pdf中也会出现相同的内容

我需要调用其他命令才能使其正常工作吗?

米歇尔·林恩·吉尔

如果将更%matplotlib notebook改为%matplotlib inline,则使用jupyter的nbconvert进行PDF导出对我来说很好。%matplotlib notebook神奇的呈现在我怀疑是不是正确的乳胶,它是PDF转换过程中使用认可的交互方式的情节。

另外,如果%matplotlib notebook由于某种原因必须使用,则使用jupyter的nbconvert(jupyter nbconvert --to='html' Test.ipynb导出为HTML似乎可以保留该图。然后,我可以从Web浏览器将此HTML文件打印为PDF,并且该图出现在最终的PDF中。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

将jupyter ipython笔记本导出为pdf

jupyter 笔记本丢失了进口

如何导出整个Jupyter笔记本?

在Jupyter Python笔记本中清除MatPlotLib图

在jupyter笔记本中内联后端的matplotlib配置

matplotlib:在Jupyter笔记本中未显示figimage

将 jupyter 笔记本中的图形转换为 pdf

Jupyter和Bokeh:将Jupyter笔记本导出为pdf时,导出散景图的解决方法

无法将 matplotlib 图导出到 Excel 工作表 --- 使用 matplotlib 到 Excel 在 Jupyter 笔记本中绘制图形

jupyter笔记本中的内存错误

jupyter笔记本中的VS代码?

jupyter笔记本中的内存限制

在jupyter笔记本python中密谋

Jupyter笔记本中的Imagegrid

不同笔记本中的 Jupyter 类?

jupyter笔记本中的打字稿

无法在Jupyter笔记本中绘图

在Firefox中冻结的jupyter笔记本

Jupyter - 将当前的 ipynb 文件导出到笔记本中的 html

R笔记本中数字的输出

无需代码即可将笔记本导出为pdf

如何在绘图时从jupyter笔记本中删除显示的matplotlib输出行

为什么 seaborn/matplotlib 在我的 jupyter 笔记本中的这条线图中的线下方填充?

Jupyter笔记本中的Matplotlib动画会创建其他空图

Jupyter笔记本中Matplotlib图的比例图大小

内核死在jupyter笔记本中,matplotlib似乎无法正常工作

在 Jupyter 笔记本中并排绘制两个 matplotlib.image.AxesImage 对象

如何禁用Jupyter笔记本Matplotlib内联图?

阻止Matplotlib Jupyter笔记本显示动画图