how to make rug plot in matplotlib

matplotlib, plot, python

Solution

You can find an example here!

ax = fig.add_subplot(111)

ax.plot(x1, np.zeros(x1.shape), 'b+', ms=20)  # rug plot
x_eval = np.linspace(-10, 10, num=200)
ax.plot(x_eval, kde1(x_eval), 'k-', label="Scott's Rule")
ax.plot(x_eval, kde1(x_eval), 'r-', label="Silverman's Rule")

Seems to be the core of it!

Problem

Im making a density plot with matplotlib and I would also like to get rug plot under it. good example to make density plot is here How to create a density plot in matplotlib? but I couldn't find any good example for rug plot. in R it can be done easly by rug(data).

Original source