From 8377bdc6856e004ecc6554008a9e0f556a05b579 Mon Sep 17 00:00:00 2001 From: Michele Di Giorgio Date: Tue, 16 Feb 2016 12:40:34 +0000 Subject: plotter: ILinePlotGen: substitute cols parameter with per_line The per_line attribute is written into the json file that describes the plot to be displayed. It identifies the number of figures in a line and therefore the number of columns. For this reason the cols parameter has been deleted from the ILinePlotGen class. This also solves the issue with too narrow plot when plotting a single figure. Previously, per_line was always set to the default value equal to 2 which caused the plot of a single figure to be in the first column even if no figures are being plotted in the next one. close #134 --- trappy/plotter/ILinePlot.py | 7 ++----- trappy/plotter/ILinePlotGen.py | 17 ++++++----------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/trappy/plotter/ILinePlot.py b/trappy/plotter/ILinePlot.py index fa30397..027e801 100644 --- a/trappy/plotter/ILinePlot.py +++ b/trappy/plotter/ILinePlot.py @@ -167,9 +167,7 @@ class ILinePlot(AbstractDataPlotter): """Internal Method called to draw the plot""" pivot_vals, len_pivots = self.c_mgr.generate_pivots(permute) - self._layout = ILinePlotGen(self._attr["per_line"], - len_pivots, - **self._attr) + self._layout = ILinePlotGen(len_pivots, **self._attr) plot_index = 0 for p_val in pivot_vals: data_frame = pd.Series() @@ -206,8 +204,7 @@ class ILinePlot(AbstractDataPlotter): pivot_vals, _ = self.c_mgr.generate_pivots() plot_index = 0 - self._layout = ILinePlotGen(self._attr["per_line"], len(self.c_mgr), - **self._attr) + self._layout = ILinePlotGen(len(self.c_mgr), **self._attr) for constraint in self.c_mgr: result = constraint.result diff --git a/trappy/plotter/ILinePlotGen.py b/trappy/plotter/ILinePlotGen.py index c911dfc..54e9778 100644 --- a/trappy/plotter/ILinePlotGen.py +++ b/trappy/plotter/ILinePlotGen.py @@ -35,9 +35,6 @@ from IPython.display import display, HTML class ILinePlotGen(object): """ - :param cols: The number of columns to draw - :type cols: int - :param num_plots: The total number of plots :type num_plots: int @@ -122,9 +119,8 @@ class ILinePlotGen(object): for _ in range(self._rows): self._begin_row() - legend_figs = [] - for _ in range(self._cols): + for _ in range(self._attr["per_line"]): fig_name = self._generate_fig_name() legend_figs.append(fig_name) self._add_graph_cell(fig_name) @@ -139,9 +135,8 @@ class ILinePlotGen(object): self._end_table() - def __init__(self, cols, num_plots, **kwargs): + def __init__(self, num_plots, **kwargs): - self._cols = cols self._attr = kwargs self._html = [] self.num_plots = num_plots @@ -152,11 +147,11 @@ class ILinePlotGen(object): if self.num_plots == 0: raise RuntimeError("No plots for the given constraints") - if self.num_plots < self._cols: - self._cols = self.num_plots - self._rows = (self.num_plots / self._cols) + if self.num_plots < self._attr["per_line"]: + self._attr["per_line"] = self.num_plots + self._rows = (self.num_plots / self._attr["per_line"]) - if self.num_plots % self._cols != 0: + if self.num_plots % self._attr["per_line"] != 0: self._rows += 1 self._attr["height"] = AttrConf.HTML_HEIGHT -- cgit v1.2.3