How to separate thousands with commas using Facet Grid in Seaborn
<p>I have the following code:</p>

<pre><code>    d = sns.FacetGrid(data = df,
                      col = 'Company',
                      sharex = False,
                      sharey = False,
                      col_wrap = 4)
    d.map(sns.distplot, 'Volume', kde = False, rug = True, fit = stats.norm)
    d.set_xlabels('volume')
    d.set_xticklabels(rotation = 45)
    plt.savefig(myDataRepository + 'figure_02__' + str(time_stamp) + '.png')
    ax.get_xaxis().set_major_formatter(
         matplotlib.ticker.FuncFormatter(lambda x, p: format(int(x), ',')))
</code></pre>

<p>The last two lines attempt to separate the x-axis values with commas.  For example, '500,000' instead of '500000'.</p>

<p>I see an error message saying:</p>

<pre><code>"global name ax is not defined"
</code></pre>

<p>How would I amend <code>ax.</code> such that I can format the x-axis values with comma separation?</p>

<p>Thanks in advance!</p>

<p><strong>---EDIT BELOW---</strong></p>

<p>Here is updated code that I'm posting.  It still fails, but this time with error message <code>@property</code> when evaluating </p>

<pre><code>d.ax.get_xaxis().set_major_formatter(tkr.FuncFormatter(lambda x, p: format(int(x), ',')))
</code></pre>

<p>Revised Code:    </p>

<pre><code>fig, ax = plt.subplots()

d = sns.FacetGrid(data = df,
                  col = 'Company',
                  sharex = False,
                  sharey = False,
                  col_wrap = 4)
d.map(sns.distplot, 'Volume', kde = False, rug = True, fit = stats.norm)
d.set_xlabels('volume')
d.set_xticklabels(rotation = 45)
plt.savefig(myDataRepository + 'figure_02__' + str(time_stamp) + '.png')

d.ax.get_xaxis().set_major_formatter(tkr.FuncFormatter(lambda x, p: format(int(x), ',')))
</code></pre>

<p><code>@cphlewis</code> is suggesting that I put the ax.get_axis() inside the Facet Grid.  But how???</p>

<p>Putting <code>ax.get_axis()</code> inside the FacetGrid does not seem to solve this problem (assuming I did so correctly).  Is it even <em>possible</em> to use this <code>ax.get_axis()</code> function with the Seaborn FacetGrid?</p>

<p>The error message:</p>

<pre><code>    971             return self.axes[0, 0]
    972         else:
--&gt; 973             raise AttributeError
    974 
    975     @property

AttributeError: 
</code></pre>

<p>Specify the <code>ax</code> inside the <code>FacetGrid</code>:</p>

<pre><code>df = random((5, 5))
d = sns.FacetGrid(data=df)
dir(d.ax.get_xaxis())
</code></pre>

<p>and aha, <code>get_major_formatter</code> is in that list. </p>

python matplotlib seaborn facet