Skip to content

Commit

Permalink
feat(pandoc_imagine): matplotlib pgfplot backend for 'tex' fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
andros21 committed Feb 18, 2023
1 parent 6800528 commit 1daf2ed
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pandoc_imagine.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@

__version__ = "0.2.0"


# -- helpers
def to_str(s, enc="ascii"):
"return encoded byte stream for s. PY2->str, PY3->bytes"
Expand Down Expand Up @@ -1134,7 +1135,10 @@ class Matplotlib(Handler):
to import standard library needed for a matplotlib plot
- Imagine adds the following lines to the bottom of the script:
fig.savefig(sys.argv[-1], transparent=True)
to save result with trasparent background
to save result with trasparent background with graphic format
- Imagine adds the following lines to the bottom of the script:
fig.savefig(sys.argv[-1], format='pgf', backend='pgf')
to save result with trasparent background with tex format
"""

cmdmap = {"matplotlib": "python3"}
Expand All @@ -1150,7 +1154,9 @@ def image(self):
+ "import matplotlib.pyplot as plt"
),
self.code,
"fig.savefig(sys.argv[-1], transparent=True)",
"fig.savefig(sys.argv[-1], transparent=True)"
if self.im_fmt != "tex"
else "fig.savefig(sys.argv[-1], format='pgf', backend='pgf')",
)
self.write("w", self.code, self.inpfile)
if self.cmd(self.im_prg, *args):
Expand All @@ -1163,9 +1169,9 @@ def image(self):
"cmds": "\n ".join(wrap(", ".join(sorted(Handler.workers.keys()))))
}


# Inline-helper
def mergeImages(rv, elms):

# ensure elms is/becomes a list
if type(elms) != list:
elms = [elms]
Expand Down

0 comments on commit 1daf2ed

Please sign in to comment.