Python - How to hide labels and keep legends matplotlib?
<p>I would like to remove the labels of a pie chart and keep the legends only. Currently, my code has both. Any idea how to remove the labels?</p>

<p>I've tried the code below: </p>

<pre><code>plt.legend(labels, loc="best") 

and 

labels=None 
</code></pre>

<p>Bu didn't work.</p>

<p>My full code is:</p>

<pre><code>plt.pie(percent,              # data
    explode=explode,    # offset parameters 
    labels=country,      # slice labels
    colors=colors,      # array of colours
    autopct='%1.0f%%',  # print the values inside the wedges - add % to the values 
    shadow=True,        # enable shadow
    startangle=70       # starting angle
    )

plt.axis('equal')
plt.title('Top 5 Countries', y=1.05, fontsize=15) #distance from plot and size
plt.legend( loc="best") 
plt.tight_layout()

countrypie = "%s_country_pie.png" % pname
plt.savefig(countrypie)
</code></pre>

<p>Thanks for your input</p>

<p>If I understand your question correctly this should solve it. 
Removing the labels from the pie chart creation and adding the labels to the legend - </p>

<pre class="lang-py prettyprint-override"><code>plt.pie(percent,              # data
    explode=explode,    # offset parameters 
    colors=colors,      # array of colours
    autopct='%1.0f%%',  # print the values inside the wedges - add % to the values 
    shadow=True,        # enable shadow
    startangle=70       # starting angle
    )

plt.axis('equal')
plt.title('Top 5 Countries', y=1.05, fontsize=15) #distance from plot and size
plt.legend(loc="best", labels=country) 
plt.tight_layout()

countrypie = "%s_country_pie.png" % pname
plt.savefig(countrypie)
</code></pre>

python matplotlib legend pie-chart