0
import matplotlib.image as mpimg
from scipy.spatial import distance
import matplotlib.patches as mpatches
import pylab
import matplotlib.mlab as mlab
import scipy.stats as ss

fig = plt.figure(num=None, figsize=(9, 7), facecolor='w', edgecolor='k')   
ax = fig.add_subplot(111)
plt.hist(h, bins=30, normed=True)    #h is the data

right now my plot looks like this: enter image description here

I want to add a trend line to reflect the histogram. To reflect the peak of each bin. So tried what fuglede suggested, using seaborn, I got something that is really weird. enter image description here

I dont know why suddenly with the seaborn imported, my plot has those weird grey grids going on. I'm using Sypder btw. Second, I want to have a smooth like, not like the one I have right now just going up and down.

1
  • Closed to the other question because displot has been removed from seaborn. Answers in the duplicate already discuss the updated opitons. Commented May 25, 2023 at 21:54

1 Answer 1

3

It sounds like you might be looking for something like a kernel density estimate. An off-the-shelf KDE calculator/plotter with a simple API is available in Seaborn.

import numpy as np
import seaborn as sns

data = np.random.normal(0, 1, 100)
sns.distplot(data)

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.