Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
0db366b2
Commit
0db366b2
authored
Oct 06, 2020
by
Stephen
Browse files
Add colorbar scale setting
parent
a1e9dc35
Changes
5
Hide whitespace changes
Inline
Side-by-side
Framework/Properties/Mantid.properties.template
View file @
0db366b2
...
...
@@ -280,3 +280,6 @@ plots.legend.FontSize = 8
# Default colormap for image plots
plots.images.Colormap = viridis
# Default colorbar scale for image plots
plots.images.ColorBarScale = Linear
\ No newline at end of file
docs/source/concepts/PropertiesFile.rst
View file @
0db366b2
...
...
@@ -293,6 +293,8 @@ Plotting Settings
+---------------------------------+------------------------------------------------------------------+---------------------+
|``plots.images.Colormap`` |Default colormap for image plots |``viridis`` |
+---------------------------------+------------------------------------------------------------------+---------------------+
|``plots.images.ColorBarScale`` |Default colorbar scale for image plots |``Linear`` |
+---------------------------------+------------------------------------------------------------------+---------------------+
Getting access to Mantid properties
***********************************
...
...
qt/applications/workbench/workbench/widgets/settings/plots/presenter.py
View file @
0db366b2
...
...
@@ -39,6 +39,7 @@ class PlotProperties(Enum):
SHOW_MINOR_TICKS
=
"plots.ShowMinorTicks"
SHOW_MINOR_GRIDLINES
=
"plots.ShowMinorGridlines"
COLORMAP
=
"plots.images.Colormap"
COLORBAR_SCALE
=
"plots.images.ColorBarScale"
class
PlotSettings
(
object
):
...
...
@@ -67,6 +68,7 @@ class PlotSettings(object):
self
.
view
.
draw_style
.
addItems
(
VALID_DRAW_STYLE
)
self
.
view
.
marker_style
.
addItems
(
MARKER_STYLES
.
keys
())
self
.
view
.
default_colormap_combo_box
.
addItems
(
get_colormap_names
())
self
.
view
.
colorbar_scale
.
addItems
(
self
.
AXES_SCALE
)
def
load_general_setting_values
(
self
):
normalize_to_bin_width
=
"on"
==
ConfigService
.
getString
(
PlotProperties
.
NORMALIZATION
.
value
).
lower
()
...
...
@@ -144,6 +146,11 @@ class PlotSettings(object):
self
.
view
.
default_colormap_combo_box
.
setCurrentIndex
(
self
.
view
.
default_colormap_combo_box
.
findText
(
colormap
[:
-
2
]))
self
.
view
.
reverse_colormap_check_box
.
setChecked
(
True
)
colorbar_scale
=
ConfigService
.
getString
(
PlotProperties
.
COLORBAR_SCALE
.
value
)
if
colorbar_scale
in
self
.
AXES_SCALE
:
self
.
view
.
colorbar_scale
.
setCurrentIndex
(
self
.
view
.
colorbar_scale
.
findText
(
colorbar_scale
))
else
:
self
.
view
.
colorbar_scale
.
setCurrentIndex
(
0
)
@
staticmethod
def
_setup_style_combo_boxes
(
current_style
,
style_combo
,
combo_items
):
...
...
@@ -173,6 +180,7 @@ class PlotSettings(object):
self
.
view
.
default_colormap_combo_box
.
currentTextChanged
.
connect
(
self
.
action_default_colormap_changed
)
self
.
view
.
reverse_colormap_check_box
.
stateChanged
.
connect
(
self
.
action_default_colormap_changed
)
self
.
view
.
plot_font
.
currentTextChanged
.
connect
(
self
.
action_font_combo_changed
)
self
.
view
.
colorbar_scale
.
currentTextChanged
.
connect
(
self
.
action_colorbar_scale_changed
)
def
action_normalization_changed
(
self
,
state
):
ConfigService
.
setString
(
PlotProperties
.
NORMALIZATION
.
value
,
"On"
if
state
==
Qt
.
Checked
else
"Off"
)
...
...
@@ -232,6 +240,9 @@ class PlotSettings(object):
def
action_legend_size_changed
(
self
,
value
):
ConfigService
.
setString
(
PlotProperties
.
LEGEND_FONT_SIZE
.
value
,
str
(
value
))
def
action_colorbar_scale_changed
(
self
,
value
):
ConfigService
.
setString
(
PlotProperties
.
COLORBAR_SCALE
.
value
,
value
)
def
action_default_colormap_changed
(
self
):
colormap
=
self
.
view
.
default_colormap_combo_box
.
currentText
()
if
self
.
view
.
reverse_colormap_check_box
.
isChecked
():
...
...
qt/applications/workbench/workbench/widgets/settings/plots/section_plots.ui
View file @
0db366b2
...
...
@@ -6,8 +6,8 @@
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
801
</width>
<height>
620
</height>
<width>
922
</width>
<height>
704
</height>
</rect>
</property>
<property
name=
"windowTitle"
>
...
...
@@ -32,9 +32,9 @@
<property
name=
"geometry"
>
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
767
</width>
<height>
971
</height>
<y>
-126
</y>
<width>
885
</width>
<height>
810
</height>
</rect>
</property>
<property
name=
"sizePolicy"
>
...
...
@@ -539,6 +539,27 @@
<string>
Images
</string>
</property>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout_10"
>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_16"
>
<item>
<widget
class=
"QLabel"
name=
"colorbar_scale_label"
>
<property
name=
"text"
>
<string>
Colorbar Scale
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QComboBox"
name=
"colorbar_scale"
>
<property
name=
"maximumSize"
>
<size>
<width>
202
</width>
<height>
16777215
</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_13"
>
<property
name=
"spacing"
>
...
...
qt/python/mantidqt/plotting/functions.py
View file @
0db366b2
...
...
@@ -12,12 +12,13 @@ our custom window.
"""
# std imports
import
matplotlib
import
numpy
as
np
# local imports
from
mantid.api
import
AnalysisDataService
,
MatrixWorkspace
from
mantid.plots.plotfunctions
import
manage_workspace_names
,
figure_title
,
plot
,
\
create_subplots
,
raise_if_not_sequence
,
plot_md_histo_ws
from
mantid.plots.plotfunctions
import
manage_workspace_names
,
figure_title
,
plot
,
\
create_subplots
,
raise_if_not_sequence
,
plot_md_histo_ws
from
mantid.kernel
import
Logger
,
ConfigService
from
mantid.plots.datafunctions
import
add_colorbar_label
...
...
@@ -26,7 +27,6 @@ from mantidqt.plotting.figuretype import figure_type, FigureType
from
mantidqt.dialogs.spectraselectorutils
import
get_spectra_selection
from
mantid.api
import
IMDHistoWorkspace
# -----------------------------------------------------------------------------
# Constants
# -----------------------------------------------------------------------------
...
...
@@ -40,6 +40,7 @@ DEFAULT_CONTOUR_LEVELS = 2
DEFAULT_CONTOUR_COLOUR
=
'k'
DEFAULT_CONTOUR_WIDTH
=
0.5
# -----------------------------------------------------------------------------
# 'Public' Functions
# -----------------------------------------------------------------------------
...
...
@@ -250,6 +251,7 @@ def pcolormesh(workspaces, fig=None):
# If there are multiple plots limits are the min and max of all the plots
colorbar_min
=
min
(
pt
.
norm
.
vmin
for
pt
in
plots
)
colorbar_max
=
max
(
pt
.
norm
.
vmax
for
pt
in
plots
)
print
(
"MIN MAX ARE"
,
colorbar_min
,
colorbar_max
)
for
pt
in
plots
:
pt
.
set_clim
(
colorbar_min
,
colorbar_max
)
...
...
@@ -261,7 +263,7 @@ def pcolormesh(workspaces, fig=None):
add_colorbar_label
(
colorbar
,
axes
)
fig
.
canvas
.
set_window_title
(
figure_title
(
workspaces
,
fig
.
number
))
#assert a minimum size, otherwise we can lose axis labels
#
assert a minimum size, otherwise we can lose axis labels
size
=
fig
.
get_size_inches
()
if
(
size
[
0
]
<=
COLORPLOT_MIN_WIDTH
)
or
(
size
[
1
]
<=
COLORPLOT_MIN_HEIGHT
):
fig
.
set_size_inches
(
COLORPLOT_MIN_WIDTH
,
COLORPLOT_MIN_HEIGHT
,
forward
=
True
)
...
...
@@ -279,10 +281,12 @@ def pcolormesh_on_axis(ax, ws):
"""
ax
.
clear
()
ax
.
set_title
(
ws
.
name
())
scale
=
_get_colorbar_scale
()
if
use_imshow
(
ws
):
pcm
=
ax
.
imshow
(
ws
,
cmap
=
ConfigService
.
getString
(
"plots.images.Colormap"
),
aspect
=
'auto'
,
origin
=
'lower'
)
pcm
=
ax
.
imshow
(
ws
,
cmap
=
ConfigService
.
getString
(
"plots.images.Colormap"
),
aspect
=
'auto'
,
origin
=
'lower'
,
norm
=
scale
())
else
:
pcm
=
ax
.
pcolormesh
(
ws
,
cmap
=
ConfigService
.
getString
(
"plots.images.Colormap"
))
pcm
=
ax
.
pcolormesh
(
ws
,
cmap
=
ConfigService
.
getString
(
"plots.images.Colormap"
)
,
norm
=
scale
()
)
return
pcm
...
...
@@ -292,6 +296,15 @@ def _validate_pcolormesh_inputs(workspaces):
raise_if_not_sequence
(
workspaces
,
'workspaces'
,
MatrixWorkspace
)
def
_get_colorbar_scale
():
"""Get the scale type (Linear, Log) for the colorbar in image type plots"""
scale
=
ConfigService
.
getString
(
"plots.images.ColorBarScale"
)
if
scale
==
"Log"
:
return
matplotlib
.
colors
.
LogNorm
else
:
return
matplotlib
.
colors
.
Normalize
@
manage_workspace_names
def
plot_surface
(
workspaces
,
fig
=
None
):
# Imported here to prevent pyplot being imported before matplotlib.use() is called when Workbench is opened.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment