Skip to content

Commit

Permalink
add ability to create output folder if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewm4894 committed Apr 29, 2020
1 parent 59d0a86 commit c96910e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions am4894plots/scatters/plotly.py
@@ -1,5 +1,7 @@
import math
import itertools
import os

import numpy as np
import pandas as pd
import plotly.graph_objects as go
Expand Down Expand Up @@ -55,6 +57,9 @@ def plot_scatters(df: pd.DataFrame, cols: list = None, cols_like: list = None, x
p.update_layout(width=w)
p.update_layout(template=theme)
if out_path:
out_dir = '/'.join(out_path.split('/')[0:-1])
if not os.path.exists(out_dir):
os.makedirs(out_dir)
plotly.offline.plot(p, filename=out_path, auto_open=False)
if show_p:
p.show(renderer=renderer)
Expand Down

0 comments on commit c96910e

Please sign in to comment.