SavaLLL
SavaLLL

Reputation: 39

Labels on plot pie so close

I`m run this:

import matplotlib.pyplot as pl
from matplotlib import rc
import pandas as pd
data = pd.read_csv("data.csv",";")
data["count"].plot(kind='pie',subplots=True,colors=['#0099FF','#0089e5','#007acc','#006bb2','#005b99'],labels=data["name"],autopct='%.2f')
plt.axis('equal')

And get pie plot, all good, but lables on plot so close. How I can fix it?
My Plot enter image description here

Upvotes: 4

Views: 2118

Answers (1)

screenpaver
screenpaver

Reputation: 1130

A couple of options might be to explode the plot and/or move the percent labels by pctdistance. (For full details see the docs.)

pctdistance sets the distance of the percentage labels as a fraction of the radius. So 1.1 will place the labels just outside the pie. 0.9 will place them just inside.

For example:

data["count"].plot(kind='pie',subplots=True,colors=['#0099FF','#0089e5','#007acc','#006bb2','#005b99'],labels=data["name"],
    autopct='%.2f', pctdistance=0.9,
    explode=len(data["count"])*[0.2])

Upvotes: 2

Related Questions