I
I
ichernob2015-06-22 22:28:56
Python
ichernob, 2015-06-22 22:28:56

How to exclude the appearance of black color in the chart?

I build pie charts using the following code:

for k in range(4):
    plt.figure(figsize=(10,10))
    plt.pie(counts[k], labels = tags[k], autopct = '%1.1f%%', pctdistance = 0.8, shadow=False)
    plt.title('Topic ' + str(k + 1) + ':')
plt.show()

Everything is well drawn, but if there are a lot of elements in counts[k], tags[k], some parts of the chart are filled with black. How to exclude black color from fill?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2015-06-22
@ichernob

You can set the colors yourself, as written in the documentation :

pie(x, explode=None, labels=None,
    colors=('b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'),
    autopct=None, pctdistance=0.6, shadow=False,
    labeldistance=1.1, startangle=None, radius=None,
    counterclock=True, wedgeprops=None, textprops=None)

Define your colors array of colors for chart parts

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question