diff --git a/nireports/reportlets/nuisance.py b/nireports/reportlets/nuisance.py index b74b4218..4bc3f5eb 100644 --- a/nireports/reportlets/nuisance.py +++ b/nireports/reportlets/nuisance.py @@ -34,7 +34,6 @@ import pandas as pd import seaborn as sns from matplotlib.backends.backend_pdf import FigureCanvasPdf as FigureCanvas -from matplotlib.colorbar import ColorbarBase from matplotlib.colors import Normalize from matplotlib.gridspec import GridSpec, GridSpecFromSubplotSpec @@ -614,26 +613,6 @@ def spikesplot( return ax -def spikesplot_cb(position, cmap="viridis", fig=None): - # Add colorbar - if fig is None: - fig = plt.gcf() - - cax = fig.add_axes(position) - cb = ColorbarBase( - cax, - cmap=mpl.colormaps[cmap], - spacing="proportional", - orientation="horizontal", - drawedges=False, - ) - cb.set_ticks([0, 0.5, 1.0]) - cb.set_ticklabels(["Inferior", "(axial slice)", "Superior"]) - cb.outline.set_linewidth(0) - cb.ax.xaxis.set_tick_params(width=0) - return cax - - def confoundplot( tseries, gs_ts, @@ -902,8 +881,7 @@ def confounds_correlation_plot( corr = corr.loc[features, features] np.fill_diagonal(corr.values, 0) - if figure is None: - plt.figure(figsize=(15, 5)) + figure = figure if figure is not None else plt.figure(figsize=(15, 5)) gs = GridSpec(1, 21) ax0 = plt.subplot(gs[0, :10]) ax1 = plt.subplot(gs[0, 11:]) @@ -944,7 +922,6 @@ def confounds_correlation_plot( ax1.spines[side].set_visible(False) if output_file is not None: - figure = plt.gcf() figure.savefig(output_file, bbox_inches="tight") plt.close(figure) figure = None @@ -1120,9 +1097,7 @@ def plot_raincloud( df_clip = df.copy(deep=True) df_clip[feature] = df[feature].clip(lower=lower_limit_value, upper=upper_limit_value) - if figure is None: - plt.figure(figsize=(7, 5)) - + figure = figure if figure is not None else plt.figure(figsize=(7, 5)) gs = GridSpec(1, 1) ax = plt.subplot(gs[0, 0]) @@ -1216,7 +1191,6 @@ def plot_raincloud( ) if output_file is not None: - figure = plt.gcf() plt.tight_layout() figure.savefig(output_file, bbox_inches="tight") plt.close(figure) diff --git a/nireports/reportlets/xca.py b/nireports/reportlets/xca.py index 97575fd7..6826f0cb 100644 --- a/nireports/reportlets/xca.py +++ b/nireports/reportlets/xca.py @@ -310,6 +310,7 @@ def compcor_variance_plot( elif len(decompositions) > 1: fig, ax = plt.subplots(1, len(decompositions), figsize=(5 * len(decompositions), 5)) else: + fig = plt.gcf() ax = [plt.axes()] for m, (source, mask) in enumerate(decompositions): @@ -367,8 +368,6 @@ def compcor_variance_plot( ax[m].spines[side].set_visible(False) if output_file is not None: - if fig is None: - fig = plt.gcf() fig.savefig(output_file, bbox_inches="tight") fig.clf() fig = None