Skip to content

Commit

Permalink
added docstrings for functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Davidportlouis committed Jun 30, 2021
1 parent 4650fee commit c102e97
Showing 1 changed file with 95 additions and 13 deletions.
108 changes: 95 additions & 13 deletions utils/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,38 @@
import matplotlib.pyplot as plt
import seaborn as sns

def cscatter(filename: str, xCol: str, yCol: str,
dateCol:str = None, maskCol: str = None,
type_: str = None, color: str = None,
xLabel: str = None, yLabel: str = None, figTitle: str = None,
figWidth: int = 26, figHeight: int = 7) -> None:
def cscatter(filename: str,
xCol: str,
yCol: str,
dateCol:str = None,
maskCol: str = None,
type_: str = None,
color: str = None,
xLabel: str = None,
yLabel: str = None,
figTitle: str = None,
figWidth: int = 26,
figHeight: int = 7) -> None:
"""
creates a scatter plot of size figWidth & figHeight, named
figTitle and saves it.
Creates a scatter plot of size figWidth & figHeight, named figTitle and saves it.
Parameters:
filename (str): Name of the dataset to load.
xCol (str): Name of the feature in dataset to plot against X axis.
yCol (str): Name of the feature in dataset to plot against Y axis.
dateCol (str): Name of the feature containing dates to parse; default to None.
maskCol (str): Name of the feature in dataset to mask; defaults to None.
type_ (str): Name of the feature in dataset to use for masking; defaults to None.
color (str): Name of the feature in dataset to be used for color value in plotting;
defaults to None.
xlabel (str): Label for X axis; defaults to None.
ylabel (str): Label for Y axis; defaults to None.
figTitle (str): Title for the figure to be save; defaults to None.
figWidth (int): Width of the figure; defaults to 26.
figHeight (int): Height of the figure; defaults to 7.
Returns:
(None): Function does not return anything.
"""
sns.set(color_codes=True)
if dateCol:
Expand All @@ -34,10 +58,28 @@ def cscatter(filename: str, xCol: str, yCol: str,
plt.savefig(f"{figTitle}.png")
plt.close()

def cbarplot(filename: str, x: str, y: str, dateCol: str = None, figTitle: str = None, figWidth: int = 5, figHeight: int = 7) -> None:
def cbarplot(filename: str,
x: str,
y: str,
dateCol: str = None,
figTitle: str = None,
figWidth: int = 5,
figHeight: int = 7) -> None:
"""
Creates a bar plot of size figWidth & figHeight, named
figTitle between x & y.
Creates a bar plot of size figWidth & figHeight, named figTitle between x & y.
Parameters:
filename (str): Name of the dataset to load.
x (str): Name of the feature in dataset to plot against X axis.
y (str): Name of the feature in dataset to plot against Y axis.
dateCol (str): name of the feature containing dates to parse; default to None.
maskCol (str): name of the feature in dataset to mask; defaults to None.
figTitle (str): Title for the figure to be save; defaults to None.
figWidth (int): Width of the figure; defaults to 5.
figHeight (int): Height of the figure; defaults to 7.
Returns:
(None): Function does not return anything.
"""
sns.set(color_codes=True)
if dateCol:
Expand All @@ -50,9 +92,25 @@ def cbarplot(filename: str, x: str, y: str, dateCol: str = None, figTitle: str =
plt.savefig(f"{figTitle}.png")
plt.close()

def cheatmap(filename: str, cmap: str, annotate: bool, figTitle: str, figWidth: int = 12, figHeight: int = 6) -> None:
def cheatmap(filename: str,
cmap: str,
annotate: bool,
figTitle: str,
figWidth: int = 12,
figHeight: int = 6) -> None:
"""
Creates a heatmap (correlation map) of the dataset and saves it.
Parameters:
filename (str): Name of the dataset to load.
cmap (str): Name of the color map to be used for plotting.
annotate (bool): Indicates whether plot should be annotated with correlation values.
figTitle (str): Title for the figure to be save; defaults to None.
figWidth (int): Width of the figure; defaults to 12.
figHeight (int): Height of the figure; defaults to 6.
Returns:
(None): Function does not return anything.
"""
sns.set(color_codes=True)
df = pd.read_csv(filename)
Expand All @@ -63,9 +121,21 @@ def cheatmap(filename: str, cmap: str, annotate: bool, figTitle: str, figWidth:
plt.savefig(f"{figTitle}.png")
plt.close()

def clmplot(filename: str, figTitle: str = None, figWidth: int = 6, figHeight: int = 7) -> None:
def clmplot(filename: str,
figTitle: str = None,
figWidth: int = 6,
figHeight: int = 7) -> None:
"""
Generates a regression plot on the given dataset and saves it.
Parameters:
filename (str): Name of the dataset to load.
figTitle (str): Title for the figure to be save; defaults to None.
figWidth (int): Width of the figure; defaults to 6.
figHeight (int): Height of the figure; defaults to 7.
Returns:
(None): Function does not return anything.
"""
sns.set(color_codes=True)
df = pd.read_csv(filename)
Expand All @@ -75,9 +145,21 @@ def clmplot(filename: str, figTitle: str = None, figWidth: int = 6, figHeight: i
plt.savefig(f"{figTitle}.png")
plt.close()

def chistplot(filename: str, figTitle: str = None, figWidth: int = 6, figHeight: int = 4) -> None:
def chistplot(filename: str,
figTitle: str = None,
figWidth: int = 6,
figHeight: int = 4) -> None:
"""
Generated a histogram on the given dataset and saves it.
Parameters:
filename (str): Name of the dataset to load.
figTitle (str): Title for the figure to be save; defaults to None.
figWidth (int): Width of the figure; defaults to 6.
figHeight (int): Height of the figure; defaults to 4.
Returns:
(None): Function does not return anything.
"""
sns.set(color_codes=True)
df = pd.read_csv(filename)
Expand Down

0 comments on commit c102e97

Please sign in to comment.