0
plt.figure()
mu = 0
variance = 1
sigma = math.sqrt(variance)
x = np.linspace(0, 2, 100)
plt.plot(x,mlab.normpdf(x, mu, sigma))
plt.show()
movieRates.plot.hist(stacked=True)

This is what I am trying out but it does not work it gives me a figure 1 and a figure 2. I tried to find an answer but I could not really get anything out of the other examples since they were different from mine. What I am trying to achieve is to show that the movieRates have a normal distribution. That is why I'd like to join those figures together. But I had no luck untill now.

5
  • You want to overlay the plots. There are many answers that deal with this. stackoverflow.com/questions/31104867/… Commented Apr 11, 2017 at 22:19
  • 1
    Possible duplicate of How to superimpose figures in matplotlib Commented Apr 11, 2017 at 22:20
  • @ShawnMehan yes I have been looking at them but did not know what fig or ax means that is why I did not know how to do that in my case Commented Apr 11, 2017 at 22:22
  • @ShawnMehan I also have a pandas plot so idk how to do ax.plot() with pandas Commented Apr 11, 2017 at 22:24
  • 1
    "read the source". Always, always, always. You will answer your own questions and learn so much more. Commented Apr 11, 2017 at 22:38

1 Answer 1

1

Let's use plt.gca() and then use the ax argument of pandas plot.

plt.figure()
mu = 0
variance = 1
sigma = math.sqrt(variance)
x = np.linspace(0, 2, 100)
plt.plot(x,mlab.normpdf(x, mu, sigma))
ax = plt.gca()
movieRates.plot.hist(stacked=True,ax=ax)
plt.show()
Sign up to request clarification or add additional context in comments.

1 Comment

thanks a lot :D I just did not knew where to put the ax in pandas

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.