Context: I am using ipython -pylab for interactive figure drawing.
I understand that clf() will erase everything, and cla() will empty the interior of the square plot in the last subfigure.
But I can't see how to clear the first subfigure or the colorbar.
Any changes to the colorbar -- for example, changing ticks or ticklabels -- create an additional colorbar instead of changing the existing one.
Q: How do you change the current axis back to a previous one? e.g., so cla() will clear the first subfigure? or clear a colorbar?
Q: Besides erasing the entire figure and starting afresh, how can one remove or change selected parts of the figure?
Q: is it possible to modify the orientation of cbar once drawn?
following the below code with
leaves it unchanged.
I'm hoping that answers to this will help orient me to 'the matplotlib way.' If I've overlooked some documentation on these issues (I have looked!), please do point it out.
Thank you for your help!
================ Here is my code: ==================
import matplotlib.pyplot as plt
import numpy as np
from time import sleep
x = np.arange(0, 10, 0.2)
y = np.sin(x)
fig = plt.figure()
ax1 = fig.add_subplot(211)
cax1 = ax1.plot(x, y)
ax2 = fig.add_subplot(212)
A = np.random.random_integers(0, 10, 100).reshape(10, 10)
cax2 = ax2.imshow(A, interpolation="nearest",vmin=-1,vmax=11 )
cbar = fig.colorbar(cax2)
#cbar = fig.colorbar(cax2, ticks=[0, 5, 10])