您可能想询问期刊是否使用width=\columnwidth,例如,
\includegraphics[width=\columnwidth]{example-image}
是可以接受的。虽然这是重新缩放,但它适应当前列
宽度,所以这可能对期刊很友好。
如果没有,也许可以问他们(或其他在该领域发表过文章的作者)
期刊)对于典型论文用来包含图形的 LaTeX 样本,或
关于如何生成图形的建议。
也可能是期刊根本不希望光栅图像
缩放up,因为这会使图像看起来模糊。缩小规模可能不是
光栅图像的问题,缩放非光栅图像可能根本不是问题。
如果一切都失败了,您可以使用 LaTeX 本身来重新调整由
matplotlib。下面,make_plot 函数(取自matplotlib example
gallery)生成
/tmp/tex_demo.pdf。 rescale_pdf 函数重新调整 tex_demo.pdf 和
将结果写入/tmp/tex_demo-scaled.pdf。 rescale_pdf 函数
通过subprocess 模块调用pdflatex。
调整LaTeX模板中的paperheight和paperwidth参数
paperheight=2.25in,
paperwidth=3in,
控制重新缩放的pdf图形的大小。
import subprocess
import os
import textwrap
import numpy as np
import matplotlib.pyplot as plt
def make_plot(filename):
"""https://matplotlib.org/users/usetex.html"""
# Example data
t = np.arange(0.0, 1.0 + 0.01, 0.01)
s = np.cos(4 * np.pi * t) + 2
# fig, ax = plt.subplots(figsize=(2, 3))
plt.rc('text', usetex=True)
plt.rc('font', family='serif')
fig, ax = plt.subplots()
ax.plot(t, s)
ax.set_xlabel(r'\textbf{time} (s)')
ax.set_ylabel(r'\textit{voltage} (mV)',fontsize=16)
ax.set_title(r"\TeX\ is Number "
r"$\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$!",
fontsize=16, color='gray')
# Make room for the ridiculously large title.
plt.subplots_adjust(top=0.8)
plt.savefig(filename)
def rescale_pdf(filename):
stub, ext = os.path.splitext(filename)
print('begin rescale')
template = textwrap.dedent(r'''
\documentclass{article}
%% https://tex.stackexchange.com/a/46178/3919
\usepackage[
paperheight=2.25in,
paperwidth=3in,
bindingoffset=0in,
left=0in,
right=0in,
top=0in,
bottom=0in,
footskip=0in]{geometry}
\usepackage{graphicx}
\begin{document}
\pagenumbering{gobble}
\begin{figure}
%% https://tex.stackexchange.com/questions/63221/how-to-deal-with-pdf-figures
\includegraphics[width=\linewidth]{%s}
\end{figure}
\end{document}''' % (stub,))
tex_filename = 'result.tex'
with open(tex_filename, 'w') as f:
f.write(template)
proc = subprocess.Popen(['pdflatex', '-interaction', 'batchmode', tex_filename])
output, err = proc.communicate()
filename = '/tmp/tex_demo.pdf'
dirname = os.path.dirname(filename)
if dirname:
os.chdir(dirname)
make_plot(filename)
rescale_pdf(filename)