Skip to content

Commit 08013df

Browse files
jenshnielsenWilliamHPNielsen
authored andcommitted
Make Default colormap configurable (#825)
* add colormap to json * use config for colormap
1 parent c9c38ba commit 08013df

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

qcodes/config/qcodesrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"gui" :{
77
"notebook": true,
88
"plotlib": "all",
9-
"pyqtmaxplots": 100
9+
"pyqtmaxplots": 100,
10+
"defaultcolormap": "hot"
1011
},
1112
"user": {}
1213
}

qcodes/config/qcodesrc_schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@
4646
"description": "Maximum number of PyQtPlots to automatically keep in memory",
4747
"type": "integer",
4848
"default": 100
49+
},
50+
"defaultcolormap":{
51+
"description": "Default colormap to use for Heatmaps with both Matplotlib and PyQtGraph",
52+
"type": "string",
53+
"default": "hot"
4954
}
5055
},
5156
"required":[ "notebook", "plotlib", "pyqtmaxplots" ]

qcodes/plots/pyqtgraph.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,12 @@ def _draw_plot(self, subplot_object, y, x=None, color=None, width=None,
212212
def _line_data(self, x, y):
213213
return [self._clean_array(arg) for arg in [x, y] if arg is not None]
214214

215-
def _draw_image(self, subplot_object, z, x=None, y=None, cmap='hot',
215+
def _draw_image(self, subplot_object, z, x=None, y=None, cmap=None,
216216
zlabel=None,
217217
zunit=None,
218218
**kwargs):
219+
if cmap is None:
220+
cmap = qcodes.config['gui']['defaultcolormap']
219221
img = self.rpg.ImageItem()
220222
subplot_object.addItem(img)
221223

qcodes/plots/qcmatplotlib.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from numpy.ma import masked_invalid, getmask
1414

1515
from .base import BasePlot
16-
16+
import qcodes.config
1717

1818
class MatPlot(BasePlot):
1919
"""
@@ -303,6 +303,8 @@ def _draw_pcolormesh(self, ax, z, x=None, y=None, subplot=1,
303303
# to check for them.
304304
return False
305305

306+
if 'cmap' not in kwargs:
307+
kwargs['cmap'] = qcodes.config['gui']['defaultcolormap']
306308
if x is not None and y is not None:
307309
# If x and y are provided, modify the arrays such that they
308310
# correspond to grid corners instead of grid centers.

0 commit comments

Comments
 (0)