def _store_as_pdf(self, filename: str, fig_width: float, fig_height: float) -> str:
"""
Stores the current figure in a pdf file.
:param filename: name of the pdf file
:param fig_width: width of the figure in cm
:param fig_height: height of the figure in cm
:warning: modifies the current figure
"""
import matplotlib.pyplot as plt
if not filename.endswith(".pdf"):
filename += ".pdf"
self.reset_plt()
self._latexify(fig_width, fig_height)
try:
plt.tight_layout()
except ValueError:
pass
self._format_axes(plt.gca())
plt.savefig(filename)
self.reset_plt()
return os.path.realpath(filename)
评论列表
文章目录