python中PyQwt的使用 画图(一)
2013-09-24 16:57
429 查看
文章中将假设读者已经有Python的与PyQt的编码的经验,因此只会针对PyQwt的相关部分作解释。
在第一个范例中将介绍PyQwt最基本的绘制二维曲线功能,下图为程序执行后输出的图形视窗:
一开始我们导入必要的库,其中PyQt4.Qwt5即为PyQwt库。
在类Ex01中分别创建 QwtPlot对象,通过调用QwtPlot对象的方法setTitle(String)来设定图的标题文字。而setAxisTitle(AxisId,String)用来设定座标轴的标题。fig.xBottm 和 fig.yLeft 为
QwtPlot对象的属性,分別代表 fig 的下方 x 轴和左边的y轴。
转自:http://blog.chinaunix.net/uid-25979788-id-2943083.html
在第一个范例中将介绍PyQwt最基本的绘制二维曲线功能,下图为程序执行后输出的图形视窗:
#!/usr/bin/env python import sys import numpy as np from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4.Qwt5 import * class Ex01(QWidget): def __init__(self): QWidget.__init__(self) fig = QwtPlot() fig.setParent(self) text = "f(x) = x + x<sup>2<\sup>" fig.setTitle(text) fig.setAxisTitle(fig.xBottom, "x") fig.setAxisTitle(fig.yLeft, "f(x)") x = np.arange(0, 10, 0.1) y = x +x**2 curve = QwtPlotCurve() curve.setData(x, y) curve.attach(fig) fig.replot() fig.resize(400, 300) def main(): app = QApplication(sys.argv) frame = Ex01() frame.show() app.exec_() if __name__ == "__main__": main()
一开始我们导入必要的库,其中PyQt4.Qwt5即为PyQwt库。
在类Ex01中分别创建 QwtPlot对象,通过调用QwtPlot对象的方法setTitle(String)来设定图的标题文字。而setAxisTitle(AxisId,String)用来设定座标轴的标题。fig.xBottm 和 fig.yLeft 为
QwtPlot对象的属性,分別代表 fig 的下方 x 轴和左边的y轴。
转自:http://blog.chinaunix.net/uid-25979788-id-2943083.html
相关文章推荐
- python使用reportlab画图示例(含中文汉字)
- python3 使用matplotlib画图出现中文乱码的情况
- Win7,64位,Python使用reportlab画图并生成为pdf文件
- 使用Python的turtle模块画图的方法
- Python 使用matplotlib画图添加标注、及移动坐标轴位置
- Python 中画图工具的使用
- 【Python入门】使用ReporLab 画图 PDF存储
- 使用python画图(2)
- linux终端使用python的matplotlib模块画图出现“could not open display”问题解决
- python3 使用matplotlib画图出现中文乱码的情况
- Python画图工具matplotlib的使用(图形并茂)
- Python使用matplotlib和pandas实现的画图操作【经典示例】
- python中使用plot画图,图不显示
- python使用reportlab画图示例(含中文汉字)
- python3使用matplotlib画图支持中文
- Python使用ReportLab画图
- python matplotlib画图安装和使用
- Mac使用 matplotlib 画图 => RuntimeError: Python is not installed as a framework
- python画图包seaborn和matplotlib中文字体显示(针对windows系统,,使用ipython notebook)
- python的turtle画图软件包的使用