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

时间:2015-01-29 13:42:56

标签: python matplotlib pweave

我想在'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 doc中找不到具体的例子或相关陈述)

2 个答案:

答案 0 :(得分:4)

作为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标记。所以如果有人在问

答案 1 :(得分:0)

看到Pweave缺乏普及和支持,我决定选择PyLatex,这肯定不一样,但是让我能够达到我想要的目标。