requirements
This commit is contained in:
@@ -6,11 +6,14 @@ class Plotter(object):
|
|||||||
def __init__(self, root_path=''):
|
def __init__(self, root_path=''):
|
||||||
self.root_path = Path(root_path)
|
self.root_path = Path(root_path)
|
||||||
|
|
||||||
def save_current_figure(self, path, extention='.png'):
|
def save_current_figure(self, path, extention='.png', naked=True):
|
||||||
fig, _ = plt.gcf(), plt.gca()
|
fig, _ = plt.gcf(), plt.gca()
|
||||||
# Prepare save location and check img file extention
|
# Prepare save location and check img file extention
|
||||||
path = self.root_path / Path(path if str(path).endswith(extention) else f'{str(path)}{extention}')
|
path = self.root_path / Path(path if str(path).endswith(extention) else f'{str(path)}{extention}')
|
||||||
path.parent.mkdir(exist_ok=True, parents=True)
|
path.parent.mkdir(exist_ok=True, parents=True)
|
||||||
|
if naked:
|
||||||
|
plt.axis('off')
|
||||||
|
fig.savefig(path, bbox_inches='tight', transparent=True, pad_inches=0)
|
||||||
fig.savefig(path)
|
fig.savefig(path)
|
||||||
fig.clf()
|
fig.clf()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user