gpt4 book ai didi

python - 在 Sphinx : how to show documentation 中嵌入 matplotlib 图

转载 作者:太空宇宙 更新时间:2023-11-04 03:32:48 25 4
gpt4 key购买 nike

我有一些 ipynb 文档,其中包含由 %matplotlib inline 指令内联显示的 matplotlib 图。

当我尝试用内联绘图显示我的笔记本时,我有我的 Sphinx 文档。我尝试使用

ipython nbconvert shalom.ipynb --to rst

但是,遗憾的是,它确实给了我一个没有任何内联图形的 RST。只有代码 list 。

你能告诉我如何使用已渲染的图生成 Sphinx 文档吗。

我知道这是可能的。

最佳答案

您需要使用 Sphinx extensions for embedded plots, math and more

Sphinx is written in python, and supports the ability to write custom extensions. We’ve written a few for the matplotlib documentation, some of which are part of matplotlib itself in the matplotlib.sphinxext module, some of which are included only in the sphinx doc directory, and there are other extensions written by other groups, eg numpy and ipython. We’re collecting these in this tutorial and showing you how to install and use them for your own project. First let’s grab the python extension files from the sphinxext directory from git (see Fetching the data), and install them in our sampledoc project sphinxext directory:

您需要修改您的 conf.py 以包括:

extensions = [
'matplotlib.sphinxext.mathmpl',
'matplotlib.sphinxext.only_directives',
'matplotlib.sphinxext.plot_directive',
'matplotlib.sphinxext.ipython_directive',
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'ipython_console_highlighting',
'inheritance_diagram',
'numpydoc']

关于python - 在 Sphinx : how to show documentation 中嵌入 matplotlib 图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30397384/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com