Skip to content

Commit d1bb8dc

Browse files
committed
added pdf option
1 parent 90b2188 commit d1bb8dc

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

plttools.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def __init__(self,
5959
y_boundaries=None,
6060
y_ticks=None,
6161
saving_path = None,
62+
saving_format = "png",
6263
filename = None,
6364
*args,
6465
**kwargs
@@ -109,6 +110,7 @@ def __init__(self,
109110
self.y_ticks=y_ticks
110111
self.saving_path = saving_path
111112
self.filename = filename
113+
self.saving_format = saving_format
112114

113115
if self.fontsize == 'default':
114116
self.fontsize = 34
@@ -462,10 +464,19 @@ def save_figure(self, **args):
462464
"text.latex.preamble" : r"\usepackage{cmbright}"
463465
})
464466
if self.dark_mode:
467+
if self.saving_format == 'pdf':
468+
print("dark mode and pdf not supported. saving to png")
465469
plt.savefig(saving_path + self.filename + "-dm.png",
466470
bbox_inches = 'tight', pad_inches = 0.062,
467471
transparent=self.transparency, dpi=200)
468472
else:
469-
plt.savefig(saving_path + self.filename + ".png",
470-
bbox_inches = 'tight', pad_inches = 0.062,
471-
transparent=self.transparency, dpi=200)
473+
if self.saving_format == 'pdf':
474+
if self.transparency:
475+
print("pdf and transparency were chosen")
476+
plt.savefig(saving_path + self.filename + ".pdf",
477+
bbox_inches = 'tight', pad_inches = 0.062,
478+
transparent=self.transparency, dpi=200)
479+
elif self.saving_format == 'png':
480+
plt.savefig(saving_path + self.filename + ".png",
481+
bbox_inches = 'tight', pad_inches = 0.062,
482+
transparent=self.transparency, dpi=200)

0 commit comments

Comments
 (0)