title: How to display custom values on a bar plot
body: <p>I'm looking to see how to do two things in Seaborn with using a bar chart to display values that are in the dataframe, but not in the graph.</p>
  <ol>
  <li>I'm looking to display the values of one field in a dataframe while graphing another.  For example, below, I'm graphing 'tip', but I would like to place the value of <code>'total_bill'</code> centered above each of the bars (i.e.325.88 above Friday, 1778.40 above Saturday, etc.)</li>
  <li>Is there a way to scale the colors of the bars, with the lowest value of <code>'total_bill'</code> having the lightest color (in this case Friday) and the highest value of <code>'total_bill'</code> having the darkest?  Obviously, I'd stick with one color (i.e., <strong>blue</strong>) when I do the scaling.</li>
  </ol>
  <p>While I see that others think that this is a duplicate of another problem (or two), I am missing the part of how I use a value that is not in the graph as the basis for the label or the shading.  How do I say, use total_bill as the basis.  I'm sorry, but I just can't figure it out based on those answers.</p>
  <p>Starting with the following code,</p>
  <pre><code>import pandas as pd
  import seaborn as sns
  %matplotlib inline
  
  df = pd.read_csv(&quot;https://raw.githubusercontent.com/wesm/pydata-book/1st-edition/ch08/tips.csv&quot;, sep=',')
  groupedvalues = df.groupby('day').sum().reset_index()
  g = sns.barplot(x='day', y='tip', data=groupedvalues)
  </code></pre>
  <p>I get the following result:</p>
  <p><a href="https://i.stack.imgur.com/0GmTW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0GmTW.png" alt="Enter image description here" /></a></p>
  <p>Interim Solution:</p>
  <pre><code>for index, row in groupedvalues.iterrows():
      g.text(row.name, row.tip, round(row.total_bill, 2), color='black', ha=&quot;center&quot;)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/LGily.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LGily.png" alt="Enter image description here" /></a></p>
  <p>On the <em><strong>shading</strong></em>, using the example below, I tried the following:</p>
  <pre><code>import pandas as pd
  import seaborn as sns
  %matplotlib inline
  
  df = pd.read_csv(&quot;https://raw.githubusercontent.com/wesm/pydata-book/1st-edition/ch08/tips.csv&quot;, sep=',')
  groupedvalues = df.groupby('day').sum().reset_index()
  
  pal = sns.color_palette(&quot;Greens_d&quot;, len(data))
  rank = groupedvalues.argsort().argsort()
  g = sns.barplot(x='day', y='tip', data=groupedvalues)
  
  for index, row in groupedvalues.iterrows():
      g.text(row.name, row.tip, round(row.total_bill, 2), color='black', ha=&quot;center&quot;)
  </code></pre>
  <p>But that gave me the following error:</p>
  <blockquote>
  <p>AttributeError: 'DataFrame' object has no attribute 'argsort'</p>
  </blockquote>
  <p>So I tried a modification:</p>
  <pre><code>import pandas as pd
  import seaborn as sns
  %matplotlib inline
  
  df = pd.read_csv(&quot;https://raw.githubusercontent.com/wesm/pydata-book/1st-edition/ch08/tips.csv&quot;, sep=',')
  groupedvalues = df.groupby('day').sum().reset_index()
  
  pal = sns.color_palette(&quot;Greens_d&quot;, len(data))
  rank = groupedvalues['total_bill'].rank(ascending=True)
  g = sns.barplot(x='day', y='tip', data=groupedvalues, palette=np.array(pal[::-1])[rank])
  </code></pre>
  <p>and that leaves me with</p>
  <blockquote>
  <p>IndexError: index 4 is out of bounds for axis 0 with size 4</p>
  </blockquote>