PythonQwt 0.14.2__py3-none-any.whl → 0.14.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {PythonQwt-0.14.2.dist-info → PythonQwt-0.14.4.dist-info}/METADATA +6 -4
- {PythonQwt-0.14.2.dist-info → PythonQwt-0.14.4.dist-info}/RECORD +14 -13
- {PythonQwt-0.14.2.dist-info → PythonQwt-0.14.4.dist-info}/WHEEL +1 -1
- qwt/__init__.py +1 -1
- qwt/interval.py +0 -15
- qwt/plot.py +14 -38
- qwt/scale_engine.py +25 -7
- qwt/tests/test_cpudemo.py +3 -3
- qwt/tests/test_curvebenchmark1.py +4 -1
- qwt/tests/test_loadtest.py +5 -0
- qwt/tests/test_relativemargin.py +54 -0
- {PythonQwt-0.14.2.dist-info → PythonQwt-0.14.4.dist-info}/LICENSE +0 -0
- {PythonQwt-0.14.2.dist-info → PythonQwt-0.14.4.dist-info}/entry_points.txt +0 -0
- {PythonQwt-0.14.2.dist-info → PythonQwt-0.14.4.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: PythonQwt
|
|
3
|
-
Version: 0.14.
|
|
3
|
+
Version: 0.14.4
|
|
4
4
|
Summary: Qt plotting widgets for Python
|
|
5
5
|
Author-email: Pierre Raybaut <pierre.raybaut@gmail.com>
|
|
6
6
|
License: PythonQwt License Agreement
|
|
@@ -722,10 +722,12 @@ See documentation [online](https://pythonqwt.readthedocs.io/en/latest/) or [PDF]
|
|
|
722
722
|
## Sample
|
|
723
723
|
|
|
724
724
|
```python
|
|
725
|
-
import qwt
|
|
726
725
|
import numpy as np
|
|
726
|
+
from qtpy import QtWidgets as QW
|
|
727
|
+
|
|
728
|
+
import qwt
|
|
727
729
|
|
|
728
|
-
app =
|
|
730
|
+
app = QW.QApplication([])
|
|
729
731
|
|
|
730
732
|
# Create plot widget
|
|
731
733
|
plot = qwt.QwtPlot("Trigonometric functions")
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
qwt/__init__.py,sha256=
|
|
1
|
+
qwt/__init__.py,sha256=0hOH-gcqLTxEDmC5n6WdR0u-oN8o_TQ5MxywimYE8uk,5917
|
|
2
2
|
qwt/_math.py,sha256=fNcPJcaK-ldCCFB20T2N58LEkQ1lwZY1-q5veXXhwl8,1501
|
|
3
3
|
qwt/color_map.py,sha256=fLRpymqOXtLrhuPrbbCxTvNINbr2GH7pYBG4fZidrcs,11812
|
|
4
4
|
qwt/column_symbol.py,sha256=0aFyQ05ryTKbaSTctkhtXa0pB_tWG444zlH3991_bt0,5760
|
|
5
5
|
qwt/dyngrid_layout.py,sha256=wgff6mZ1okNhQRRbwaw1I__vOXqGdUG0uafkShuns08,13477
|
|
6
6
|
qwt/graphic.py,sha256=x5rrVauD4EPTZMl3ZDeC7QUC51GhyF8aI4V6WESsjKo,28093
|
|
7
|
-
qwt/interval.py,sha256=
|
|
7
|
+
qwt/interval.py,sha256=PMrCQxV9NXGk2JG0MNjJ3zGTNTSSRfa_noxbpm-Okns,12287
|
|
8
8
|
qwt/legend.py,sha256=GBUim67HWgwLat5tOWDpK98fWcFxV-RkxWjoyWd9Gao,31313
|
|
9
9
|
qwt/null_paintdevice.py,sha256=AAVyQCVgZKyIw7i-J9ElB0_-8KRV9OXDr140TwMxLSs,9144
|
|
10
10
|
qwt/painter.py,sha256=UGh-MC_9qw3fNF9GJ_1xbcAkVG6hD5op7jg9M2CcIXI,16527
|
|
11
11
|
qwt/painter_command.py,sha256=b_uZb56YlzYFG3ZmB5ykjkBQQAadQD8epknsQSEai54,6957
|
|
12
|
-
qwt/plot.py,sha256=
|
|
12
|
+
qwt/plot.py,sha256=_RPXQKSkEP7Dh6PWIjEuGiR_BsMQkj4DbUZvRtxYJeE,75613
|
|
13
13
|
qwt/plot_canvas.py,sha256=eYcXJgVc7MaDk5UzSjhcTmc6ptyQWApeaRKWSoi_jeE,30317
|
|
14
14
|
qwt/plot_curve.py,sha256=ilb1ts7E-Ql-IE3eigjmb5LwjdCf7LMPBlYuu_cjKPw,37061
|
|
15
15
|
qwt/plot_directpainter.py,sha256=JCWNhCC21L1A1HZnxd-C95QNlrVJbLztmGab-X8gCGc,10165
|
|
@@ -21,7 +21,7 @@ qwt/plot_series.py,sha256=Wa_Wunu-t_L8vl95RJq6__k-XA8UV2YNIsc8yNGpTT8,10654
|
|
|
21
21
|
qwt/qthelpers.py,sha256=GpvLr96Ip8SIGwyFfs0f7ocHyKPB7PEjHBQyrpw84xw,1405
|
|
22
22
|
qwt/scale_div.py,sha256=2Ay5mgduXgSm4OrDMcaEWIzenAiBuEASZRoX99PWEE4,9276
|
|
23
23
|
qwt/scale_draw.py,sha256=DvknvoOpEerVqplH-fbEtXQlXrFebUGz-1eS5qJdDWI,36760
|
|
24
|
-
qwt/scale_engine.py,sha256=
|
|
24
|
+
qwt/scale_engine.py,sha256=HOw5rLriO81p6CyeG9FdZzb0OVBkO9Y4-AQz33GZj-0,30002
|
|
25
25
|
qwt/scale_map.py,sha256=WobkNna6_RPXYZjGK7gZLykNxN_kYnrcB6fEaWgnL2w,9182
|
|
26
26
|
qwt/scale_widget.py,sha256=p202DrRgMraGbVcubzkatvVXOLbO9CPho729hz6gqa0,27125
|
|
27
27
|
qwt/symbol.py,sha256=DYMMelQkP7vr8WGo3EFM72CzcWpZEHEYohlLXZEtCsI,39170
|
|
@@ -34,8 +34,8 @@ qwt/tests/conftest.py,sha256=akpTe2ofWLsMKqpbxqYURpLOmCdEdXa8MccB1E0GG5M,1690
|
|
|
34
34
|
qwt/tests/test_backingstore.py,sha256=AIiRPqcNPY1riXSQXU43tqB2_z02PhxmK1zA4OxQixM,524
|
|
35
35
|
qwt/tests/test_bodedemo.py,sha256=bOIApjBQA1J4aZkVBnzByiKqhqEcmQpag1TvIfsuHMs,9386
|
|
36
36
|
qwt/tests/test_cartesian.py,sha256=0VCrvclqbQJSEGhWpZLq6brA9Qm9oRIgluEBbxOTOds,3855
|
|
37
|
-
qwt/tests/test_cpudemo.py,sha256=
|
|
38
|
-
qwt/tests/test_curvebenchmark1.py,sha256=
|
|
37
|
+
qwt/tests/test_cpudemo.py,sha256=E2kwRO6sUh9WSZ08FABmQBhfH2bQ49JCYXPUpoonAS0,12846
|
|
38
|
+
qwt/tests/test_curvebenchmark1.py,sha256=a53CvA149Ng1Vj4oruKo4Gp952-0A5gLXvRPOiNSYQk,5891
|
|
39
39
|
qwt/tests/test_curvebenchmark2.py,sha256=5TYkVuWuP8-Tp7gphsaF_ys3cufHkzKstFDHb9BCOAg,2720
|
|
40
40
|
qwt/tests/test_curvedemo1.py,sha256=3jAq_pQ52F2HyO3WlDWUn43vNVw8q_g5OQ_hcseaD4s,4181
|
|
41
41
|
qwt/tests/test_curvedemo2.py,sha256=FkPbP6OvetMGx2jmEuhc6NLPQKxhVI8XmiUIBcm-0eU,4080
|
|
@@ -44,10 +44,11 @@ qwt/tests/test_errorbar.py,sha256=ecJ_YHcx1RhCS9_BKKoNYz6bOuuqapRPGL2Vp_r3O1U,10
|
|
|
44
44
|
qwt/tests/test_eventfilter.py,sha256=31vCsCzRcoq3cyMlDAH5fthA45QqeFXKaWyhfZME6rE,16441
|
|
45
45
|
qwt/tests/test_highdpi.py,sha256=Xafo016q-RX4918JddBGD60HZ4GpuYJBJokEO15md24,1053
|
|
46
46
|
qwt/tests/test_image.py,sha256=yY_AplKEdm-M7uB5G50p4E68ZzNamYvGSfN5rvlVPPM,6549
|
|
47
|
-
qwt/tests/test_loadtest.py,sha256=
|
|
47
|
+
qwt/tests/test_loadtest.py,sha256=ZTHatcGAbLyvS0BpbOWbzPD2Bjz4rckF7oxZsUVQ5KM,1812
|
|
48
48
|
qwt/tests/test_logcurve.py,sha256=XOtR0asSqFfzc0VL0qfXN0fXNvxvLnz5fxmNZ2gzQWk,1129
|
|
49
49
|
qwt/tests/test_mapdemo.py,sha256=e7rvB8IPKYVVii8UgdHSbOHLc3i7eB21EQNKZ151Kc8,3423
|
|
50
50
|
qwt/tests/test_multidemo.py,sha256=YS-P08qcakD41OJy6ZI53ofKOnUvD-2_uum0yOLiIRc,2530
|
|
51
|
+
qwt/tests/test_relativemargin.py,sha256=E2PqK4e8Ml-NZGuhslBlCsIPEcFm08nLwsn0jZT_h70,2093
|
|
51
52
|
qwt/tests/test_simple.py,sha256=4opQp_-RkcVdpRyYSh89ddBkeXCPrppB-_2KTiu5vjI,2347
|
|
52
53
|
qwt/tests/test_stylesheet.py,sha256=cuL1iY4pp5ZoMX4OI86amJA6R5SzQsH1JUWLtEiitZ4,950
|
|
53
54
|
qwt/tests/test_symbols.py,sha256=YcGM0_Em8QtcbqpLSU98PxvGo7BIIYviP2o_4Fg2LbI,5607
|
|
@@ -75,9 +76,9 @@ qwt/tests/data/symbol.svg,sha256=ONkkohVqpg3OO2-XEZge7UZLqqNyOQXbSpLgHXcTBFU,127
|
|
|
75
76
|
qwt/tests/data/symbols.png,sha256=wiqRBc2MJluJ-am9LtZ0K9DHV9BnreYMiEvfzJUFzCk,55586
|
|
76
77
|
qwt/tests/data/testlauncher.png,sha256=WmucObp30QYYKsVRBs5-6t1aEN0FbIWRmOVFN1gt-vQ,139676
|
|
77
78
|
qwt/tests/data/vertical.png,sha256=EvyG6q6rZm6pTT08Y_nzdBYCnqmoX1QDuEQtp2pyGlw,34076
|
|
78
|
-
PythonQwt-0.14.
|
|
79
|
-
PythonQwt-0.14.
|
|
80
|
-
PythonQwt-0.14.
|
|
81
|
-
PythonQwt-0.14.
|
|
82
|
-
PythonQwt-0.14.
|
|
83
|
-
PythonQwt-0.14.
|
|
79
|
+
PythonQwt-0.14.4.dist-info/LICENSE,sha256=qjEk8TRuXmFS7QC-omINvD1UPGqWaOs6CzcCZoMEhdI,33457
|
|
80
|
+
PythonQwt-0.14.4.dist-info/METADATA,sha256=sPEkl_YuQgSoSGFumxPOhPeUjulgeAxI64fhzOLG0fw,45077
|
|
81
|
+
PythonQwt-0.14.4.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
82
|
+
PythonQwt-0.14.4.dist-info/entry_points.txt,sha256=pdPda-YcYigCi00hR4tMxWKu6byxM2x3zA8BQFDYvwI,46
|
|
83
|
+
PythonQwt-0.14.4.dist-info/top_level.txt,sha256=KB1IBdWRWnaItyJMaECwZiEi1jWt3IvqCrRVVhMjTu8,4
|
|
84
|
+
PythonQwt-0.14.4.dist-info/RECORD,,
|
qwt/__init__.py
CHANGED
|
@@ -55,7 +55,7 @@ from qwt.symbol import QwtSymbol as QSbl # see deprecated section
|
|
|
55
55
|
from qwt.text import QwtText # noqa: F401
|
|
56
56
|
from qwt.toqimage import array_to_qimage as toQImage # noqa: F401
|
|
57
57
|
|
|
58
|
-
__version__ = "0.14.
|
|
58
|
+
__version__ = "0.14.4"
|
|
59
59
|
QWT_VERSION_STR = "6.1.5"
|
|
60
60
|
|
|
61
61
|
|
qwt/interval.py
CHANGED
|
@@ -396,18 +396,3 @@ class QwtInterval(object):
|
|
|
396
396
|
if not self.isValid():
|
|
397
397
|
return self
|
|
398
398
|
return QwtInterval(min([value, self.__minValue]), max([value, self.__maxValue]))
|
|
399
|
-
|
|
400
|
-
def extend_fraction(self, value):
|
|
401
|
-
"""
|
|
402
|
-
Extend the interval by a fraction of its width
|
|
403
|
-
|
|
404
|
-
:param float value: Fraction
|
|
405
|
-
:return: extended interval
|
|
406
|
-
"""
|
|
407
|
-
if not self.isValid():
|
|
408
|
-
return self
|
|
409
|
-
return QwtInterval(
|
|
410
|
-
self.__minValue - value * self.width(),
|
|
411
|
-
self.__maxValue + value * self.width(),
|
|
412
|
-
self.__borderFlags,
|
|
413
|
-
)
|
qwt/plot.py
CHANGED
|
@@ -588,7 +588,7 @@ class QwtPlot(QFrame):
|
|
|
588
588
|
def axisMargin(self, axisId):
|
|
589
589
|
"""
|
|
590
590
|
:param int axisId: Axis index
|
|
591
|
-
:return:
|
|
591
|
+
:return: Relative margin of the axis, as a fraction of the full axis range
|
|
592
592
|
|
|
593
593
|
.. seealso::
|
|
594
594
|
|
|
@@ -871,15 +871,17 @@ class QwtPlot(QFrame):
|
|
|
871
871
|
|
|
872
872
|
def setAxisMargin(self, axisId, margin):
|
|
873
873
|
"""
|
|
874
|
-
Set the margin of the
|
|
874
|
+
Set the relative margin of the axis, as a fraction of the full axis range
|
|
875
875
|
|
|
876
876
|
:param int axisId: Axis index
|
|
877
|
-
:param float margin:
|
|
877
|
+
:param float margin: Relative margin (float between 0 and 1)
|
|
878
878
|
|
|
879
879
|
.. seealso::
|
|
880
880
|
|
|
881
881
|
:py:meth:`axisMargin()`
|
|
882
882
|
"""
|
|
883
|
+
if not isinstance(margin, float) or margin < 0.0 or margin > 1.0:
|
|
884
|
+
raise ValueError("margin must be a float between 0 and 1")
|
|
883
885
|
if self.axisValid(axisId):
|
|
884
886
|
d = self.__axisData[axisId]
|
|
885
887
|
if margin != d.margin:
|
|
@@ -946,15 +948,13 @@ class QwtPlot(QFrame):
|
|
|
946
948
|
minValue = d.minValue
|
|
947
949
|
maxValue = d.maxValue
|
|
948
950
|
stepSize = d.stepSize
|
|
949
|
-
if d.
|
|
950
|
-
intv_i = intv[axisId].extend_fraction(d.margin)
|
|
951
|
-
else:
|
|
952
|
-
intv_i = intv[axisId]
|
|
953
|
-
if d.doAutoScale and intv_i.isValid():
|
|
951
|
+
if d.doAutoScale and intv[axisId].isValid():
|
|
954
952
|
d.isValid = False
|
|
955
|
-
minValue =
|
|
956
|
-
maxValue =
|
|
957
|
-
minValue, maxValue, stepSize = d.scaleEngine.autoScale(
|
|
953
|
+
minValue = intv[axisId].minValue()
|
|
954
|
+
maxValue = intv[axisId].maxValue()
|
|
955
|
+
minValue, maxValue, stepSize = d.scaleEngine.autoScale(
|
|
956
|
+
d.maxMajor, minValue, maxValue, stepSize, d.margin
|
|
957
|
+
)
|
|
958
958
|
if not d.isValid:
|
|
959
959
|
d.scaleDiv = d.scaleEngine.divideScale(
|
|
960
960
|
minValue, maxValue, d.maxMajor, d.maxMinor, stepSize
|
|
@@ -1391,7 +1391,7 @@ class QwtPlot(QFrame):
|
|
|
1391
1391
|
:py:meth:`QwtPlotItem.getCanvasMarginHint()`
|
|
1392
1392
|
"""
|
|
1393
1393
|
maps = [self.canvasMap(axisId) for axisId in self.AXES]
|
|
1394
|
-
self.drawItems(painter, self.__data.canvas.contentsRect(), maps)
|
|
1394
|
+
self.drawItems(painter, QRectF(self.__data.canvas.contentsRect()), maps)
|
|
1395
1395
|
|
|
1396
1396
|
def drawItems(self, painter, canvasRect, maps):
|
|
1397
1397
|
"""
|
|
@@ -1560,9 +1560,9 @@ class QwtPlot(QFrame):
|
|
|
1560
1560
|
if self.__data.legend.parent() is not self:
|
|
1561
1561
|
self.__data.legend.setParent(self)
|
|
1562
1562
|
|
|
1563
|
-
self.
|
|
1563
|
+
self.legendDataChanged.disconnect(self.updateLegendItems)
|
|
1564
1564
|
self.updateLegend()
|
|
1565
|
-
self.
|
|
1565
|
+
self.legendDataChanged.connect(self.updateLegendItems)
|
|
1566
1566
|
|
|
1567
1567
|
lpos = self.__data.layout.legendPosition()
|
|
1568
1568
|
|
|
@@ -1706,7 +1706,6 @@ class QwtPlotItem_PrivateData(QObject):
|
|
|
1706
1706
|
self.yAxis = QwtPlot.yLeft
|
|
1707
1707
|
self.legendIconSize = QSize(8, 8)
|
|
1708
1708
|
self.title = None # QwtText
|
|
1709
|
-
self.icon = None
|
|
1710
1709
|
|
|
1711
1710
|
|
|
1712
1711
|
class QwtPlotItem(object):
|
|
@@ -1915,29 +1914,6 @@ class QwtPlotItem(object):
|
|
|
1915
1914
|
"""
|
|
1916
1915
|
return self.__data.title
|
|
1917
1916
|
|
|
1918
|
-
def setIcon(self, icon):
|
|
1919
|
-
"""
|
|
1920
|
-
Set item icon
|
|
1921
|
-
|
|
1922
|
-
:param icon: Icon
|
|
1923
|
-
:type icon: QIcon
|
|
1924
|
-
|
|
1925
|
-
.. seealso::
|
|
1926
|
-
|
|
1927
|
-
:py:meth:`icon()`
|
|
1928
|
-
"""
|
|
1929
|
-
self.__data.icon = icon
|
|
1930
|
-
|
|
1931
|
-
def icon(self):
|
|
1932
|
-
"""
|
|
1933
|
-
:return: Icon of the item
|
|
1934
|
-
|
|
1935
|
-
.. seealso::
|
|
1936
|
-
|
|
1937
|
-
:py:meth:`setIcon()`
|
|
1938
|
-
"""
|
|
1939
|
-
return self.__data.icon
|
|
1940
|
-
|
|
1941
1917
|
def setItemAttribute(self, attribute, on=True):
|
|
1942
1918
|
"""
|
|
1943
1919
|
Toggle an item attribute
|
qwt/scale_engine.py
CHANGED
|
@@ -37,8 +37,8 @@ from qwt.scale_div import QwtScaleDiv
|
|
|
37
37
|
from qwt.transform import QwtLogTransform, QwtTransform
|
|
38
38
|
|
|
39
39
|
DBL_MAX = sys.float_info.max
|
|
40
|
-
LOG_MIN = 1.0e-
|
|
41
|
-
LOG_MAX = 1.
|
|
40
|
+
LOG_MIN = 1.0e-150
|
|
41
|
+
LOG_MAX = 1.0e150
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
def qwtLogInterval(base, interval):
|
|
@@ -198,7 +198,7 @@ class QwtScaleEngine(object):
|
|
|
198
198
|
self.__data = QwtScaleEngine_PrivateData()
|
|
199
199
|
self.setBase(base)
|
|
200
200
|
|
|
201
|
-
def autoScale(self, maxNumSteps, x1, x2, stepSize):
|
|
201
|
+
def autoScale(self, maxNumSteps, x1, x2, stepSize, relativeMargin=0.0):
|
|
202
202
|
"""
|
|
203
203
|
Align and divide an interval
|
|
204
204
|
|
|
@@ -206,6 +206,7 @@ class QwtScaleEngine(object):
|
|
|
206
206
|
:param float x1: First limit of the interval (In/Out)
|
|
207
207
|
:param float x2: Second limit of the interval (In/Out)
|
|
208
208
|
:param float stepSize: Step size
|
|
209
|
+
:param float relativeMargin: Margin as a fraction of the interval width
|
|
209
210
|
:return: tuple (x1, x2, stepSize)
|
|
210
211
|
"""
|
|
211
212
|
pass
|
|
@@ -473,7 +474,7 @@ class QwtLinearScaleEngine(QwtScaleEngine):
|
|
|
473
474
|
def __init__(self, base=10):
|
|
474
475
|
super(QwtLinearScaleEngine, self).__init__(base)
|
|
475
476
|
|
|
476
|
-
def autoScale(self, maxNumSteps, x1, x2, stepSize):
|
|
477
|
+
def autoScale(self, maxNumSteps, x1, x2, stepSize, relativeMargin=0.0):
|
|
477
478
|
"""
|
|
478
479
|
Align and divide an interval
|
|
479
480
|
|
|
@@ -481,12 +482,19 @@ class QwtLinearScaleEngine(QwtScaleEngine):
|
|
|
481
482
|
:param float x1: First limit of the interval (In/Out)
|
|
482
483
|
:param float x2: Second limit of the interval (In/Out)
|
|
483
484
|
:param float stepSize: Step size
|
|
485
|
+
:param float relativeMargin: Margin as a fraction of the interval width
|
|
484
486
|
:return: tuple (x1, x2, stepSize)
|
|
485
487
|
|
|
486
488
|
.. seealso::
|
|
487
489
|
|
|
488
490
|
:py:meth:`setAttribute()`
|
|
489
491
|
"""
|
|
492
|
+
# Apply the relative margin (fraction of the interval width) in linear space:
|
|
493
|
+
if relativeMargin > 0.0:
|
|
494
|
+
margin = (x2 - x1) * relativeMargin
|
|
495
|
+
x1 -= margin
|
|
496
|
+
x2 += margin
|
|
497
|
+
|
|
490
498
|
interval = QwtInterval(x1, x2)
|
|
491
499
|
interval = interval.normalized()
|
|
492
500
|
interval.setMinValue(interval.minValue() - self.lowerMargin())
|
|
@@ -640,7 +648,7 @@ class QwtLogScaleEngine(QwtScaleEngine):
|
|
|
640
648
|
super(QwtLogScaleEngine, self).__init__(base)
|
|
641
649
|
self.setTransformation(QwtLogTransform())
|
|
642
650
|
|
|
643
|
-
def autoScale(self, maxNumSteps, x1, x2, stepSize):
|
|
651
|
+
def autoScale(self, maxNumSteps, x1, x2, stepSize, relativeMargin=0.0):
|
|
644
652
|
"""
|
|
645
653
|
Align and divide an interval
|
|
646
654
|
|
|
@@ -648,6 +656,7 @@ class QwtLogScaleEngine(QwtScaleEngine):
|
|
|
648
656
|
:param float x1: First limit of the interval (In/Out)
|
|
649
657
|
:param float x2: Second limit of the interval (In/Out)
|
|
650
658
|
:param float stepSize: Step size
|
|
659
|
+
:param float relativeMargin: Margin as a fraction of the interval width
|
|
651
660
|
:return: tuple (x1, x2, stepSize)
|
|
652
661
|
|
|
653
662
|
.. seealso::
|
|
@@ -657,11 +666,20 @@ class QwtLogScaleEngine(QwtScaleEngine):
|
|
|
657
666
|
if x1 > x2:
|
|
658
667
|
x1, x2 = x2, x1
|
|
659
668
|
logBase = self.base()
|
|
669
|
+
|
|
670
|
+
# Apply the relative margin (fraction of the interval width) in logarithmic
|
|
671
|
+
# space, and convert back to linear space.
|
|
672
|
+
if relativeMargin is not None:
|
|
673
|
+
x1 = min(max([x1, LOG_MIN]), LOG_MAX)
|
|
674
|
+
x2 = min(max([x2, LOG_MIN]), LOG_MAX)
|
|
675
|
+
log_margin = math.log(x2 / x1, logBase) * relativeMargin
|
|
676
|
+
x1 /= math.pow(logBase, log_margin)
|
|
677
|
+
x2 *= math.pow(logBase, log_margin)
|
|
678
|
+
|
|
660
679
|
interval = QwtInterval(
|
|
661
680
|
x1 / math.pow(logBase, self.lowerMargin()),
|
|
662
681
|
x2 * math.pow(logBase, self.upperMargin()),
|
|
663
682
|
)
|
|
664
|
-
interval = interval.limited(LOG_MIN, LOG_MAX)
|
|
665
683
|
if interval.maxValue() / interval.minValue() < logBase:
|
|
666
684
|
linearScaler = QwtLinearScaleEngine()
|
|
667
685
|
linearScaler.setAttributes(self.attributes())
|
|
@@ -674,7 +692,7 @@ class QwtLogScaleEngine(QwtScaleEngine):
|
|
|
674
692
|
linearInterval = linearInterval.limited(LOG_MIN, LOG_MAX)
|
|
675
693
|
|
|
676
694
|
if linearInterval.maxValue() / linearInterval.minValue() < logBase:
|
|
677
|
-
# The min / max interval is too short to be represented as a log scale.
|
|
695
|
+
# The min / max interval is too short to be represented as a log scale.
|
|
678
696
|
# Set the step to 0, so that a new step is calculated and a linear scale is used.
|
|
679
697
|
stepSize = 0.0
|
|
680
698
|
return x1, x2, stepSize
|
qwt/tests/test_cpudemo.py
CHANGED
|
@@ -11,7 +11,7 @@ SHOW = True # Show test in GUI-based test launcher
|
|
|
11
11
|
import os
|
|
12
12
|
|
|
13
13
|
import numpy as np
|
|
14
|
-
from qtpy.QtCore import
|
|
14
|
+
from qtpy.QtCore import QRectF, Qt, QTime
|
|
15
15
|
from qtpy.QtGui import QBrush, QColor
|
|
16
16
|
from qtpy.QtWidgets import QLabel, QVBoxLayout, QWidget
|
|
17
17
|
|
|
@@ -225,7 +225,7 @@ class CpuPieMarker(QwtPlotMarker):
|
|
|
225
225
|
|
|
226
226
|
def draw(self, painter, xMap, yMap, rect):
|
|
227
227
|
margin = 5
|
|
228
|
-
pieRect =
|
|
228
|
+
pieRect = QRectF()
|
|
229
229
|
pieRect.setX(rect.x() + margin)
|
|
230
230
|
pieRect.setY(rect.y() + margin)
|
|
231
231
|
pieRect.setHeight(int(yMap.transform(80.0)))
|
|
@@ -263,7 +263,7 @@ class Background(QwtPlotItem):
|
|
|
263
263
|
|
|
264
264
|
def draw(self, painter, xMap, yMap, rect):
|
|
265
265
|
c = QColor(Qt.white)
|
|
266
|
-
r =
|
|
266
|
+
r = QRectF(rect)
|
|
267
267
|
|
|
268
268
|
for i in range(100, 0, -10):
|
|
269
269
|
r.setBottom(int(yMap.transform(i - 10)))
|
|
@@ -142,6 +142,7 @@ class CurveBenchmark1(QMainWindow):
|
|
|
142
142
|
self.text = BMText(self)
|
|
143
143
|
self.tabs.addTab(self.text, "Contents")
|
|
144
144
|
self.resize(*self.SIZE)
|
|
145
|
+
self.durations = []
|
|
145
146
|
|
|
146
147
|
# Force window to show up and refresh (for test purpose only)
|
|
147
148
|
self.show()
|
|
@@ -160,7 +161,9 @@ class CurveBenchmark1(QMainWindow):
|
|
|
160
161
|
# Force widget to refresh (for test purpose only)
|
|
161
162
|
QApplication.processEvents()
|
|
162
163
|
|
|
163
|
-
|
|
164
|
+
duration = (time.time() - t0) * 1000
|
|
165
|
+
self.durations.append(duration)
|
|
166
|
+
time_str = "Elapsed time: %d ms" % duration
|
|
164
167
|
widget.text.setText(time_str)
|
|
165
168
|
self.text.append("<br><i>%s:</i><br>%s" % (description, time_str))
|
|
166
169
|
print("[%s] %s" % (utils.get_lib_versions(), time_str))
|
qwt/tests/test_loadtest.py
CHANGED
|
@@ -10,6 +10,8 @@ SHOW = True # Show test in GUI-based test launcher
|
|
|
10
10
|
|
|
11
11
|
import time
|
|
12
12
|
|
|
13
|
+
import numpy as np
|
|
14
|
+
|
|
13
15
|
# Local imports
|
|
14
16
|
from qwt.tests import test_curvebenchmark1 as cb
|
|
15
17
|
from qwt.tests import utils
|
|
@@ -47,6 +49,9 @@ class LoadTest(cb.CurveBenchmark1):
|
|
|
47
49
|
symtext,
|
|
48
50
|
)
|
|
49
51
|
self.process_iteration(title, description, widget, t0)
|
|
52
|
+
print("")
|
|
53
|
+
time_str = "Average elapsed time: %d ms" % np.mean(self.durations)
|
|
54
|
+
print("[%s] %s" % (utils.get_lib_versions(), time_str))
|
|
50
55
|
|
|
51
56
|
|
|
52
57
|
def test_loadtest():
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
from qtpy import QtWidgets as QW
|
|
12
|
+
from qtpy.QtCore import Qt
|
|
13
|
+
|
|
14
|
+
import qwt
|
|
15
|
+
from qwt.tests import utils
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class RelativeMarginDemo(QW.QWidget):
|
|
19
|
+
def __init__(self, *args):
|
|
20
|
+
QW.QWidget.__init__(self, *args)
|
|
21
|
+
layout = QW.QGridLayout(self)
|
|
22
|
+
x = [1, 2, 3, 4]
|
|
23
|
+
y = [1, 500, 1000, 1500]
|
|
24
|
+
for i_row, log_scale in enumerate((False, True)):
|
|
25
|
+
for i_col, relative_margin in enumerate((0.0, None, 0.2)):
|
|
26
|
+
plot = qwt.QwtPlot(self)
|
|
27
|
+
qwt.QwtPlotGrid.make(
|
|
28
|
+
plot, color=Qt.lightGray, width=0, style=Qt.DotLine
|
|
29
|
+
)
|
|
30
|
+
def_margin = plot.axisMargin(qwt.QwtPlot.yLeft)
|
|
31
|
+
scale_str = "lin/lin" if not log_scale else "log/lin"
|
|
32
|
+
if relative_margin is None:
|
|
33
|
+
margin_str = f"default ({def_margin*100:.0f}%)"
|
|
34
|
+
else:
|
|
35
|
+
margin_str = f"{relative_margin*100:.0f}%"
|
|
36
|
+
plot.setTitle(f"{scale_str}, margin: {margin_str}")
|
|
37
|
+
if relative_margin is not None:
|
|
38
|
+
plot.setAxisMargin(qwt.QwtPlot.yLeft, relative_margin)
|
|
39
|
+
plot.setAxisMargin(qwt.QwtPlot.xBottom, relative_margin)
|
|
40
|
+
color = "red" if i_row == 0 else "blue"
|
|
41
|
+
qwt.QwtPlotCurve.make(x, y, "", plot, linecolor=color)
|
|
42
|
+
layout.addWidget(plot, i_row, i_col)
|
|
43
|
+
if log_scale:
|
|
44
|
+
engine = qwt.QwtLogScaleEngine()
|
|
45
|
+
plot.setAxisScaleEngine(qwt.QwtPlot.yLeft, engine)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def test_relative_margin():
|
|
49
|
+
"""Test relative margin."""
|
|
50
|
+
utils.test_widget(RelativeMarginDemo, size=(400, 300), options=False)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
if __name__ == "__main__":
|
|
54
|
+
test_relative_margin()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|