:
を私はあなたのサンプルコードを取り、少しこれは私のmac unsingパイソン3上の素敵な2ページのPDFファイルになりmultipage example from matplotlib.
import numpy as np
from matplotlib.backends.backend_pdf import PdfPages
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
import numpy as np
with PdfPages('multipage_pdf.pdf') as pdf:
# Data for plotting
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)
# Note that using plt.subplots below is equivalent to using
# fig = plt.figure and then ax = fig.add_subplot(111)
#fig, ax = plt.subplots()
plt.plot(t, s)
#ax.set(xlabel='time (s)', ylabel='voltage (mV)', title='About as simple as it gets, folks')
#ax.grid()
plt.title("Page one")
pdf.savefig()
plt.close()
plt.rc('text', usetex=False)
plt.title("PAGE TWO")
# Data for plotting
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)
# Note that using plt.subplots below is equivalent to using
# fig = plt.figure and then ax = fig.add_subplot(111)
fig, ax = plt.subplots()
ax.plot(t, s)
ax.set(xlabel='time (s)', ylabel='voltage (mV)',
title='About as simple as it gets, folks')
ax.grid()
pdf.savefig()
plt.close()
にそれを適応しました。 これは最終的な解決策ではありませんが、あなたには良い出発点になるはずです。 また、pdfメタデータを追加したり、テキストを挿入したりできます。
OSXユーザー向けの発言:私が原因の行にmatplotlibのからの例の問題を持っていた:
plt.rc('text', usetex=True)
これは、ラテックスエラーが発生しました。
RuntimeError: LaTeX was not able to process the following string:
b'lp'
Here is the full report generated by LaTeX:
ちょうど軌道に乗るための最初の回避策として、
usetex=False
を設定します。
は[multipage_pdf.pyサンプルコードをpylab_examples] ... ;-)理由もなく、数年後にテ・コードの例を破るように見えます.html) – sascha
私の答えは、あなたがコメントしたhakvin、saschaと同じものに基づいています。彼らには本当に素晴らしい例があります。 – klaas