#160 Basic donut plot

 

 

 

 

Here is a basic donut (?doughnut) plot made using the matplotlib library.

The trick here is to make a pieplot and add a white circle in the middle of it. Note that another option would be to use the radius and width arguments (see graph #163).

In the next post we’ll see how to custom it, add annotations…

 

 

 

 


# library
import matplotlib.pyplot as plt

# create data
size_of_groups=[12,11,3,30]

# Create a pieplot
plt.pie(size_of_groups)
#plt.show()

# add a circle at the center
my_circle=plt.Circle( (0,0), 0.7, color='white')
p=plt.gcf()
p.gca().add_artist(my_circle)

plt.show()

Leave a Reply

Your email address will not be published.