0

I have a AxesSubplot object ax1 from this:

fig = plt.figure()
ax1 = fig.add_subplot(2, 2, 1)

I plot multiple times on this ax1 to see how alpha values will set the plots' appearance:

first = ax1.hist(np.random.randn(100), bins=20, color='k', alpha=0.3)
second = ax1.hist(np.random.randn(100), bins=20, color='k', alpha=0.6)
third = ax1.hist(np.random.randn(100), bins=20, color='k', alpha=0.9)

But these three plots overlap each other:

How can I erase the former histogram , then only show one plot each time? And by the way, what does the alpha arg do?

Thanks. :)

1 Answer 1

1

If I understand what you want,then try this

import numpy as np
import matplotlib.pyplot as plt

fig = plt.figure()
ax1 = fig.add_subplot(2, 2, 1)
ax2 = fig.add_subplot(2, 2, 2)
ax3 = fig.add_subplot(2, 2, 3)

Output enter image description here

first = ax1.hist(np.random.randn(100), bins=20, color='k', alpha=0.3)
second = ax2.hist(np.random.randn(100), bins=20, color='k', alpha=0.6)
third = ax3.hist(np.random.randn(100), bins=20, color='k', alpha=0.9)

plt.show()
Sign up to request clarification or add additional context in comments.

Comments

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.