0

I found a nice code snippet for a pie chart on Stackoverflow.

enter image description here

import matplotlib.pyplot as plt

group_size = [10, 10, 10, 10, 10, 50]

labels = ['AAAA', 'BBBB', 'CCCC', 'DDDD', 'EEEE', '']
fig, ax = plt.subplots()

ax.axis('equal')

pie = ax.pie(
    group_size,
    radius=2.2,
    colors=['k'],
    startangle=180,
    counterclock=False
    )

pie2 = ax.pie(
    [10, 10, 10, 10, 10, 50],
    radius=2,
    labeldistance=0.9,
    labels=labels,
    rotatelabels=True,
    startangle=180,
    counterclock=False
    )

plt.setp(
    pie2[1],
    rotation_mode="anchor",
    ha="center",
    va="center"
    )

for tx in pie2[1]:

    rot = tx.get_rotation()

    tx.set_rotation(rot+90+(1-rot//180)*180)

plt.show()

Now, I would like to add white lines between the individual tiles of the chart. I tried via linecolor='white in the ax.pie() part. However, this returns the following error: TypeError: Axes.pie() got an unexpected keyword argument 'linecolor'. How can I add a white line between the individual parts?

Stücke
  • 868
  • 3
  • 14
  • 41
  • 2
    I think you need to pass a `wedgeprops` argument with a dictionary of [wedge parameters](https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.Wedge.html#matplotlib.patches.Wedge), e.g., `ax.pie(..., wedgeprops={"edgecolor": "white"}, ...)` – Matt Pitkin Mar 09 '23 at 10:10

0 Answers0