If you want all the bars, just write down the output from the charting method. Its list contains the lines:
import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt fig, ax = plt.subplots() x = np.arange(5) y = np.random.rand(5) bars = ax.bar(x, y, color='grey') bars[3].set_color('g')

If you need the entire Rectangle object in the axes, but it can be more than just bars, use:
bars = [rect for rect in ax.get_children() if isinstance(rect, mpl.patches.Rectangle)]
Rutger kassies
source share