Another_coder
Another_coder

Reputation: 810

Hide one wedge in a pie chart?

I want to hide one wedge of a pie chart in Matplotlib, but there does not seem to be an option for it in the parameters.

I guess it would be possible to give one bar the same color as the background but that doesn't feel like a reliable solution. Is there a better way?

Upvotes: 1

Views: 585

Answers (1)

gboffi
gboffi

Reputation: 25053

You can manipulate the visibility of any WEDGE in your pie chart. E.g.,

In [36]: import matplotlib.pyplot as plt 
    ...: import numpy as np 
    ...: data = np.arange(5.0)+2.0 
    ...: wedges, labels = plt.pie(data, labels=['a','b','c','d','e']) 
    ...: wedges[3].set_visible(False) 
    ...: plt.show()                                                                       

enter image description here

Upvotes: 3

Related Questions