title: Python - Modify Python Script to Exclude a Specific Row from Color Ramp in a Seaborn Heatmap
body: <p>I need assistance with my Python code.</p>
  <p>The code displayed below reads data from a csv file (I'm providing a link to the dataset), which generates a seaborn heatmap (attached below). The visualization shows the monthly and annual rainfall averages (y-axis) from 2011–2021 (x-axis) for a specific location.</p>
  <p>Notice that the bottom of the heatmap on row 13, the annual averages are displayed for each year.</p>
  <p>I'm trying to adjust my code so the annual average row stands out to my readers. Therefore, I don't want the color ramp to apply to the annual averages for this row.</p>
  <p>So I think I need to mask the bottom row with a different color. Can anyone assist?</p>
  <p>Content:</p>
  <ol>
  <li><p>Precip Data (<a href="https://raw.githubusercontent.com/cartopher/data/main/precip.csv" rel="nofollow noreferrer">https://raw.githubusercontent.com/cartopher/data/main/precip.csv</a>)</p>
  </li>
  <li><p>The entire script (displayed below)</p>
  </li>
  <li><p><a href="https://i.stack.imgur.com/vGHwm.png" rel="nofollow noreferrer">Current Heatmap</a></p>
  </li>
  </ol>
  <pre><code> # import modules
  import pandas as pd
  import matplotlib.pyplot as plt
  from matplotlib.backends.backend_pdf import PdfPages
  import seaborn as sns
  # load historic precip. data &amp; create pandas dataframe
  df = pd.read_csv(&quot;/main/home/precip.csv&quot;)
  df.fillna(method=&quot;bfill&quot;, inplace=True)
  df
  # create subset with selected variables
  df_month = df[[&quot;Year&quot;, &quot;Jan.&quot;, &quot;Feb.&quot;, &quot;Mar.&quot;, &quot;Apr.&quot;, &quot;May&quot;, &quot;Jun.&quot;, &quot;Jul.&quot;, &quot;Aug.&quot;, 'Sept.', 'Oct.', 'Nov.', 'Dec.', 'Annual Avg.']]
  df_month.head()
  df_grouped = df.groupby([&quot;Year&quot;]).mean().round(2)
  df_grouped.head()
  # create heatmap
  with PdfPages('Bamberger Precipitation Heatmap.pdf') as pdf:
      fig = plt.figure(figsize=(14, 10)) 
  
      cmap = sns.diverging_palette(20, 145, sep=77, as_cmap=True)
      sns.heatmap(df_grouped.T,
              linecolor=('0.8'),
              linewidth=0.1,
              robust=True, 
              annot=True,
              cmap=cmap,
              linewidths=1,  
              cbar_kws={'shrink':.8,
                             'label':'Precipitation (mm)'})
  
  # set title &amp; preferences
      plt.title('  Bamberger''\n', loc='center', fontsize=26, fontweight=&quot;bold&quot;)
   
  # set subtitle &amp; preferences
      plt.title('                 Average Annual Precipitation in Millimeters', loc='left', fontsize=20)
  
  # x-axis title &amp; preferences
      plt.xticks(fontsize=12)
      plt.xlabel('\n''Period: 2011 - 2021', fontsize=16)
  
  # y-axis title &amp; preferences
      plt.yticks(rotation = 0, fontsize=12)
      plt.ylabel('Monthly Averages               ', rotation = 90, fontsize=16)
  
  # add location information
      plt.annotate('          Precipitation Report (10-Years)''\n''          Bamberger: 30.2060, -98.4494    ''\n''2341 Blue Ridge Dr Johnson City, TX 78636                    ', (0,0), (425, -40), fontsize=9, color='#636363',
                   xycoords='axes fraction', textcoords='offset points', va='top')
      
  # cite source &amp; set preferences
      plt.annotate('Creation Date: 07 Jul. 2022''\n''Data Source: NSA ''\n''https://power.larc.nasa.gov/data-access-viewer/', (0,0), (1, -45), fontsize=9, color='#636363',
                   xycoords='axes fraction', textcoords='offset points', va='top')
  
  # save the heatmap
      pdf.savefig(fig)
      plt.close()
      
  fig# create heatmap
  with PdfPages('Bamberger Precipitation Heatmap.pdf') as pdf:
      fig = plt.figure(figsize=(14, 10)) 
  
      cmap = sns.diverging_palette(20, 145, sep=77, as_cmap=True)
      sns.heatmap(df_grouped.T,
              linecolor=('0.8'),
              linewidth=0.1,
              robust=True, 
              annot=True,
              cmap=cmap,
              linewidths=1,  
              cbar_kws={'shrink':.8,
                             'label':'Precipitation (mm)'})
  
  # set title &amp; preferences
      plt.title('  Bamberger''\n', loc='center', fontsize=26, fontweight=&quot;bold&quot;)
   
  # set subtitle &amp; preferences
      plt.title('                 Average Annual Precipitation in Millimeters', loc='left', fontsize=20)
  
  # x-axis title &amp; preferences
      plt.xticks(fontsize=12)
      plt.xlabel('\n''Period: 2011 - 2021', fontsize=16)
  
  # y-axis title &amp; preferences
      plt.yticks(rotation = 0, fontsize=12)
      plt.ylabel('Monthly Averages               ', rotation = 90, fontsize=16)
  
  # add location information
      plt.annotate('          Precipitation Report (10-Years)''\n''          Bamberger: 30.2060, -98.4494    ''\n''2341 Blue Ridge Dr Johnson City, TX 78636                    ', (0,0), (425, -40), fontsize=9, color='#636363',
                   xycoords='axes fraction', textcoords='offset points', va='top')
      
  # cite source &amp; set preferences
      plt.annotate('Creation Date: 07 Jul. 2022''\n''Data Source: NSA ''\n''https://power.larc.nasa.gov/data-access-viewer/', (0,0), (1, -45), fontsize=9, color='#636363',
                   xycoords='axes fraction', textcoords='offset points', va='top')
  
  # save the heatmap
      pdf.savefig(fig)
      plt.close()
  
  # display heatmap    
  
      fig
  </code></pre>