def finalize(self, **kwargs): """ Finalize executes any subclass-specific axes finalization steps. The user calls poof and poof calls finalize. Parameters ---------- kwargs: generic keyword arguments. """ # Add the title to the plot self.set_title("Residuals for {} Model".format(self.name)) # Set the legend with full opacity patches using manual legend manual_legend(self, self._labels, self._colors, loc="best", frameon=True) # Create a full line across the figure at zero error. self.ax.axhline(y=0, c=self.colors["line"]) # Set the axes labels self.ax.set_ylabel("Residuals") self.ax.set_xlabel("Predicted Value") # Finalize the histogram axes if self.hist: self.hax.axhline(y=0, c=self.colors["line"]) self.hax.set_xlabel("Distribution")
def finalize(self, **kwargs): """ Prepares the plot for renderig by adding a title, legend, and axis labels. Also draws a line at the zero residuals to show the baseline. Parameters ---------- kwargs: generic keyword arguments. Notes ----- Generally this method is called from show and not directly by the user. """ # Add the title to the plot self.set_title("Residuals for {} Model".format(self.name)) # Set the legend with full opacity patches using manual legend manual_legend(self, self._labels, self._colors, loc="best", frameon=True) # Create a full line across the figure at zero error. self.ax.axhline(y=0, c=self.colors["line"]) # Set the axes labels self.ax.set_ylabel("Residuals") self.ax.set_xlabel("Predicted Value") # Finalize the histogram axes if self.hist: self.hax.axhline(y=0, c=self.colors["line"]) self.hax.set_xlabel("Distribution")
def finalize(self): """ Draws legends and colorbar for scatter plots. """ self.ax.set_xticklabels([]) self.ax.set_yticklabels([]) if self.projection == 3: self.ax.set_zticklabels([]) if self._target_color_type == TargetType.DISCRETE: # Add the legend manual_legend(self, self.classes_, list(self._colors.values()), frameon=True) elif self._target_color_type == TargetType.CONTINUOUS: if self.colorbar: if self.projection == 3: sm = plt.cm.ScalarMappable(cmap=self._colors, norm=self._norm) # Avoid MPL TypeError: "You must first set_array for mappable" sm.set_array([]) self.cbar = plt.colorbar(sm, ax=self.ax) else: # Manually draw the colorbar. self.cbar = mpl.colorbar.ColorbarBase(self.cax, cmap=self._colors, norm=self._norm)
def finalize(self, **kwargs): """ Finalize executes any subclass-specific axes finalization steps. The user calls poof and poof calls finalize. Parameters ---------- kwargs: generic keyword arguments. """ # Set the title self.set_title( "Parallel Coordinates for {} Features".format(len(self.features_)) ) # Add the vertical lines # TODO: Make an independent function for override! if self.show_vlines: for idx in self._increments: self.ax.axvline(idx, **self.vlines_kwds) # Set the limits self.ax.set_xticks(self._increments) self.ax.set_xticklabels(self.features_) self.ax.set_xlim(self._increments[0], self._increments[-1]) # Add the legend sorting classes by name labels = sorted(list(self._colors.keys())) colors = [self._colors[lbl] for lbl in labels] manual_legend(self, labels, colors, loc="best", frameon=True) # Add the grid view self.ax.grid()
def finalize(self): """ Add title and modify axes to make the image ready for display. """ self.set_title('{} Manifold (fit in {:0.2f} seconds)'.format( self._name, self.fit_time_.interval)) self.ax.set_xticklabels([]) self.ax.set_yticklabels([]) if self._target_color_type == DISCRETE: # Add the legend manual_legend(self, self.classes_, self._colors) elif self._target_color_type == CONTINUOUS: # Add the color bar plt.colorbar(self._scatter, ax=self.ax)
def finalize(self): """ Add title and modify axes to make the image ready for display. """ self.set_title( '{} Manifold (fit in {:0.2f} seconds)'.format( self._name, self.fit_time_.interval ) ) self.ax.set_xticklabels([]) self.ax.set_yticklabels([]) if self._target_color_type == DISCRETE: # Add the legend manual_legend(self, self.classes_, self._colors) elif self._target_color_type == CONTINUOUS: # Add the color bar plt.colorbar(self._scatter, ax=self.ax)
def finalize(self, **kwargs): """ Finalize executes any subclass-specific axes finalization steps. The user calls poof and poof calls finalize. Parameters ---------- kwargs: generic keyword arguments. """ # Set the title self.set_title("RadViz for {} Features".format(len(self.features_))) # Remove the ticks from the graph self.ax.set_yticks([]) self.ax.set_xticks([]) # Add the legend colors = self.get_colors(self.classes_) manual_legend(self, self.classes_, colors, loc="best")
def finalize(self, **kwargs): """ Finalize the drawing by adding a title and legend, and removing the axes objects that do not convey information about TNSE. """ self.set_title( "TSNE Projection of {} Documents".format(self.n_instances_) ) # Remove the ticks self.ax.set_yticks([]) self.ax.set_xticks([]) # Add the legend outside of the figure box. if not all(self.classes_ == np.array([self.NULL_CLASS])): box = self.ax.get_position() self.ax.set_position([box.x0, box.y0, box.width * 0.8, box.height]) manual_legend( self, self.classes_, self.color_values_, loc='center left', bbox_to_anchor=(1, 0.5) )
def finalize(self, **kwargs): """ Finalize executes any subclass-specific axes finalization steps. The user calls poof and poof calls finalize. Parameters ---------- kwargs: generic keyword arguments. """ # Set the title self.set_title( 'RadViz for {} Features'.format(len(self.features_)) ) # Remove the ticks from the graph self.ax.set_yticks([]) self.ax.set_xticks([]) # Add the legend colors = [self._colors[c] for c in self.classes_] manual_legend(self, self.classes_, colors, loc='best')
def finalize(self, **kwargs): """ Sets the title and adds a legend. Removes the ticks from the graph to make a cleaner visualization. Parameters ---------- kwargs: generic keyword arguments. Notes ----- Generally this method is called from show and not directly by the user. """ # Set the title self.set_title("RadViz for {} Features".format(len(self.features_))) # Remove the ticks from the graph self.ax.set_yticks([]) self.ax.set_xticks([]) # Add the legend colors = self.get_colors(self.classes_) manual_legend(self, self.classes_, colors, loc="best")
def finalize(self, **kwargs): """ Performs the final rendering for the multi-axis visualization, including setting and rendering the vertical axes each instance is plotted on. Adds a title, a legend, and manages the grid. Parameters ---------- kwargs: generic keyword arguments. Notes ----- Generally this method is called from show and not directly by the user. """ # Set the title self.set_title( "Parallel Coordinates for {} Features".format(len(self.features_)) ) # Add the vertical lines # TODO: Make an independent function for override! if self.show_vlines: for idx in self._increments: self.ax.axvline(idx, **self.vlines_kwds) # Set the limits self.ax.set_xticks(self._increments) self.ax.set_xticklabels(self.features_) self.ax.set_xlim(self._increments[0], self._increments[-1]) # Add the legend sorting classes by name labels = sorted(list(self._colors.keys())) colors = [self._colors[lbl] for lbl in labels] manual_legend(self, labels, colors, loc="best", frameon=True) # Add the grid view self.ax.grid()