Reputation: 1365
How can the following skinny look in a histogram, taken from an article, be achieved based on the Python code below? The histogram bins are noticeably smaller than the plot I made at the bottom. There is also spacing between the bars and no edgecolor
outline
from scipy.stats import dgamma
import matplotlib.pyplot as plt
import seaborn as sns
r = dgamma.rvs(1.1, size=1000)
sns.set_style("white")
sns.set_context("talk")
fig, ax = plt.subplots(figsize=(24,12))
sns.histplot(r, color='deepskyblue', stat='density')
sns.kdeplot(r, color='orange')
plt.title('Seaborn Histplot Example', size=24, fontweight='bold')
sns.histplot(r, color='deepskyblue', stat='density', edgecolor="black")
sns.kdeplot(r, color='orange')
plt.axvline(2.8, 0, 0.95, color='blue')
plt.axvline(2.4, 0, 0.95, color='brown', linestyle='--')
ax.tick_params(left=True, bottom=True)
plt.show()
The code above looks like this:
Upvotes: 2
Views: 5112
Reputation: 545
You can supply a
shrink
argument to your histplot()
function in seaborn. Also to get rid of the edge color, you can simply remove the edgecolor="black"
that you have included in your function call above?
Does this do what you're after?
sns.histplot(r, color='deepskyblue', stat='density', shrink=0.8)
I've also defined a number of bins in the attached image using bins=100
Upvotes: 2