I want to plot a histogram with a contour like this 
I found this picture in here, but after following the same procedure there I don't get the contour.
I saw this question in stack overflow but it draws an edge over each bar, and I want only the outer contour.
How can I draw this outer contour? (I'm running python 3)
The plot is probably produced with a different (i.e. older) matplotlib version. This can also be seen from the use of normed, which is deprecated in newer versions.
Here, you would explicitely set the edgecolor to black.
ec="k", or longer, edgecolor="black".
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('seaborn-white')
x1 = np.random.normal(0, 0.8, 1000)
x2 = np.random.normal(-2, 1, 1000)
x3 = np.random.normal(3, 2, 1000)
kwargs = dict(histtype='stepfilled', alpha=0.3, density=True, bins=40, ec="k")
plt.hist(x1, **kwargs)
plt.hist(x2, **kwargs)
plt.hist(x3, **kwargs);
plt.show()

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With