Skip to content

Commit b8b7f70

Browse files
committed
Removed extension argument
1 parent 66b91cb commit b8b7f70

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/maxplotlib/canvas/canvas.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import matplotlib.pyplot as plt
22
import plotly.graph_objects as go
33
from plotly.subplots import make_subplots
4-
4+
import os
55
import maxplotlib.backends.matplotlib.utils as plt_utils
66
import maxplotlib.subfigure.line_plot as lp
77
import maxplotlib.subfigure.tikz_figure as tf
@@ -120,11 +120,12 @@ def add_subplot(self, **kwargs):
120120
def savefig(
121121
self,
122122
filename,
123-
extension="pdf",
124123
backend="matplotlib",
125124
layers=None,
126125
layer_by_layer=False,
126+
verbose=False,
127127
):
128+
filename_no_extension, extension = os.path.splitext(filename)
128129
if backend == "matplotlib":
129130
if layer_by_layer:
130131
layers = []
@@ -133,17 +134,21 @@ def savefig(
133134
fig, axs = self.plot(
134135
show=False, backend="matplotlib", savefig=True, layers=layers
135136
)
136-
fig.savefig(f"{filename}_{layers}.{extension}")
137+
_fn = f"{filename_no_extension}_{layers}.{extension}"
138+
fig.savefig(_fn)
139+
print(f"Saved {_fn}")
137140
else:
138141
if layers is None:
139142
layers = self.layers
140-
full_filepath = f"{filename}.{extension}"
143+
full_filepath = filename
141144
else:
142-
full_filepath = f"{filename}_{layers}.{extension}"
145+
full_filepath = f"{filename_no_extension}_{layers}.{extension}"
143146
fig, axs = self.plot(
144147
show=False, backend="matplotlib", savefig=True, layers=layers
145148
)
146149
fig.savefig(full_filepath)
150+
if verbose:
151+
print(f"Saved {full_filepath}")
147152

148153
def plot(self, backend="matplotlib", show=True, savefig=False, layers=None):
149154
if backend == "matplotlib":

0 commit comments

Comments
 (0)