|
1 | | -from distutils.version import LooseVersion |
2 | | -import pathlib |
3 | | -import warnings |
4 | | - |
5 | 1 | import pyqtgraph as pg |
6 | 2 |
|
7 | 3 |
|
8 | | -if LooseVersion(pg.__version__) > "0.12.1": |
9 | | - warnings.warn("New version of pyqtgraph detected! Please remove the " |
10 | | - "imageAxisOrder workaround, remove this case structure and " |
11 | | - "update setup.py with the new version.") |
12 | | -else: |
13 | | - # Temporary fix for https://github.com/pyqtgraph/pyqtgraph/issues/1866. |
14 | | - # Only modifies the AxisItem code in-place. This means that the location |
15 | | - # has to be writable. For frozen applications, it has to be run before |
16 | | - # freezing (e.g. during tests). |
17 | | - axis_item_path = pathlib.Path(pg.graphicsItems.AxisItem.__file__) |
18 | | - if axis_item_path.suffix == ".py" and axis_item_path.exists(): |
19 | | - lines = axis_item_path.read_text(encoding="utf-8").split("\n") |
20 | | - for ii, line in enumerate(lines): |
21 | | - if (line.count("resolves some damn pixel ambiguity") |
22 | | - and not line.strip().startswith("#")): |
23 | | - lines[ii] = "# " + line |
24 | | - try: |
25 | | - axis_item_path.write_text("\n".join(lines), |
26 | | - encoding="utf-8") |
27 | | - except BaseException: |
28 | | - warnings.warn("Could not patch AxisItem for ColorBarItem!") |
29 | | - |
30 | | - |
31 | 4 | class ShapeOutColorBarItem(pg.ColorBarItem): |
32 | 5 | def __init__(self, yoffset, height, label, *args, **kwargs): |
33 | 6 | """pg.ColorBarItem modified for Shape-Out |
34 | 7 |
|
35 | | - - Workaround for https://github.com/pyqtgraph/pyqtgraph/issues/1720 |
36 | | - which is not in pyqtgraph 0.12.1 |
37 | 8 | - Added option to define height |
38 | 9 | - translate the colorbar so that it is aligned with the plot |
39 | 10 | - show the label on the right-hand axis |
40 | 11 | - increase the contents margins |
41 | 12 | """ |
42 | | - # workaround for pyqtgraph 0.12.1, which does not yet include |
43 | | - # https://github.com/pyqtgraph/pyqtgraph/issues/1720 |
44 | | - pg.setConfigOption('imageAxisOrder', 'col-major') |
45 | 13 | super(ShapeOutColorBarItem, self).__init__(*args, **kwargs) |
46 | | - pg.setConfigOption('imageAxisOrder', 'row-major') |
47 | 14 |
|
48 | 15 | for key in ['left', 'top', 'bottom']: |
49 | 16 | axis = self.getAxis(key) |
|
0 commit comments