# Plot colorbar for pseudocolored images

import os

def plot_colorbar(outdir, filename, bins):
    """Plot colorbar for pseudocolored images

    Inputs:
    outdir   = Output directory
    filename = Figure filename
    bins     = Number of bins for color mapping

    :param outdir: str
    :param filename: str
    :param bins: int
    :return:
    """
    import matplotlib
    matplotlib.use('Agg', warn=False)
    from matplotlib import pyplot as plt
    from matplotlib import colors as colors
    from matplotlib import colorbar as colorbar

    fig_name = os.path.join(outdir, filename)
    fig = plt.figure()
    ax1 = fig.add_axes([0.05, 0.80, 0.9, 0.15])
    valmin = -0
    valmax = (bins - 1)
    norm = colors.Normalize(vmin=valmin, vmax=valmax)
    colorbar.ColorbarBase(ax1, cmap="viridis", norm=norm, orientation='horizontal')
    fig.savefig(fig_name, bbox_inches='tight')
    fig.clf()

@@ -35,16 +35,18 @@
 images%0A%0A
+# 
 import o
@@ -47,17 +47,20 @@
 port os%0A
-%0A
+#%0A# 
 def plot
@@ -94,16 +94,18 @@
  bins):%0A
+# 
     %22%22%22P
@@ -142,17 +142,20 @@
  images%0A
-%0A
+#%0A# 
     Inpu
@@ -158,16 +158,18 @@
 Inputs:%0A
+# 
     outd
@@ -192,16 +192,18 @@
 rectory%0A
+# 
     file
@@ -225,16 +225,18 @@
 ilename%0A
+# 
     bins
@@ -275,17 +275,20 @@
 mapping%0A
-%0A
+#%0A# 
     :par
@@ -298,24 +298,26 @@
 outdir: str%0A
+# 
     :param f
@@ -329,16 +329,18 @@
 me: str%0A
+# 
     :par
@@ -352,16 +352,18 @@
 ns: int%0A
+# 
     :ret
@@ -371,16 +371,18 @@
 rn:%0A
+# 
     %22%22%22%0A
     
@@ -377,20 +377,22 @@
     %22%22%22%0A
+#
     
+ 
 import m
@@ -401,16 +401,18 @@
 plotlib%0A
+# 
     matp
@@ -441,20 +441,22 @@
 =False)%0A
+#
     
+ 
 from mat
@@ -484,16 +484,18 @@
  as plt%0A
+# 
     from
@@ -530,16 +530,18 @@
  colors%0A
+# 
     from
@@ -580,21 +580,24 @@
 olorbar%0A
-%0A
+#%0A#
     
+ 
 fig_name
@@ -630,16 +630,18 @@
 lename)%0A
+# 
     fig 
@@ -655,16 +655,18 @@
 igure()%0A
+# 
     ax1 
@@ -705,16 +705,18 @@
  0.15%5D)%0A
+# 
     valm
@@ -723,16 +723,18 @@
 in = -0%0A
+# 
     valm
@@ -749,20 +749,22 @@
 ns - 1)%0A
+#
     
+ 
 norm = c
@@ -805,16 +805,18 @@
 valmax)%0A
+# 
     colo
@@ -891,20 +891,22 @@
 ontal')%0A
+#
     
+ 
 fig.save
@@ -940,16 +940,18 @@
 tight')%0A
+# 
     fig.

comment out plot_colorbar