在matplotlib或其他Python库中绘制3D饼图

4 投票
2 回答
16657 浏览
提问于 2025-04-16 02:30

有没有办法在matplotlib中绘制一个3D饼图,或者有没有其他Python库可以生成3D饼图呢?

补充说明:其实我之前就知道pygooglechart这个库,但我想找一个可以离线使用的工具。很抱歉之前没有提到这一点。对于那些推荐pygooglechart的人,感谢你们的努力,我会支持你们的。这个问题仍然开放,欢迎更多的想法。

2 个回答

0
from pychartdir import *

#Data
data = [50, 12, 3,35]

# Labels
labels = ["a", "b", "c", "d"]

# Set pixel
c= PieChart(500, 300)

# set center
c.setPieSize(250, 140, 100)

# Add title
c.addTitle("title")

# Draw
c.set3D()

# Set lebel
c.setData(data, labels)

# Explode all
c.setExplode()

# Output
c.makeChart("threedpie.png")

当然可以!请把你想要翻译的内容发给我,我会帮你用简单易懂的语言解释清楚。

5

当然可以使用 pygooglecharts,这是一个用Python写的工具,可以帮助你使用 Google Charts

PyPi: pygooglechat 0.4.0:发布于2014年4月20日。

GitHub: pygooglechart项目已经停止维护

例如:

from pygooglechart import PieChart3D

def python_pie3D() :
  # initialize chart object, 250 x 250 pixels
  chart = PieChart3D(250, 250)

  # pass your data to the chart object
  chart.add_data([398, 294, 840, 462])

  # make labels for the slices
  chart.set_pie_labels("Lithuania Bulgaria Ukraine Romania".split())

  # render the image
  chart.download('revenue_east_europe.png')

alt text

撰写回答