擅长:python、mysql、java
<p>您可以选择一个条形图,并设置一个估计器,以百分比定义标准化:</p>
<pre><code>import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
df = pd.DataFrame(dict(x=np.random.poisson(10, 1_000)))
ax = sns.barplot(x="x",
y="x",
data=df,
palette=["teal", "crimson"],
estimator=lambda x: len(x) / len(df) * 100
)
ax.set(xlabel="tenure")
ax.set(ylabel="Percent")
plt.show()
</code></pre>
<p>给予:</p>
<p><a href="https://i.stack.imgur.com/wqWhy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wqWhy.png" alt="enter image description here"/></a></p>