如何使用 Pweave 指定图形的大小(使用 .py 脚本)
How to specify the size of a figure with Pweave (using a .py script)
我正在尝试在 'Pweave-compatible'.py 脚本中使用 Pweave 指定图形的大小:
#' do the imports
import matplotlib.pyplot as plt
#' normal figure
plt.figure(1)
plt.plot(range(30), color='k', linestyle='dashed', marker='o')
#' figure super wide
#+ fig = True, width = '24 cm'
plt.figure(2)
plt.plot(range(30), color='k', linestyle='dashed', marker='o')
但是在编译脚本之后:
pypublish test.py
我只能证明 .html 文件中的数字是相同的,我希望它们具有不同的大小。
我想知道我做错了什么,或者即使这是否受支持(在 Pweave 文档中找不到具体示例或相关声明)
看到 Pweave 缺乏人气和支持,我决定使用 PyLatex,它肯定不一样,但让我几乎可以实现我想要的。
作为 Pweave 的作者,我将以我刚刚注意到的方式回答这个问题。您将需要设置有效的宽度 html,因此将宽度设置为例如1200 将工作。
下面的代码示例将更改 HTML 输出中的图形大小:
#' figure super wide
#+ fig = True, width = '1200'
plt.figure(2)
plt.plot(range(30), color='k', linestyle='dashed', marker='o')
脚本 reader(在 0.23.2 中)也有一个错误,它不喜欢 #'
和 #+
行之间的额外空格(现在已修复在 github)。
我还在 SO 上添加了 pweave
标签。所以如果有人问
我正在尝试在 'Pweave-compatible'.py 脚本中使用 Pweave 指定图形的大小:
#' do the imports
import matplotlib.pyplot as plt
#' normal figure
plt.figure(1)
plt.plot(range(30), color='k', linestyle='dashed', marker='o')
#' figure super wide
#+ fig = True, width = '24 cm'
plt.figure(2)
plt.plot(range(30), color='k', linestyle='dashed', marker='o')
但是在编译脚本之后:
pypublish test.py
我只能证明 .html 文件中的数字是相同的,我希望它们具有不同的大小。
我想知道我做错了什么,或者即使这是否受支持(在 Pweave 文档中找不到具体示例或相关声明)
看到 Pweave 缺乏人气和支持,我决定使用 PyLatex,它肯定不一样,但让我几乎可以实现我想要的。
作为 Pweave 的作者,我将以我刚刚注意到的方式回答这个问题。您将需要设置有效的宽度 html,因此将宽度设置为例如1200 将工作。
下面的代码示例将更改 HTML 输出中的图形大小:
#' figure super wide
#+ fig = True, width = '1200'
plt.figure(2)
plt.plot(range(30), color='k', linestyle='dashed', marker='o')
脚本 reader(在 0.23.2 中)也有一个错误,它不喜欢 #'
和 #+
行之间的额外空格(现在已修复在 github)。
我还在 SO 上添加了 pweave
标签。所以如果有人问