Python图表软件包ChartDirector的安装和使用
2014-08-18 23:28
881 查看
Python图表软件包ChartDirector的安装和使用
分类: Python2013-01-0716:40 1073人阅读 评论(0) 收藏 举报
转载自http://zj.he.blog.163.com/blog/static/1068286472010925104915276/
Python平台好的图表软件不多,ChartDirector是其中较好的一个,功能丰富,使用简单,特在此分享一下安装和使用经验。
使用环境:
SUSE Enterprise Server 11
Python2.6
一、安装
1、从http://www.advsofteng.com/下载最新版安装包并解压缩
ChartDirector for Python - Software and HTML Doc | Linux (i386) | 7.3 MB |
3、将ChartDirector/lib子目录下文件复制到/usr/local/lib/python2.6/site_packages/chartdirector目录下
4、在/usr/local/lib/python2.6/site_packages/chartdirector目录下建立chartdirector.pth文件,文件内容如下:
# chartdirector packages configuration
chartdirector
5、验证安装是否成功,在python Shell中执行
>>>from pychartdir import *
如果命令正常执行,表示安装成功
二、中文问题的解决
1、安装中文字体文件
将中文字体文件mingliu.ttc、simsun.ttc复制到/usr/local/lib/python2.6/site-packages
中文字体文件可以从Windows XP的windows/fonts目录下获得
2、在程序中指定中文字体(seDefaultFonts),示例程序如下:
#!/usr/bin/python
# -*- coding: utf-8 -*-
from pychartdir import *
# The data for the bar chart
data = [85, 156, 179.5, 211, 123]
# The labels for the bar chart
labels = [u"星期一", u"星期二", u"星期三", u"星期四", u"星期五"]
# Create a XYChart object of size 500 x 500 pixels
c = XYChart(500, 500)
# Set the plotarea at (30, 20) and of size 200 x 200 pixels
c.setPlotArea(60, 40, 400, 400)
# Add a bar chart layer using the given data
c.addBarLayer(data)
# Set the labels on the x axis.
c.xAxis().setLabels(labels)
# Set Chinese fonts
c.setDefaultFonts("simsun.ttc")
# Output the chart
c.makeChart("simplebar.png")
程序输出结果
注意事项:
1)源代码要使用UTF-8编码
2)中文标签都要用Unicode字符串
相关文章推荐
- Python图表软件包ChartDirector的安装和使用
- Web图表开发--在Pythonr下如何安装ChartDirector
- python 使用apt模块安装软件包
- python 使用apt模块安装软件包
- Python:使用pycha快速绘制办公常用图二(使用样式定制个性化图表)
- thrift安装使用——python客户端通过thrift调用hive
- 使用setuptools自动安装python模块
- HP-UX 11i v2安装使用python 2.5.2
- 使用Python2.4在Linux下访问SQL Server(安装篇)
- Python:使用matplotlib绘制图表
- 如何使用和制作 Python 安装模块(setup.py)
- 使用setuptools自动安装python模块
- Windows下安装libxml2并在Python中使用XPath
- Python模块之chardir: 使用chartdir生成各种图表
- 使用python3.2开发pyramid1.3(安装环境和初始项目)
- 安装,使用Python easy_install 模块
- Memcached 安装、使用(Python操作)以及常用方法
- 使用Python2.4在Linux下访问SQL Server(安装篇)
- 使用Python2.4在Linux下访问SQL Server(安装篇)
- 非root用户安装 Python + MySQLdb 及使用