def _setLabels2D(axes, workspace, indices=None, transpose=False, xscale=None, normalize_by_bin_width=True): ''' helper function to automatically set axes labels for 2D plots ''' labels = get_axes_labels(workspace, indices, normalize_by_bin_width) if transpose: axes.set_xlabel(labels[2]) axes.set_ylabel(labels[1]) else: axes.set_xlabel(labels[1]) axes.set_ylabel(labels[2]) axes.set_title(labels[0]) if xscale is None and hasattr(workspace, 'isCommonLogBins') and workspace.isCommonLogBins(): axes.set_xscale('log') elif xscale is not None: axes.set_xscale(xscale)
def test_get_axes_label_2d_MDWS_indices(self): axs = funcs.get_axes_labels(self.ws_MD_2d, indices=(0, slice(None), 0)) # should get the first two dimension labels only self.assertEqual( axs, ('Intensity', 'Dim2 (EnergyTransfer)', 'Dim1=-2.4; Dim3=0.0;'))
def test_get_axes_label_2d_MDWS(self): axs = funcs.get_axes_labels(self.ws_MD_2d) # should get the first two dimension labels only self.assertEqual( axs, ('Intensity', 'Dim1 ($\\AA^{-1}$)', 'Dim2 (EnergyTransfer)', ''))
def test_y_units_for_non_distribution_and_autodist_on_with_latex(self): ws = self.ws2d_non_distribution labels = funcs.get_axes_labels(ws, normalize_by_bin_width=True) self.assertEqual(labels[0], 'Counts (microAmp.hour $\\AA$)$^{-1}$')
def test_y_units_for_non_distribution_and_autodist_on_with_ascii(self): ws = self.ws2d_non_distribution labels = funcs.get_axes_labels(ws, normalize_by_bin_width=True, use_latex=False) self.assertEqual(labels[0], 'Counts per microAmp.hour per Angstrom')
def test_y_units_correct_on_distribution_workspace(self): ws = self.ws2d_distribution labels = funcs.get_axes_labels(ws) self.assertEqual(labels[0], 'Counts (microAmp.hour)$^{-1}$')
def test_get_axes_labels(self): axs = funcs.get_axes_labels(self.ws2d_histo) self.assertEqual(axs, ('($\\AA$)$^{-1}$', 'Wavelength ($\\AA$)', 'Energy transfer ($meV$)'))