From 30c36c3ab0250be4a3739271e1b6e9be46fe0fc5 Mon Sep 17 00:00:00 2001 From: kurbansitterley Date: Wed, 25 Mar 2026 11:43:07 -0600 Subject: [PATCH 1/6] .gitignore logs --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f384bb0..232cf0c 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ psPlotKit/examples/figs/Brine salinity vs LCOW.csv *.egg *.egg-info site/ +*.log From 273020afc33974e446ebb9a8a3a08fb5c2285279 Mon Sep 17 00:00:00 2001 From: kurbansitterley Date: Wed, 25 Mar 2026 11:43:33 -0600 Subject: [PATCH 2/6] duplicate ignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 232cf0c..7a341d7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ -*.csv *.csv psPlotKit/examples/figs/Water recovery vs LCOW.svg psPlotKit/examples/figs/Water recovery vs LCOW.csv From 412d8b69a2540154d8286ff08d12c485c230b8bf Mon Sep 17 00:00:00 2001 From: kurbansitterley Date: Wed, 25 Mar 2026 12:53:31 -0600 Subject: [PATCH 3/6] pass FigureGenerator to BreakDownPlotter; pass ax_idx to plot generating methods --- .../data_plotter/ps_break_down_plotter.py | 49 +++++++++++-------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/src/psPlotKit/data_plotter/ps_break_down_plotter.py b/src/psPlotKit/data_plotter/ps_break_down_plotter.py index 9d707e6..14a4839 100644 --- a/src/psPlotKit/data_plotter/ps_break_down_plotter.py +++ b/src/psPlotKit/data_plotter/ps_break_down_plotter.py @@ -20,6 +20,7 @@ def __init__( save_folder=None, save_name=None, show_fig=True, + fig=None, ): self.save_location = create_save_location(save_location, save_folder) @@ -36,6 +37,9 @@ def __init__( self.save_name = save_name self.hatch_groups = {} self.area_groups = {} + if fig is not None and not isinstance(fig, FigureGenerator): + raise ValueError("fig must be a FigureGenerator object") + self.fig = fig def _select_data(self, xkeys, ykeys): self.PsData.select_data(xkeys, require_all_in_dir=False) @@ -229,7 +233,8 @@ def plotbreakdown( generate_figure=True, legend_loc="upper left", legend_cols=2, - fig_options={}, + # fig_options={}, + ax_idx=0, ): self._select_data(xdata, ydata) @@ -238,7 +243,7 @@ def plotbreakdown( self.generate_groups_lines = self._get_group_options( self.selected_data.keys(), xdata, ydata ) - self.fig_options = fig_options + # self.fig_options = fig_options self.index = 0 if axis_options is None: self.axis_options = {} @@ -247,28 +252,28 @@ def plotbreakdown( if self.axis_options.get("xlabel") == None: self.axis_options["xlabel"] = self._get_axis_label( self.xdata_label, self.xunit - ) # all lines shold share units + ) # all lines should share units if self.axis_options.get("ylabel") == None: self.axis_options["ylabel"] = self._get_axis_label( self.ydata_label, self.yunit - ) # all lines shold share units + ) # all lines should share units - self.plot_imported_data() + self.plot_imported_data(ax_idx=ax_idx) - if ( - generate_figure - ): # TODO: other plotters call this generate_plot, should make this consistent - self.generate_figure(loc=legend_loc, cols=legend_cols) + # if ( + # generate_figure + # ): # TODO: other plotters call this generate_plot, should make this consistent + # self.generate_figure(loc=legend_loc, cols=legend_cols) - def plot_imported_data(self): - if "fig_object" in self.fig_options: - self.fig = self.fig_options.get("fig_object") - else: - self.fig = FigureGenerator() - self.fig.init_figure(**self.fig_options) + def plot_imported_data(self, ax_idx=0): + # if "fig_object" in self.fig_options: + # self.fig = self.fig_options.get("fig_object") + # else: + # self.fig = FigureGenerator() + # self.fig.init_figure(**self.fig_options) plotted_legend = [] for group, items in self.hatch_groups.items(): - self.fig.plot_area([], [], **items) + self.fig.plot_area([], [], ax_idx=ax_idx, **items) old_data = 0 current_data = None @@ -284,14 +289,16 @@ def plot_imported_data(self): else: current_data = line["ydata"] + old_data line["ydata"] = current_data - if "ax_idx" in self.fig_options: - line["ax_idx"] = self.fig_options.get("ax_idx") - self.fig.plot_area(**line) + # if "ax_idx" in self.fig_options: + # line["ax_idx"] = self.fig_options.get("ax_idx") + self.fig.plot_area(ax_idx=ax_idx, **line) old_data = line["ydata"] + + self.fig.set_axis(**self.axis_options) def generate_figure(self, loc="upper left", cols=2): - if "ax_idx" in self.fig_options: - self.axis_options["ax_idx"] = self.fig_options["ax_idx"] + # if "ax_idx" in self.fig_options: + # self.axis_options["ax_idx"] = self.fig_options["ax_idx"] self.fig.set_axis(**self.axis_options) self.fig.add_legend(loc=loc, ncol=cols) From df68b5441ef8867ce5bc890b5a66154e091352ac Mon Sep 17 00:00:00 2001 From: kurbansitterley Date: Wed, 25 Mar 2026 18:27:05 -0600 Subject: [PATCH 4/6] bdp inits with fig generator obj, ax_idx as args --- .../data_plotter/ps_break_down_plotter.py | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/psPlotKit/data_plotter/ps_break_down_plotter.py b/src/psPlotKit/data_plotter/ps_break_down_plotter.py index 14a4839..684846b 100644 --- a/src/psPlotKit/data_plotter/ps_break_down_plotter.py +++ b/src/psPlotKit/data_plotter/ps_break_down_plotter.py @@ -15,20 +15,22 @@ class BreakDownPlotter: def __init__( self, - PsData, + PsData=None, save_location=None, save_folder=None, save_name=None, show_fig=True, fig=None, + line_indexes={}, + line_color_list=None, + color_dict=None, ): self.save_location = create_save_location(save_location, save_folder) self.show_fig = show_fig self.select_data_key_list = [] self.PsData = PsData - self.define_plot_styles() - self.line_indexes = {} + self.define_plot_styles(line_color_list=line_color_list) self.line_groups = None self.xunit = None self.yunit = None @@ -40,6 +42,7 @@ def __init__( if fig is not None and not isinstance(fig, FigureGenerator): raise ValueError("fig must be a FigureGenerator object") self.fig = fig + self.color_dict = color_dict def _select_data(self, xkeys, ykeys): self.PsData.select_data(xkeys, require_all_in_dir=False) @@ -52,6 +55,7 @@ def define_area_groups(self, groups): self.area_groups = groups def _get_color(self, label): + if isinstance(self.line_colors, dict): return self.line_colors[label] else: @@ -152,7 +156,11 @@ def _get_group_options(self, selected_keys, xdata, ydata): opts = None key = None color = None + if skey in self.color_dict.keys(): + color = self.color_dict[skey] for i, key in enumerate(self.hatch_groups): + # First try to get plotting options based on skey + # provided directly in hatch_groups if key in str(skey): opts = self.hatch_groups[key] if opts.get("label") == None: @@ -165,17 +173,23 @@ def _get_group_options(self, selected_keys, xdata, ydata): self.hatch_groups[key] = copy.deepcopy(opts) # if key not in self.line_indexes: # self.line_indexes[key] = {"idx": 0, "auto": True} + + # Then check if there are options based on akey for akey in self.area_groups: _label = None if isinstance(akey, dict): akey, item = list(akey.items())[0] if isinstance(item, dict): + # if True, the structure of area_groups is a list of dicts with one key? if "label" in item: _label = item["label"] if "color" in item: color = item["color"] else: _label = item + + if akey in self.color_dict.keys(): + color = self.color_dict[akey] if self.check_key_in_dir(skey, akey): if _label is None: _label = akey @@ -199,12 +213,14 @@ def _get_group_options(self, selected_keys, xdata, ydata): cur_line[key] = val if self.hatch_groups != {}: + # If hatch_groups is not an empty dict for h_key in self.hatch_groups: - # print("ss", h_key, akey, skey) if h_key in str(skey): + # print("ss", h_key, akey, skey) _label = tuple([h_key, akey]) plot_label.replace(h_key, "") + # Then we are looking for a color based on h_key if color is None: color = self._get_color(h_key) cur_line["color"] = color @@ -230,17 +246,17 @@ def plotbreakdown( xdata, ydata, axis_options=None, - generate_figure=True, - legend_loc="upper left", - legend_cols=2, + # generate_figure=True, + # legend_loc="upper left", + # legend_cols=2, # fig_options={}, ax_idx=0, ): self._select_data(xdata, ydata) self.selected_data = self.PsData.get_selected_data() - self.selected_data.display() - self.generate_groups_lines = self._get_group_options( + # self.selected_data.display() + self._get_group_options( self.selected_data.keys(), xdata, ydata ) # self.fig_options = fig_options @@ -276,7 +292,6 @@ def plot_imported_data(self, ax_idx=0): self.fig.plot_area([], [], ax_idx=ax_idx, **items) old_data = 0 current_data = None - for linelabel in self.plot_order: line = self.plot_areas[linelabel] if line.get("label") in plotted_legend: @@ -310,6 +325,8 @@ def generate_figure(self, loc="upper left", cols=2): self.fig.close() + def set_selected_data(self, data): + self.PsData = data class breakDownPlotter(BreakDownPlotter): _logger.warning("breakDownPlotter is deprecated, please use BreakDownPlotter") From e57f070e46f15813c74ab90c15af4333c1a5a4cf Mon Sep 17 00:00:00 2001 From: avdudchenko <33663878+avdudchenko@users.noreply.github.com> Date: Fri, 27 Mar 2026 17:43:59 -0400 Subject: [PATCH 5/6] Update ps_break_down_plotter.py --- src/psPlotKit/data_plotter/ps_break_down_plotter.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/psPlotKit/data_plotter/ps_break_down_plotter.py b/src/psPlotKit/data_plotter/ps_break_down_plotter.py index 684846b..84fd3e4 100644 --- a/src/psPlotKit/data_plotter/ps_break_down_plotter.py +++ b/src/psPlotKit/data_plotter/ps_break_down_plotter.py @@ -55,7 +55,7 @@ def define_area_groups(self, groups): self.area_groups = groups def _get_color(self, label): - + if isinstance(self.line_colors, dict): return self.line_colors[label] else: @@ -187,7 +187,7 @@ def _get_group_options(self, selected_keys, xdata, ydata): color = item["color"] else: _label = item - + if akey in self.color_dict.keys(): color = self.color_dict[akey] if self.check_key_in_dir(skey, akey): @@ -256,9 +256,7 @@ def plotbreakdown( self._select_data(xdata, ydata) self.selected_data = self.PsData.get_selected_data() # self.selected_data.display() - self._get_group_options( - self.selected_data.keys(), xdata, ydata - ) + self._get_group_options(self.selected_data.keys(), xdata, ydata) # self.fig_options = fig_options self.index = 0 if axis_options is None: @@ -308,7 +306,7 @@ def plot_imported_data(self, ax_idx=0): # line["ax_idx"] = self.fig_options.get("ax_idx") self.fig.plot_area(ax_idx=ax_idx, **line) old_data = line["ydata"] - + self.fig.set_axis(**self.axis_options) def generate_figure(self, loc="upper left", cols=2): @@ -328,5 +326,6 @@ def generate_figure(self, loc="upper left", cols=2): def set_selected_data(self, data): self.PsData = data + class breakDownPlotter(BreakDownPlotter): _logger.warning("breakDownPlotter is deprecated, please use BreakDownPlotter") From 3d022befecfd696ad113c08a7872a7e256fcb449 Mon Sep 17 00:00:00 2001 From: kurbansitterley Date: Fri, 27 Mar 2026 16:26:22 -0600 Subject: [PATCH 6/6] work for single plot --- .../data_plotter/ps_break_down_plotter.py | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/psPlotKit/data_plotter/ps_break_down_plotter.py b/src/psPlotKit/data_plotter/ps_break_down_plotter.py index 684846b..382efa6 100644 --- a/src/psPlotKit/data_plotter/ps_break_down_plotter.py +++ b/src/psPlotKit/data_plotter/ps_break_down_plotter.py @@ -246,20 +246,24 @@ def plotbreakdown( xdata, ydata, axis_options=None, - # generate_figure=True, - # legend_loc="upper left", - # legend_cols=2, - # fig_options={}, - ax_idx=0, + generate_plot=False, + legend_loc="upper left", + legend_cols=2, + fig_options={}, + ax_idx=None, + **kwargs ): + if ax_idx is None: + ax_idx = 0 + self.fig_options = fig_options + self.fig_options["ax_idx"] = ax_idx + self._select_data(xdata, ydata) self.selected_data = self.PsData.get_selected_data() - # self.selected_data.display() self._get_group_options( self.selected_data.keys(), xdata, ydata ) - # self.fig_options = fig_options self.index = 0 if axis_options is None: self.axis_options = {} @@ -276,10 +280,9 @@ def plotbreakdown( self.plot_imported_data(ax_idx=ax_idx) - # if ( - # generate_figure - # ): # TODO: other plotters call this generate_plot, should make this consistent - # self.generate_figure(loc=legend_loc, cols=legend_cols) + # TODO: other plotters call this generate_plot, should make this consistent + if generate_plot: + self.generate_plot(ax_idx=ax_idx, loc=legend_loc, cols=legend_cols) def plot_imported_data(self, ax_idx=0): # if "fig_object" in self.fig_options: @@ -304,17 +307,13 @@ def plot_imported_data(self, ax_idx=0): else: current_data = line["ydata"] + old_data line["ydata"] = current_data - # if "ax_idx" in self.fig_options: - # line["ax_idx"] = self.fig_options.get("ax_idx") self.fig.plot_area(ax_idx=ax_idx, **line) old_data = line["ydata"] - self.fig.set_axis(**self.axis_options) + self.fig.set_axis(ax_idx=ax_idx, **self.axis_options) - def generate_figure(self, loc="upper left", cols=2): - # if "ax_idx" in self.fig_options: - # self.axis_options["ax_idx"] = self.fig_options["ax_idx"] - self.fig.set_axis(**self.axis_options) + def generate_plot(self, ax_idx=0, loc="upper left", cols=2): + self.fig.set_axis(ax_idx=ax_idx, **self.axis_options) self.fig.add_legend(loc=loc, ncol=cols) if self.save_name is not None: