python - matplotlib pie how to set alpha
黄舟
黄舟 2017-06-12 09:25:48
0
1
1049

matplotlib.pyplot.bar has the alpha parameter, but it seems that an error will be reported when using it in pie. The built-in color is too ugly! Ask God for enlightenment!

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(1)
我想大声告诉你

Because I don’t have the code, I’m not sure about your actual situation, but here are some examples with alpha values ​​set

  • polar_bar_demo.py uses bar.set_alpha(...)

  • matplotlib.patches.Patch uses fc=(0, 0, 1, 0.5)
    Basically, it is to find an object to set the alpha value such as XXX.set_aplha() or to give a four-digit tuple when passing parameters to set the facecolor fc value.

See code

# Pie chart, where the slices will be ordered and plotted counter-clockwise:
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
sizes = [15, 30, 45, 10]
explode = (0, 0.1, 0, 0)  # only "explode" the 2nd slice (i.e. 'Hogs')

fig1, ax1 = plt.subplots()
patches, texts, autotexts = ax1.pie(sizes, explode=explode, labels=labels, autopct='%1.1f%%',
        shadow=True, startangle=90)

for i, p in enumerate(patches):
    p.set_alpha(0.25*i)

plt.show()

patches/wedges set_alpha is fine.

See more examples: Wedge

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template