简体   繁体   中英

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?

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

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()                                                                       

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM