Skip to content

Commit 3635c6c

Browse files
authored
Merge pull request #356 from wpfff/fix/pyqtgraphcolors
fix: pyqtgraph colormaps
2 parents b2cd882 + de18c45 commit 3635c6c

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

plottr/config/plottrcfg_main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@
3939
'line_symbols': ['o', ],
4040
'line_symbol_size': 7,
4141
'minimum_plot_size': (400, 400),
42+
'default_colormap': 'magma',
4243
}
4344
}

plottr/plot/pyqtgraph/plots.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import numpy as np
77
import pyqtgraph as pg
88

9-
from plottr import QtCore, QtWidgets
9+
from plottr import QtCore, QtWidgets, config_entry
1010

1111
__all__ = ['PlotBase', 'Plot']
1212

@@ -73,9 +73,14 @@ class PlotWithColorbar(PlotBase):
7373
def __init__(self, parent: Optional[QtWidgets.QWidget] = None) -> None:
7474
super().__init__(parent)
7575

76-
cmap = pg.colormap.get('viridis', source='matplotlib')
76+
cmap_name = config_entry('main', 'pyqtgraph', 'default_colormap')
77+
try:
78+
cmap = pg.colormap.get(cmap_name)
79+
except:
80+
cmap = pg.colormap.get('CET-L1')
81+
7782
self.colorbar: pg.ColorBarItem = pg.ColorBarItem(interactive=True, values=(0, 1),
78-
cmap=cmap, width=15)
83+
colorMap=cmap, width=15)
7984
self.graphicsLayout.addItem(self.colorbar)
8085

8186
self.img: Optional[pg.ImageItem] = None

0 commit comments

Comments
 (0)