<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import seaborn as sns;sns.set()
import matplotlib.pyplot as plt
penguins = sns.load_dataset(&quot;penguins&quot;)
# sns.displot(data=penguins, x=&quot;flipper_length_mm&quot;,label='policy_0',kind=&quot;hist&quot;)
sns.histplot(data=penguins, x=&quot;flipper_length_mm&quot;,label='policy_1')
plt.legend()
plt.savefig(&quot;test.png&quot;)"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">seaborn</span> <span class="pl-k">as</span> <span class="pl-s1">sns</span>;<span class="pl-s1">sns</span>.<span class="pl-en">set</span>()
<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>
<span class="pl-s1">penguins</span> <span class="pl-c1">=</span> <span class="pl-s1">sns</span>.<span class="pl-en">load_dataset</span>(<span class="pl-s">"penguins"</span>)
<span class="pl-c"># sns.displot(data=penguins, x="flipper_length_mm",label='policy_0',kind="hist")</span>
<span class="pl-s1">sns</span>.<span class="pl-en">histplot</span>(<span class="pl-s1">data</span><span class="pl-c1">=</span><span class="pl-s1">penguins</span>, <span class="pl-s1">x</span><span class="pl-c1">=</span><span class="pl-s">"flipper_length_mm"</span>,<span class="pl-s1">label</span><span class="pl-c1">=</span><span class="pl-s">'policy_1'</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">legend</span>()
<span class="pl-s1">plt</span>.<span class="pl-en">savefig</span>(<span class="pl-s">"test.png"</span>)</pre></div>
<p dir="auto">By running belowing codes, I got a figure like:</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/39483938/200516845-de61003e-becf-4459-8872-90a675ffb631.png"><img width="636" alt="image" src="https://user-images.githubusercontent.com/39483938/200516845-de61003e-becf-4459-8872-90a675ffb631.png" style="max-width: 100%;"></a></p>
<p dir="auto">It seems to repeat the legends, could you fixed it soon? It will be pretty nice of you!</p>
<p dir="auto">Consider data points that describe:</p>
<ul dir="auto">
<li>different animal species</li>
<li>each specie lives across different countries</li>
<li>a population for each specie in each country</li>
</ul>
<p dir="auto">The current plotting histograms considers each bin (animal specie) as a full collection of data and each hue (country) as separate <em>histograms</em>.<br>
Since each specie is decoupled one would like to do something like this:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="sns.histplot(population, x='specie', hue='country', stat='probability')"><pre class="notranslate"><span class="pl-s1">sns</span>.<span class="pl-en">histplot</span>(<span class="pl-s1">population</span>, <span class="pl-s1">x</span><span class="pl-c1">=</span><span class="pl-s">'specie'</span>, <span class="pl-s1">hue</span><span class="pl-c1">=</span><span class="pl-s">'country'</span>, <span class="pl-s1">stat</span><span class="pl-c1">=</span><span class="pl-s">'probability'</span>)</pre></div>
<p dir="auto">however this will not decouple the species from each other. What would be nice if one could normalize each specie individually across the countries, aka:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="sns.histplot(population, x='specie', hue='country', stat='probability', bin_norm=True, common_norm=True)"><pre class="notranslate"><span class="pl-s1">sns</span>.<span class="pl-en">histplot</span>(<span class="pl-s1">population</span>, <span class="pl-s1">x</span><span class="pl-c1">=</span><span class="pl-s">'specie'</span>, <span class="pl-s1">hue</span><span class="pl-c1">=</span><span class="pl-s">'country'</span>, <span class="pl-s1">stat</span><span class="pl-c1">=</span><span class="pl-s">'probability'</span>, <span class="pl-s1">bin_norm</span><span class="pl-c1">=</span><span class="pl-c1">True</span>, <span class="pl-s1">common_norm</span><span class="pl-c1">=</span><span class="pl-c1">True</span>)</pre></div>
<p dir="auto">which normalizes across hues for each bin plot. This would make all bin sizes equal height of 1, but the hue for each will show the probability distribution for the specie population and clearly indicate which specie has a tendency in each country.</p>
<p dir="auto">I agree this isn't the regular histogram, but perhaps it would fit seaborn anyways? :)</p>