Skip to content

Commit bdf8d09

Browse files
committed
Create LogCurveDemo.py
1 parent d5975de commit bdf8d09

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

qwt/tests/LogCurveDemo.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Licensed under the terms of the PyQwt License
4+
# Copyright (C) 2003-2009 Gerard Vermeulen, for the original PyQwt example
5+
# Copyright (c) 2015 Pierre Raybaut, for the PyQt5/PySide port and further
6+
# developments (e.g. ported to PythonQwt API)
7+
# (see LICENSE file for more details)
8+
9+
SHOW = True # Show test in GUI-based test launcher
10+
11+
import numpy as np
12+
13+
np.seterr(all='raise')
14+
15+
from qwt.qt.QtGui import QApplication, QPen
16+
from qwt.qt.QtCore import Qt
17+
from qwt import QwtPlot, QwtPlotCurve, QwtLogScaleEngine
18+
19+
20+
def create_log_plot():
21+
plot = QwtPlot('LogCurveDemo.py (or how to handle -inf values)')
22+
plot.enableAxis(QwtPlot.xBottom)
23+
plot.setAxisScaleEngine(QwtPlot.yLeft, QwtLogScaleEngine())
24+
curve = QwtPlotCurve()
25+
curve.setRenderHint(QwtPlotCurve.RenderAntialiased)
26+
pen = QPen(Qt.magenta)
27+
pen.setWidth(1.5)
28+
curve.setPen(pen)
29+
curve.attach(plot)
30+
x = np.arange(0.0, 10.0, 0.1)
31+
y = 10*np.cos(x)**2-.1
32+
print("y<=0:", y<=0)
33+
curve.setData(x, y)
34+
plot.replot()
35+
return plot
36+
37+
38+
if __name__ == '__main__':
39+
app = QApplication([])
40+
plot = create_log_plot()
41+
plot.resize(800, 500)
42+
plot.show()
43+
app.exec_()

0 commit comments

Comments
 (0)