diff --git a/CHANGES.md b/CHANGES.md
index 2746464d..412c41dd 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -5,6 +5,9 @@
- No longer bundle vispy, and instead depend on the latest stable release. [#351]
+- Make it possible to modify the axis labels, as well as the font size of
+ the axis and tick labels, and the weight of the axis labels. [#352]
+
0.12.2 (unreleased)
-------------------
diff --git a/glue_vispy_viewers/common/viewer_options.ui b/glue_vispy_viewers/common/viewer_options.ui
index 04acb961..609eeac8 100644
--- a/glue_vispy_viewers/common/viewer_options.ui
+++ b/glue_vispy_viewers/common/viewer_options.ui
@@ -6,352 +6,563 @@
0
0
- 276
- 364
+ 291
+ 366
3D_Volume
-
+
- 5
+ 0
- 5
+ 0
- 5
+ 0
- 5
+ 0
-
- 5
-
- -
-
-
- min/max:
-
-
-
- -
-
-
-
-
-
- Perspective
-
-
- false
-
-
-
- -
-
-
- Show axes
-
-
- true
+
-
+
+
+ 2
+
+
+
+ General
+
+
+
+ 10
-
-
- -
-
-
- Native aspect ratio
+
+ 5
-
-
- -
-
-
- true
-
-
- Downsample when panning
-
-
- false
-
-
-
-
-
- -
-
-
-
- 75
- true
-
-
-
- y axis
-
-
-
- -
-
-
-
- 14
-
-
-
- padding: 0px
-
-
- ⇄
-
-
-
- -
-
-
- stretch:
-
-
-
- -
-
-
- -
-
-
- -10000
-
-
- 10000
-
-
- 0
-
-
- Qt::Horizontal
-
-
-
- -
-
-
- QComboBox::AdjustToMinimumContentsLength
-
-
-
- -
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
- -
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
- -
-
-
- stretch:
-
-
-
- -
-
-
- -10000
-
-
- 10000
-
-
- 0
-
-
- Qt::Horizontal
-
-
-
- -
-
-
- QComboBox::AdjustToMinimumContentsLength
-
-
-
- -
-
-
- min/max:
-
-
-
- -
-
-
- min/max:
-
-
-
- -
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
- -
-
-
-
- 75
- true
-
-
-
- x axis
-
-
-
- -
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
- -
-
-
-
- 14
-
-
-
- padding: 0px
-
-
- ⇄
-
-
-
- -
-
-
- stretch:
-
-
-
- -
-
-
- -10000
-
-
- 10000
-
-
- 0
-
-
- Qt::Horizontal
-
+
-
+
+
+ stretch:
+
+
+
+ -
+
+
+
+ 75
+ true
+
+
+
+ x axis
+
+
+
+ -
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+ -
+
+
+ stretch:
+
+
+
+ -
+
+
+ QComboBox::AdjustToMinimumContentsLength
+
+
+
+ -
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+ -
+
+
+
+ 75
+ true
+
+
+
+ y axis
+
+
+
+ -
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ -10000
+
+
+ 10000
+
+
+ 0
+
+
+ Qt::Horizontal
+
+
+
+ -
+
+
+ QComboBox::AdjustToMinimumContentsLength
+
+
+
+ -
+
+
+ QComboBox::AdjustToMinimumContentsLength
+
+
+
+ -
+
+
-
+
+
+ Perspective
+
+
+ false
+
+
+
+ -
+
+
+ Show axes
+
+
+ true
+
+
+
+ -
+
+
+ Native aspect ratio
+
+
+
+ -
+
+
+ true
+
+
+ Downsample when panning
+
+
+ false
+
+
+
+
+
+ -
+
+
+
+ 75
+ true
+
+
+
+ reference:
+
+
+
+ -
+
+
+
+ 75
+ true
+
+
+
+ resolution:
+
+
+
+ -
+
+
+ -
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ -10000
+
+
+ 10000
+
+
+ 0
+
+
+ Qt::Horizontal
+
+
+
+ -
+
+
+
+ 75
+ true
+
+
+
+ z axis
+
+
+
+ -
+
+
+ stretch:
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ -10000
+
+
+ 10000
+
+
+ 0
+
+
+ Qt::Horizontal
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+ Limits
+
+
+ -
+
+
+ -
+
+
+
+ 75
+ true
+
+
+
+ z axis
+
+
+
+ -
+
+
+
+ 75
+ true
+
+
+
+ x axis
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+ 14
+
+
+
+ padding: 0px
+
+
+ ⇄
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+ 75
+ true
+
+
+
+ y axis
+
+
+
+ -
+
+
+
+ 14
+
+
+
+ padding: 0px
+
+
+ ⇄
+
+
+
+ -
+
+
+
+ 14
+
+
+
+ padding: 0px
+
+
+ ⇄
+
+
+
+ -
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+ Axes
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 168
+
+
+
+
+ -
+
+
+ y label:
+
+
+
+ -
+
+
+ z label:
+
+
+
+ -
+
+
+ axis label size
+
+
+
+ -
+
+
+ tick label size
+
+
+
+ -
+
+
+ bold axis label
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ -
+
+
+ x
+
+
+
+ -
+
+
+ x label:
+
+
+
+ -
+
+
+ y
+
+
+
+ -
+
+
+ z
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- QComboBox::AdjustToMinimumContentsLength
-
-
-
- -
-
-
-
- 14
-
-
-
- padding: 0px
-
-
- ⇄
-
-
-
- -
-
-
- -
-
-
-
- 75
- true
-
-
-
- z axis
-
-
-
- -
-
-
-
- 75
- true
-
-
-
- resolution:
-
-
-
- -
-
-
- -
-
-
-
- 75
- true
-
-
-
- reference:
-
-
-
- -
-
-
diff --git a/glue_vispy_viewers/common/viewer_state.py b/glue_vispy_viewers/common/viewer_state.py
index d7446401..3e651edc 100644
--- a/glue_vispy_viewers/common/viewer_state.py
+++ b/glue_vispy_viewers/common/viewer_state.py
@@ -30,6 +30,22 @@ class Vispy3DViewerState(ViewerState):
z_max = CallbackProperty(1)
z_stretch = CallbackProperty(1.)
+ x_axislabel = CallbackProperty('', docstring='Label for the x-axis')
+ y_axislabel = CallbackProperty('', docstring='Label for the y-axis')
+ z_axislabel = CallbackProperty('', docstring='Label for the z-axis')
+
+ x_axislabel_size = CallbackProperty(10, docstring='Size of the x-axis label')
+ y_axislabel_size = CallbackProperty(10, docstring='Size of the y-axis label')
+ z_axislabel_size = CallbackProperty(10, docstring='Size of the z-axis label')
+
+ x_axislabel_bold = CallbackProperty(False, docstring='Weight of the x-axis label')
+ y_axislabel_bold = CallbackProperty(False, docstring='Weight of the y-axis label')
+ z_axislabel_bold = CallbackProperty(False, docstring='Weight of the z-axis label')
+
+ x_ticklabel_size = CallbackProperty(8, docstring='Size of the x-axis tick labels')
+ y_ticklabel_size = CallbackProperty(8, docstring='Size of the y-axis tick labels')
+ z_ticklabel_size = CallbackProperty(8, docstring='Size of the z-axis tick labels')
+
visible_axes = CallbackProperty(True)
perspective_view = CallbackProperty(False)
clip_data = CallbackProperty(True)
@@ -73,6 +89,19 @@ def __init__(self, **kwargs):
# avoid this altogether and make it more clean.
self.add_callback('limits_cache', self._update_limits_cache)
+ self.add_callback('x_att', self._on_x_att_change)
+ self.add_callback('y_att', self._on_y_att_change)
+ self.add_callback('z_att', self._on_z_att_change)
+
+ def _on_x_att_change(self, *args):
+ self.x_axislabel = '' if self.x_att is None else self.x_att.label
+
+ def _on_y_att_change(self, *args):
+ self.y_axislabel = '' if self.y_att is None else self.y_att.label
+
+ def _on_z_att_change(self, *args):
+ self.z_axislabel = '' if self.z_att is None else self.z_att.label
+
def reset_limits(self):
self.x_lim_helper.log = False
self.x_lim_helper.percentile = 100.
diff --git a/glue_vispy_viewers/common/vispy_widget.py b/glue_vispy_viewers/common/vispy_widget.py
index 0b1a17c5..2a0dd900 100644
--- a/glue_vispy_viewers/common/vispy_widget.py
+++ b/glue_vispy_viewers/common/vispy_widget.py
@@ -16,7 +16,6 @@
LIMITS_PROPS = [coord + attribute for coord in 'xyz' for attribute in ['_min', '_max', '_stretch']]
-
class VispyWidgetHelper(object):
def __init__(self, parent=None, viewer_state=None):
@@ -88,9 +87,6 @@ def _update_from_state(self, force=False, **props):
if force or 'perspective_view' in props:
self._toggle_perspective()
- if force or any(key in props for key in ('x_att', 'y_att', 'z_att')):
- self._update_attributes()
-
if force or any(key in props for key in ('x_stretch', 'y_stretch',
'z_stretch', 'native_aspect')):
self._update_stretch()
@@ -98,6 +94,22 @@ def _update_from_state(self, force=False, **props):
if force or any(p in props for p in LIMITS_PROPS) or 'native_aspect' in props:
self._update_limits()
+ for axis_name in 'xyz':
+
+ axis = getattr(self.axis, axis_name + 'ax')
+
+ if force or axis_name + '_axislabel' in props:
+ axis.axis_label = getattr(self.viewer_state, axis_name + '_axislabel')
+
+ if force or axis_name + '_axislabel_size' in props:
+ axis.axis_font_size = getattr(self.viewer_state, axis_name + '_axislabel_size')
+
+ if force or axis_name + '_axislabel_bold' in props:
+ axis._axis_label.bold = getattr(self.viewer_state, axis_name + '_axislabel_bold')
+
+ if force or axis_name + '_ticklabel_size' in props:
+ axis.tick_font_size = getattr(self.viewer_state, axis_name + '_ticklabel_size')
+
self.canvas.update()
def _toggle_axes(self):
@@ -116,14 +128,6 @@ def _toggle_perspective(self):
self.axis.tick_font_size = 6
self.axis.axis_font_size = 8
- def _update_attributes(self):
- if self.viewer_state.x_att is not None:
- self.axis.xlabel = self.viewer_state.x_att.label
- if self.viewer_state.y_att is not None:
- self.axis.ylabel = self.viewer_state.y_att.label
- if self.viewer_state.z_att is not None:
- self.axis.zlabel = self.viewer_state.z_att.label
-
def _update_stretch(self):
self.scene_transform.scale = (self.viewer_state.x_stretch * self.viewer_state.aspect[0],
self.viewer_state.y_stretch * self.viewer_state.aspect[1],
diff --git a/glue_vispy_viewers/compat/axis.py b/glue_vispy_viewers/compat/axis.py
index fdbb0a82..12ec224c 100644
--- a/glue_vispy_viewers/compat/axis.py
+++ b/glue_vispy_viewers/compat/axis.py
@@ -122,7 +122,7 @@ def __init__(self, pos=None, domain=(0., 1.), tick_direction=(-1., 0.),
self._text = TextVisual(font_size=tick_font_size, color=text_color)
self._axis_label = TextVisual(font_size=axis_font_size,
- color=text_color)
+ color=text_color, bold=True)
CompoundVisual.__init__(self, [self._line, self._text, self._ticks,
self._axis_label])
if pos is not None:
diff --git a/glue_vispy_viewers/compat/text.py b/glue_vispy_viewers/compat/text.py
index 1e0614f9..62ea81ee 100644
--- a/glue_vispy_viewers/compat/text.py
+++ b/glue_vispy_viewers/compat/text.py
@@ -414,7 +414,10 @@ def __init__(self, text=None, color='black', bold=False,
# Init font handling stuff
# _font_manager is a temporary solution to use global mananger
self._font_manager = font_manager or FontManager(method=method)
- self._font = self._font_manager.get_font(face, bold, italic)
+ self._face = face
+ self._bold = bold
+ self._italic = italic
+ self._update_font()
self._vertices = None
self._color_vbo = None
self._anchors = (anchor_x, anchor_y)
@@ -607,6 +610,37 @@ def _compute_bounds(self, axis, view):
return self._pos[:, axis].min(), self._pos[:, axis].max()
+ @property
+ def face(self):
+ return self._face
+
+ @face.setter
+ def face(self, value):
+ self._face = value
+ self._update_font()
+
+ @property
+ def bold(self):
+ return self._bold
+
+ @bold.setter
+ def bold(self, value):
+ self._bold = value
+ self._update_font()
+
+ @property
+ def italic(self):
+ return self._italic
+
+ @italic.setter
+ def italic(self, value):
+ self._italic = value
+ self._update_font()
+
+ def _update_font(self):
+ self._font = self._font_manager.get_font(self._face, self._bold, self._italic)
+ self.update()
+
class SDFRendererCPU(object):
"""Render SDFs using the CPU."""
# This should probably live in _sdf_cpu.pyx, but doing so makes