我一直试图使用python生成一个简单的饼图,只使用两个变量.代表百分比.我总是"vcvarsall.bat" not found
在安装matplotlib
包时遇到错误.是不是已经不可避免地要安装Visual Studio了?
Visual Studio不需要安装matplotlib
.为了获得最佳结果,首先从python.org安装Python,32位或64位,具体取决于您的计算机的体系结构和您运行的Windows版本(例如,即使您有64位处理器,如果您'重新运行32位Windows,下载32位Python).版本并不特别重要,我更喜欢3.3.3,但更多的软件包与2.7.6兼容,所以请选择.Matplotlib及其依赖项都可用于任一版本.
接下来,转到Christoph Gohlke的Windows Python扩展包,并为您的Python版本下载以下包:
matplotlib
numpy
python-dateutil
pytz
pyparsing
six
Pillow
tornado
pyside
pyqt
这些包都是自解压安装程序.以任何顺序运行它们,当你完成后,你应该能够导入并使用matplotlib就好了.
一个示例饼图程序,从这里:
from pylab import * # make a square figure and axes figure(1, figsize=(6,6)) ax = axes([0.1, 0.1, 0.8, 0.8]) # The slices will be ordered and plotted counter-clockwise. labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' fracs = [15, 30, 45, 10] explode=(0, 0.05, 0, 0) pie(fracs, explode=explode, labels=labels, autopct='%1.1f%%', shadow=True, startangle=90) # The default startangle is 0, which would start # the Frogs slice on the x-axis. With startangle=90, # everything is rotated counter-clockwise by 90 degrees, # so the plotting starts on the positive y-axis. title('Raining Hogs and Dogs', bbox={'facecolor':'0.8', 'pad':5}) show()