def _do(self): # initial a figure with a single plot self.init_figure() # equal axis length and no ticks equal_axis(self.ax) no_ticks(self.ax) # determine the overall scale of points _F = np.row_stack([e[0] for e in self.to_plot]) _min, _max = _F.min(axis=0), _F.max(axis=0) V = get_uniform_points_around_circle(self.n_dim) plot_axes_arrow(self.ax, V, extend_factor=self.axis_extension, **{**self.axis_style, **self.arrow_style}) plot_axis_labels(self.ax, V, self.get_labels(), **self.axis_label_style) # normalize in range for this plot - here no implicit normalization as in radviz bounds = parse_bounds(self.bounds, self.n_dim) to_plot_norm = normalize(self.to_plot, bounds) for k, (F, kwargs) in enumerate(to_plot_norm): N = (F[..., None] * V).sum(axis=1) self.ax.scatter(N[:, 0], N[:, 1], **kwargs)
def _do(self): if self.bounds is None: raise Exception("The boundaries must be provided.") _F = np.row_stack([e[0] for e in self.to_plot]) if np.any(_F < self.bounds[0]) or np.any(_F > self.bounds[1]): raise Exception( "Points out of the boundaries exist! Please make sure the boundaries are indeed boundaries.") n_rows = len(self.to_plot) n_cols = max([len(e[0]) for e in self.to_plot]) self.init_figure(n_rows=n_rows, n_cols=n_cols, force_axes_as_matrix=True) # normalize the input bounds = parse_bounds(self.bounds, self.n_dim) to_plot_norm = normalize(self.to_plot, bounds, reverse=self.reverse) # get the endpoints of circle V = get_circle_points(self.n_dim) if self.normalize_each_objective: inner = np.zeros((self.n_dim, 1)) * V outer = np.ones((self.n_dim, 1)) * V else: inner = bounds[[0]].T * V outer = (bounds[[1]].T * V) / bounds[1].max() for k, (F, kwargs) in enumerate(to_plot_norm): for j, _F in enumerate(F): self._plot(self.ax[k, j], _F, inner, outer, kwargs)
def _do(self): # initial a figure with a single plot self.init_figure() # if no normalization of each axis the bounds are based on the overall min and max if not self.normalize_each_axis and self.bounds is None: _F = np.row_stack([e[0] for e in self.to_plot]) self.bounds = [_F.min(), _F.max()] # normalize the input bounds = parse_bounds(self.bounds, self.n_dim) to_plot_norm, bounds = normalize(self.to_plot, bounds, return_bounds=True) # plot for each set the lines for k, (F, kwargs) in enumerate(to_plot_norm): _kwargs = kwargs.copy() set_if_none(_kwargs, "color", self.colors[k]) for i in range(len(F)): plt.plot(np.arange(F.shape[1]), F[i, :], **_kwargs) # Plot the parallel coordinate axes for i in range(self.n_dim): self.ax.axvline(i, **self.axis_style) bottom, top = -0.1, 1.075 margin_left = 0.08 if self.show_bounds: self.ax.text(i - margin_left, bottom, self.func_number_to_text(bounds[0][i])) self.ax.text(i - margin_left, top, self.func_number_to_text(bounds[1][i])) if self.n_ticks is not None: n_length = 0.03 for y in np.linspace(0, 1, self.n_ticks): self.ax.hlines(y, i - n_length, i + n_length, **self.axis_style) # if bounds are shown, then move them to the bottom if self.show_bounds: self.ax.tick_params(axis='x', which='major', pad=25) self.ax.spines['right'].set_visible(False) self.ax.spines['left'].set_visible(False) self.ax.set_yticklabels([]) self.ax.set_yticks([]) self.ax.set_ylim((-0.05, 1.05)) self.ax.set_xticks(np.arange(self.n_dim)) self.ax.set_xticklabels(self.get_labels()) return self
def _do(self): n_rows = len(self.to_plot) n_cols = max([len(e[0]) for e in self.to_plot]) self.init_figure(n_rows=n_rows, n_cols=n_cols, force_axes_as_matrix=True) # normalize the input bounds = parse_bounds(self.bounds, self.n_dim) to_plot_norm = normalize(self.to_plot, bounds, reverse=self.reverse) for k, (F, kwargs) in enumerate(to_plot_norm): for j, _F in enumerate(F): self._plot(self.ax[k, j], _F)
def _do(self): if len(self.to_plot) != 1: raise Exception("Only one element can be added to a heatmap.") # initial a figure with a single plot self.init_figure() # normalize the input bounds = parse_bounds(self.bounds, self.n_dim) to_plot_norm = normalize(self.to_plot, bounds, reverse=self.reverse) (F, kwargs) = to_plot_norm[0] # dot the sorting if required if self.order_by_objectives is not None and self.order_by_objectives is not False: if isinstance(self.order_by_objectives, list) and len( self.order_by_objectives) == self.n_dim: L = self.order_by_objectives elif isinstance(self.order_by_objectives, int): L = [ i for i in range(F.shape[1]) if i != self.order_by_objectives ] L.insert(0, self.order_by_objectives) else: L = range(self.n_dim) _F = [F[:, j] for j in L] I = np.lexsort(_F[::-1]) else: I = np.arange(len(F)) # plot the data self.ax.imshow(F[I], cmap=self.cmap, **self.axis_style) # set the x ticks and labels self.ax.set_xticks(np.arange(self.n_dim)) self.ax.set_xticklabels(self.get_labels()) # no solution labels should be used if self.solution_labels is None: pass # in case just true just use a number for each solution elif isinstance(self.solution_labels, bool) and self.solution_labels: self.solution_labels = np.arange(len(F)) + 1 # otherwise use directly the label provided else: if len(self.solution_labels) != len(F): raise Exception( "The labels provided for each solution must be equal to the number of solutions being plotted." ) if self.solution_labels is None: self.ax.set_yticks([]) self.ax.set_yticklabels([]) else: # for ordered by objective apply it to labels self.solution_labels = [self.solution_labels[i] for i in I] self.ax.set_yticks(np.arange(len(F))) self.ax.set_yticklabels(self.solution_labels)