PyQwt反转轴(或设置PyQwt属性)

Schodge

我正在PyQwt中创建一个Nyquist图。当前有效,除了我需要翻转y轴-约定的底部为零,上移时为负数。

我知道您将在C ++中执行此操作,但无法弄清楚如何在Python中执行此操作。我不完全了解Qt / Qwt如何转换为PyQt / PyQwt。根据http://qwt.sourceforge.net/class_qwt_scale_engine.html,有一个属性Inverted需要设置。在C ++中,这看起来像:

ui.plotWidget->axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Inverted, true);

我想不出一种方法,在主窗口中尝试了几种方法__init__(self)

self.ui.qwtPlot.setAxisTitle(Qwt.QwtPlot.yLeft, 'Imaginary Impedance')
self.ui.qwtPlot.setAxisScaleEngine(Qwt.QwtPlot.yLeft, Qwt.QwtScaleEngine.Inverted))
# TypeError: QwtPlot.setAxisScaleEngine(): argument 2 has unexpected type 'Attribute'
self.ui.qwtPlot.setAxisScaleEngine(Qwt.QwtPlot.yLeft,   Qwt.QwtScaleEngine.setAttribute(Inverted))
# NameError: global name 'Inverted' is not defined
self.ui.qwtPlot.setAxisScaleEngine(Qwt.QwtPlot.yLeft, Qwt.QwtScaleEngine.setAttribute(Qwt.QwtScaleEngine.Inverted)
# TypeError: QwtScaleEngine.setAttribute(): first argument of unbound method must have type 'QwtScaleEngine'

我还尝试定义一个新类,就像在http://sourceforge.net/p/pyqwt/patches/1/中所做的那样:

class InvertedAxisEngine(Qwt.QwtScaleEngine):
    def __init__(self):
        Qwt.QwtScaleEngine.__init__(self)
        self.setAttribute(Qwt.QwtScaleEngine.Inverted)
# back in Window.__init__(self)
self.ui.qwtPlot.setAxisScaleEngine(Qwt.QwtPlot.yLeft, InvertedAxisEngine)
#TypeError: QwtPlot.setAxisScaleEngine(): argument 2 has unexpected type 'PyQt4.QtCore.pyqtWrapperType'
self.ui.qwtPlot.setAxisScaleEngine(Qwt.QwtPlot.yLeft, InvertedAxisEngine())
# NotImplementedError: QwtScaleEngine.divideScale() is abstract and must be overridden
#NotImplementedError: QwtScaleEngine.transformation() is abstract and must be overridden

我感觉到我把它弄得太复杂了。

编辑-下面的注释启发了几件事,例如添加=TrueInverted(不,没有关键字参数,我也尝试过这样做,这对unexpected type(包装器)有所帮助

self.ui.inverted_engine = Qwt.QwtScaleEngine
self.ui.inverted_engine.Inverted = True        
self.ui.qwtPlot.setAxisScaleEngine(Qwt.QwtPlot.yLeft, self.ui.inverted_engine)

当GUI运行时,我没有解释器提示访问权限,但是我print dir(Qwt.QwtScaleEngine)在init中添加了a ,它确实存在:['Attribute', 'Floating', 'IncludeReference', 'Inverted', 'NoAttribute', 'Symmetric', '__class__',....

Schodge

在检查http://orange.biolab.si/svn/orange/externals/trunk/install-scripts/mac/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/上的代码后,我终于找到了答案2.6 / lib目录/ python2.6的/站点包/ PyQt4的/ Qwt5 / qplt.py我认为还可以使用来实现此目的setAxisScaleEngine(),但这是可行的。

    QMainWindow.__init__(self)
    self.ui = Ui_MainWindow()
    self.ui.setupUi(self)
    self.ui.qwtPlot.setAxisTitle(Qwt.QwtPlot.yLeft, 'Imaginary Impedance (ohms)')
    self.ui.qwtPlot.setCanvasBackground(Qt.white)
    engine = self.ui.qwtPlot.axisScaleEngine(Qwt.QwtPlot.yLeft)
    Qwt.QwtScaleEngine.setAttribute(engine, Qwt.QwtScaleEngine.Inverted)

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

密谋:如何反转轴?

来自分类Dev

如何在ILNumerics中反转轴

来自分类Dev

Gnuradio(3.7.9):如何向流程图添加qt小部件(例如滑块)?(新版本不支持pyqwt)

来自分类Dev

反转轴时不显示高图堆积列堆栈标签

来自分类Dev

如何在R中反转轴以避免一元运算符错误

来自分类Dev

反转轴时不显示高图堆积列堆栈标签

来自分类Dev

设置层之间的依赖反转

来自分类Dev

反转属性名称和值

来自分类Dev

SCNCylinder上的设置内容(图像)反转(翻转)

来自分类Dev

反转(翻转)SCNCylinder上的设置内容(图像)

来自分类Dev

使用条件子句反转设置值

来自分类Dev

html 标签上的“反转”属性是什么?

来自分类Dev

设置属性的属性

来自分类Dev

设置属性的属性

来自分类Dev

在双屏/双显示器设置上反转颜色?

来自分类Dev

镜像或反转给定的文本并设置为HTML标题标签

来自分类Dev

Interior.Color属性会反转颜色吗?

来自分类Dev

条件不再适用后,CSS @media属性无法反转

来自分类Dev

在结构中设置属性的属性?

来自分类Dev

使用反射设置属性的属性

来自分类Dev

ggpairs 旋转轴标签

来自分类Dev

从Lua设置C属性

来自分类Dev

在ItemTemplate上设置属性

来自分类Dev

LINQ查询设置属性

来自分类Dev

全局设置JVM的属性

来自分类Dev

设置箱线图属性

来自分类Dev

设置对象的属性

来自分类Dev

循环设置类属性

来自分类Dev

Swift可变属性设置