Overwrite a transparent histogram using matplotlib in Python.
histgram.py
import numpy as np
import matplotlib.pyplot as plt
a = np.random.randn(10000)
plt.figure()
plt.hist(a-1, bins=100, alpha=0.3, histtype='stepfilled', color='r')
plt.hist(a+1, bins=100, alpha=0.3, histtype='stepfilled', color='b')
plt.show()
You can adjust the transparency with alpha. 0 is completely transparent. 1 for transparency 0.
Execution result
Recommended Posts