From f8dafd4207f483987ba69cd726cce4747bead5f7 Mon Sep 17 00:00:00 2001 From: wiheto Date: Mon, 4 Apr 2022 13:18:24 +0200 Subject: [PATCH] style --- README.md | 1 - netplotbrain/plot.py | 2 +- netplotbrain/plotting/plot_gif.py | 18 +++++++++--------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index f6d7d7c..0f2aeff 100644 --- a/README.md +++ b/README.md @@ -311,7 +311,6 @@ plt.show() ### Plotting a rotating GIF - ```python netplotbrain.plot(template='MNI152NLin2009cAsym', templatestyle='surface', diff --git a/netplotbrain/plot.py b/netplotbrain/plot.py index 77c438c..5e20dac 100644 --- a/netplotbrain/plot.py +++ b/netplotbrain/plot.py @@ -212,7 +212,7 @@ def plot(nodes=None, fig: Optional[plt.Figure]=None, ax=None, view: str='L', fra ax_out.append(ax) # Add legends to plot - if legends is not None and profile['gif'] == False: + if legends is not None and profile['gif'] is False: for li, legend in enumerate(legends): # setup legend subplot. Goes in centre or centre2 subplots spind = gridspec.ncols diff --git a/netplotbrain/plotting/plot_gif.py b/netplotbrain/plotting/plot_gif.py index c19a6d6..ecd2db3 100755 --- a/netplotbrain/plotting/plot_gif.py +++ b/netplotbrain/plotting/plot_gif.py @@ -16,9 +16,9 @@ def _plot_gif(fig, ax, gifduration, savename=None, gif_loop=0): ax : list of subplot axes fig : matplotlib figure - + gifduration: each frame in ms, int (600 is suggested) - + gif_loop: number of loops, int If 0, it becomes an infinite loop @@ -26,17 +26,17 @@ def _plot_gif(fig, ax, gifduration, savename=None, gif_loop=0): Name of the saved GIF """ - + #Ensure that savename ends in gif - if savename is None: + if savename is None: raise ValueError('savename must be specified to save gif') - # Add give to end of the - if savename.endswith('.gif') == False: + # Add give to end of the + if savename.endswith('.gif') is False: savename += '.gif' #saving matplotlib figures (frame images) to buffer and opening in PIL Image objects images = [] - + for i, current_ax in enumerate(ax): extent = current_ax.get_window_extent().transformed(fig.dpi_scale_trans.inverted()) buf = io.BytesIO() @@ -44,6 +44,6 @@ def _plot_gif(fig, ax, gifduration, savename=None, gif_loop=0): buf.seek(i) img = Image.open(buf).convert('RGBA') images.append(img) - + images[0].save(savename, - save_all=True, append_images=images[1:], optimize=False, duration=gifduration, loop=gif_loop) + save_all=True, append_images=images[1:], optimize=False, duration=gifduration, loop=gif_loop)