I write a code to create a heatmap with seaborn, but the result has a duplication of the…
- User
I write a code to create a heatmap with seaborn, but the result has a duplication of the scale bar. What is the error?\\def plot_heatmap(evals, eval, title, fig_dir, fig_name, show, metadata=None, index: str = "num_train_models", column: str = "percentage", vmin: float = 0, vmax: float = 1, min_rows: int = None, ascending_index: bool = True, annot: bool = True, log_scale: bool = False, verbose=False): evals = evals.drop_duplicates(subset=[index, column]) if evals.empty: return pivot = evals.pivot(index=index, columns=column, values=eval) pivot = pivot.sort_values(index, ascending=ascending_index) if pivot.dropna().empty: if verbose: print(f"Skipping {title}, empty: {pivot}") return if min_rows and len(pivot.dropna(axis=0, how='all')) < min_rows: if verbose: print(f"Skipping {title}, no different scales of smaller models {pivot}") return ax = sns.heatmap(100 pivot, annot=annot, vmin=100 vmin if pd.notna(vmin) else None, vmax=100 * vmax if pd.notna(vmax) else None, norm=LogNorm() if log_scale else None, ax=ax) if title: ax.set_title(title) capitalize_fig(ax) if fig_dir and fig_name: os.makedirs(fig_dir, exist_ok=True) plt.savefig(os.path.join(fig_dir, fig_name), bbox_inches="tight") if show: plt.show() plt.clf() \\
Assistant