I want to access the face color of a bar container object returned by plt.bar(). If the bar() data is not empty, I can do:
bc = plt.bar(1,1)
bc.get_children()[0].get_fc()
However if the data is empty, I can’t do that because the get_children() method returns an empty list, as it should. BUT, it seems like the color cycler is still cycled through once even though nothing gets plotted. For example, doing:
x = np.random.normal(0,1,500)
hist,edges = np.histogram(x,bins=50)
x = (edges[1:]+edges[:-1])/2
bc1 = plt.bar([],[])
bc2 = plt.bar(x,hist)
Only bc2 appears, and appears with the second color of the color cycler ‘C2’. So bc1 was assigned color ‘C1’, but I can’t know this because it has no bar children. Is there another way to access the color of an empty bar container?