gpt4 book ai didi

python - 如何使用 Pweave 指定图形的大小(使用 .py 脚本)

转载 作者:行者123 更新时间:2023-11-28 22:45:45 27 4
gpt4 key购买 nike

我正在尝试在“Pweave 兼容”.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 的作者,我将以我刚刚注意到的方式回答这个问题。您将需要设置有效 html 的宽度,因此将宽度设置为例如1200 将工作。

下面的代码示例将更改 HTML 输出中的图形大小:

#' figure super wide

#+ fig = True, width = '1200'

plt.figure(2)
plt.plot(range(30), color='k', linestyle='dashed', marker='o')

脚本阅读器(在 0.23.2 中)也有一个错误,它不喜欢 #'#+ 行之间的额外空格(这是现在已在 github 中修复)。

我还在 SO 上添加了 pweave 标签。所以如果有人问

关于python - 如何使用 Pweave 指定图形的大小(使用 .py 脚本),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28216257/

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