Skip to content
Snippets Groups Projects
Commit 0c82090d authored by Ryan Godwin's avatar Ryan Godwin
Browse files

Updates to the plotter class to get the png saved since html isn't working well in mlflow

parent c3f4b10b
No related branches found
No related tags found
1 merge request!1Progress toward getting the evaluation integrated
a46b9fdd3ebb4c11a77d4ecc5444ad56
\ No newline at end of file
e1362b03b8ed47648bddee1af72ce30c
\ No newline at end of file
......@@ -10,6 +10,8 @@ class Plotter(object):
self._y = y_values
self._output_file = output_file
self._fig_size = fig_size
plt.close()
def __call__(self):
pass
......@@ -18,47 +20,42 @@ class Plotter(object):
# save figure as HTML file
html_str = mpld3.fig_to_html(fig)
output_html = self._output_file.rename(self._output_file.with_suffix(".html"))
HTML_file = open(output_html, "w")
HTML_file = open(output_html, "w", encoding="utf8")
HTML_file.write(html_str)
HTML_file.close()
return output_html
class PlotCardiacIC(Plotter):
def __init__(self, output_file: Path(), x_values, y_values, fig_size=(12, 5)):
def __init__(self, output_file, x_values, y_values, fig_size=(12, 5)):
super().__init__(output_file, x_values, y_values, fig_size)
def __call__(self):
fig, ax = plt.subplots(1, 1, figsize=(12, 5))
plt.plot(self._x, self._y, linewidth=0.2)
plt.xlabel = "Time (s)"
plt.ylabel = "Cardiac Component"
plt.title = "Selected Cardiac Component"
fig = plt.gcf()
plt.savefig(self._output_file)
output_html = super().make_html(fig)
return output_html
plt.plot(self._x, self._y, linewidth=0.3)
plt.xlabel("Time (s)")
plt.ylabel("Cardiac Component")
plt.title("Selected Cardiac Component")
plt.savefig(Path(self._output_file), dpi=330)
#TODO- pull off the IC # and add to title
print('outfile - ', Path(self._output_file))
#output_html = super().make_html(plt.gcf())
return self._output_file
class PlotECG(Plotter):
def __init__(self, output_file: Path(), x_values, y_values, fig_size=(12, 5)):
def __init__(self, output_file, x_values, y_values, fig_size=(12, 5)):
super().__init__(output_file, x_values, y_values, fig_size)
def __call__(self):
fig, ax = plt.subplots(1, 1, figsize=(12, 5))
plt.subplots(1, 1, figsize=(12, 5))
plt.plot(self._x, self._y, linewidth=0.2)
plt.xlabel = "Time (s)"
plt.ylabel = "ECG Signal"
plt.title = "Scaled Signal"
fig = plt.gcf()
plt.savefig(self._output_file)
# save figure as HTML file
html_str = mpld3.fig_to_html(fig)
output_html = self._output_file.rename(self._output_file.with_suffix(".html"))
HTML_file = open(output_html, "w")
HTML_file.write(html_str)
HTML_file.close()
plt.xlabel("Time (s)")
plt.ylabel("ECG Signal")
plt.title("Scaled Signal")
plt.savefig(str(self._output_file), dpi=330)
output_html = super().make_html(plt.gcf())
return output_html
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment