Reputation: 1719
I have a histogram of my data: h is a 1-d array of counts x is a 1-d array of bin values
Now if I do: sns.kdeplot(h, shade=True);
I get a plot where x-axis goes from -20 to 100, which has nothing to do with my original x data. How do I get the x-axis scaled to match my data?
Upvotes: 2
Views: 1375
Reputation: 1719
I see I misunderstood the input to kde. It wants the original values. I had already created a histogram and wanted to feed that to kde.
In my histogram I have h.buckets, and h.results. I did
def hist_to_values (hist):
ret = []
for x,y in zip (hist.buckets, h.results):
ret.extend ([x] * y)
return np.array (ret)
Then feed this to kde, and I got the results I expect.
Upvotes: 2