From 357df1609fcdcec9e1cbfeffc7d38a4d7f586ea7 Mon Sep 17 00:00:00 2001 From: SimpleArt <71458112+SimpleArt@users.noreply.github.com> Date: Thu, 12 Nov 2020 12:11:04 -0500 Subject: [PATCH] General graph features --- src/database/matplotlib_graph.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/database/matplotlib_graph.py b/src/database/matplotlib_graph.py index c45e341..ed044f9 100644 --- a/src/database/matplotlib_graph.py +++ b/src/database/matplotlib_graph.py @@ -4,6 +4,11 @@ import matplotlib.pyplot as plt class Matplotlib_Graph: """Prebuilt graphing functions to make visual represention of fitness data.""" + type_of_plot_dict = { + 'line' : plt.plot, + 'scatter' : plt.scatter, + 'bar' : plt.bar + } def __init__(self, database): self.database = database @@ -119,15 +124,8 @@ class Matplotlib_Graph: @type_of_plot.setter - def type_of_plot(self, value_input): - - # Defults type of ploting functions - if(value_input == "line"): - self._type_of_plot = plt.plot - elif(value_input == "scatter"): - self._type_of_plot = plt.scatter - elif(value_input == "bar"): - self._type_of_plot = plt.bar + def type_of_plot(self, _type_of_plot): + if _type_of_plot in self.type_of_plot_dict.keys(): + self._type_of_plot = self.type_of_plot_dict[_type_of_plot] else: - # If its none of the defaults then use what the user provided. - self._type_of_plot = value_input + self._type_of_plot = _type_of_plot