Skip to content

Commit

Permalink
Better axis fonts for spectrum viewers (spacetelescope#2372)
Browse files Browse the repository at this point in the history
* Reduce num ticks for Mosviz
and Specviz2D spectrum viewers to avoid crowding

Adjust axis ticks and labels

* styling tweaks

Co-authored-by: jenneh <[email protected]>

* Add change log

* DOC: Tell users how to show axes again

in Cubeviz

---------

Co-authored-by: Kyle Conroy <[email protected]>
Co-authored-by: jenneh <[email protected]>
  • Loading branch information
3 people authored Aug 25, 2023
1 parent 5d26c93 commit 2e61f48
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
^^^^^^^

Expand Down
1 change: 1 addition & 0 deletions docs/cubeviz/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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::

Expand Down
8 changes: 8 additions & 0 deletions jdaviz/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
</style>
3 changes: 3 additions & 0 deletions jdaviz/configs/cubeviz/plugins/viewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 18 additions & 2 deletions jdaviz/configs/mosviz/plugins/viewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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):
Expand Down
15 changes: 13 additions & 2 deletions jdaviz/configs/specviz/plugins/viewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}

0 comments on commit 2e61f48

Please sign in to comment.