Reputation: 45
I know how to make histograms but I wanted to reproduce this image:
The original is form a PNAS (journal) paper by Andrew Karplus et al. 2011.
I have the following image from my own histogram:
I have the following questions:
1) How can I start the plot with histogram smoothed out?
2) How can I superimpose but yet not distort the color as I have done in my plot (2nd image), that is omit the points in the exterior plot that are in the interior one as well to produce a clean superimposition?
Upvotes: 0
Views: 624
Reputation: 879451
You could use fill_between
:
import numpy as np
import matplotlib.pyplot as plt
def gaussian(x, x0, y0, variance):
return y0 * np.exp(-(x - x0) ** 2 / variance)
x = np.linspace(150, 210, 100)
plt.fill_between(x, 0, gaussian(x, 180, 5000, 30), color='red', zorder=0)
plt.fill_between(x, 0, gaussian(x, 181, 4500, 10), color='blue', zorder=1)
plt.show()
yields
Above I used gaussian
to generate a substitute for your data; you can replace gaussian(...)
with your actual histogram values.
Upvotes: 1