不需要安装 Visual Studiomatplotlib
。为了获得最佳结果,首先从 python.org 安装 Python,32 位或 64 位,具体取决于您的计算机体系结构和您运行的 Windows 版本(例如,即使您有 64 位处理器,如果您正在运行 32 位 Windows,请下载 32 位 Python)。版本并不特别重要,我更喜欢 3.3.3,但更多的软件包与 2.7.6 兼容,所以你可以选择。 Matplotlib 及其依赖项均可用于任一版本。
接下来,前往 Christoph Gohlke's适用于 Windows 的 Python 扩展包并下载适合您的 Python 版本的以下软件包:
- matplotlib
- numpy
- python-dateutil
- pytz
- pyparsing
- six
- Pillow
- tornado
- pyside
- pyqt
这些软件包都是自解压安装程序。以任意顺序运行它们,完成后您应该能够正常导入和使用 matplotlib。
饼图程序示例,来自here:
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()