From 2e61f488f60a5cffe276bad4115af085f4e24f04 Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Fri, 25 Aug 2023 18:18:26 -0400 Subject: [PATCH] Better axis fonts for spectrum viewers (#2372) * Reduce num ticks for Mosviz and Specviz2D spectrum viewers to avoid crowding Adjust axis ticks and labels * styling tweaks Co-authored-by: jenneh * Add change log * DOC: Tell users how to show axes again in Cubeviz --------- Co-authored-by: Kyle Conroy Co-authored-by: jenneh --- CHANGES.rst | 3 +++ docs/cubeviz/plugins.rst | 1 + jdaviz/app.vue | 8 ++++++++ jdaviz/configs/cubeviz/plugins/viewers.py | 3 +++ jdaviz/configs/mosviz/plugins/viewers.py | 20 ++++++++++++++++++-- jdaviz/configs/specviz/plugins/viewers.py | 15 +++++++++++++-- 6 files changed, 46 insertions(+), 4 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 210996986a..f58b0a2ab7 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -36,6 +36,9 @@ Specviz2d API Changes ----------- +- Adjusted axis ticks and labels for spectrum viewers to be more readable. + Axes on image viewers no longer show by default. [#2372] + Cubeviz ^^^^^^^ diff --git a/docs/cubeviz/plugins.rst b/docs/cubeviz/plugins.rst index 0a5c7d1c77..38f68afeb0 100644 --- a/docs/cubeviz/plugins.rst +++ b/docs/cubeviz/plugins.rst @@ -34,6 +34,7 @@ Plot Options ============ This plugin gives access to per-viewer and per-layer plotting options. +To show axes on image viewers, toggle on the "Show Axes" option at the bottom of the plugin. .. seealso:: diff --git a/jdaviz/app.vue b/jdaviz/app.vue index 80f2c6e508..6b5a10ad0f 100644 --- a/jdaviz/app.vue +++ b/jdaviz/app.vue @@ -431,4 +431,12 @@ a:active { * appearing */ overflow: hidden; } + +.jupyter-widgets.bqplot.figure .axislabel { + /* consistent with other labels (legend, buttons, plugin expansion menu labels, etc)*/ + font-size: 15px !important; + font-family: Roboto, sans-serif !important; + font-weight: 500 !important; +} + diff --git a/jdaviz/configs/cubeviz/plugins/viewers.py b/jdaviz/configs/cubeviz/plugins/viewers.py index 17652cf122..bd1c8ee7d0 100644 --- a/jdaviz/configs/cubeviz/plugins/viewers.py +++ b/jdaviz/configs/cubeviz/plugins/viewers.py @@ -36,6 +36,9 @@ def __init__(self, *args, **kwargs): self._subscribe_to_layers_update() self.state.add_callback('reference_data', self._initial_x_axis) + # Hide axes by default + self.state.show_axes = False + @property def _default_spectrum_viewer_reference_name(self): return self.jdaviz_helper._default_spectrum_viewer_reference_name diff --git a/jdaviz/configs/mosviz/plugins/viewers.py b/jdaviz/configs/mosviz/plugins/viewers.py index 62042087bb..69e370d8dc 100644 --- a/jdaviz/configs/mosviz/plugins/viewers.py +++ b/jdaviz/configs/mosviz/plugins/viewers.py @@ -212,10 +212,22 @@ def set_plot_axes(self): self.figure.axes[1].label = "y: pixels" self.figure.axes[1].tick_format = None - self.figure.axes[1].label_location = "start" + self.figure.axes[1].label_location = "middle" + # Sync with Spectrum1D viewer (that is also used by other viz). # Make it so y axis label is not covering tick numbers. - self.figure.axes[1].label_offset = "-50" + self.figure.fig_margin["left"] = 95 + self.figure.fig_margin["bottom"] = 60 + self.figure.send_state('fig_margin') # Force update + self.figure.axes[0].label_offset = "40" + self.figure.axes[1].label_offset = "-70" + # NOTE: with tick_style changed below, the default responsive ticks in bqplot result + # in overlapping tick labels. For now we'll hardcode at 8, but this could be removed + # (default to None) if/when bqplot auto ticks react to styling options. + self.figure.axes[1].num_ticks = 8 + + for i in (0, 1): + self.figure.axes[i].tick_style = {'font-size': 15, 'font-weight': 600} @viewer_registry("mosviz-profile-viewer", label="Profile 1D") @@ -230,6 +242,10 @@ class MosvizProfileView(SpecvizProfileView): ['jdaviz:sidebar_plot', 'jdaviz:sidebar_export'] ] + def set_plot_axes(self): + super().set_plot_axes() + self.figure.axes[1].num_ticks = 5 + @viewer_registry("mosviz-table-viewer", label="Table (Mosviz)") class MosvizTableViewer(TableViewer, JdavizViewerMixin): diff --git a/jdaviz/configs/specviz/plugins/viewers.py b/jdaviz/configs/specviz/plugins/viewers.py index 33806849a2..153b12a907 100644 --- a/jdaviz/configs/specviz/plugins/viewers.py +++ b/jdaviz/configs/specviz/plugins/viewers.py @@ -544,8 +544,19 @@ def set_plot_axes(self): self.figure.axes[0].label = f"{spectral_axis_unit_type} [{self.state.x_display_unit}]" self.figure.axes[1].label = f"{flux_unit_type} [{self.state.y_display_unit}]" - # Make it so y axis label is not covering tick numbers. - self.figure.axes[1].label_offset = "-50" + # Make it so axis labels are not covering tick numbers. + self.figure.fig_margin["left"] = 95 + self.figure.fig_margin["bottom"] = 60 + self.figure.send_state('fig_margin') # Force update + self.figure.axes[0].label_offset = "40" + self.figure.axes[1].label_offset = "-70" + # NOTE: with tick_style changed below, the default responsive ticks in bqplot result + # in overlapping tick labels. For now we'll hardcode at 8, but this could be removed + # (default to None) if/when bqplot auto ticks react to styling options. + self.figure.axes[1].num_ticks = 8 # Set Y-axis to scientific notation self.figure.axes[1].tick_format = '0.1e' + + for i in (0, 1): + self.figure.axes[i].tick_style = {'font-size': 15, 'font-weight': 600}