Changeset fecfe28 in sasview


Ignore:
Timestamp:
Dec 8, 2016 9:49:50 AM (7 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
3b7b218
Parents:
b4b8589
Message:

Code review for 3D plots.

Location:
src/sas/qtgui
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/PlotUtilities.py

    r31c5b58 rfecfe28  
    1313    """ 
    1414    # No qx or qy given in a vector format 
    15     if qx_data == None or qy_data == None \ 
     15    if qx_data is None or qy_data is None \ 
    1616            or qx_data.ndim != 1 or qy_data.ndim != 1: 
    1717        return data 
     
    7272    """ 
    7373    # No qx or qy given in a vector format 
    74     if qx_data == None or qy_data == None \ 
     74    if qx_data is None or qy_data is None \ 
    7575            or qx_data.ndim != 1 or qy_data.ndim != 1: 
    7676        return data 
  • src/sas/qtgui/Plotter.py

    rb4b8589 rfecfe28  
    88 
    99class PlotterWidget(PlotterBase): 
     10    """ 
     11    1D Plot widget for use with a QDialog 
     12    """ 
    1013    def __init__(self, parent=None, manager=None, quickplot=False): 
    1114        super(PlotterWidget, self).__init__(parent, manager=manager, quickplot=quickplot) 
  • src/sas/qtgui/Plotter2D.py

    rb4b8589 rfecfe28  
    1111from mpl_toolkits.mplot3d import Axes3D 
    1212 
     13# Minimum value of Z for which we will present data. 
     14MIN_Z=-32 
     15 
    1316class Plotter2DWidget(PlotterBase): 
     17    """ 
     18    2D Plot widget for use with a QDialog 
     19    """ 
    1420    def __init__(self, parent=None, manager=None, quickplot=False, dimension=2): 
    1521        self.dimension = dimension 
     
    2430        """ data setter """ 
    2531        self._data = data 
    26         self.qx_data=data.qx_data 
    27         self.qy_data=data.qy_data 
    28         self.xmin=data.xmin 
    29         self.xmax=data.xmax 
    30         self.ymin=data.ymin 
    31         self.ymax=data.ymax 
    32         self.zmin=data.zmin 
    33         self.zmax=data.zmax 
    34         self.label=data.name 
    35         self.xLabel="%s(%s)"%(data._xaxis, data._xunit) 
    36         self.yLabel="%s(%s)"%(data._yaxis, data._yunit) 
     32        self.qx_data = data.qx_data 
     33        self.qy_data = data.qy_data 
     34        self.xmin = data.xmin 
     35        self.xmax = data.xmax 
     36        self.ymin = data.ymin 
     37        self.ymax = data.ymax 
     38        self.zmin = data.zmin 
     39        self.zmax = data.zmax 
     40        self.label = data.name 
     41        self.xLabel = "%s(%s)"%(data._xaxis, data._xunit) 
     42        self.yLabel = "%s(%s)"%(data._yaxis, data._yunit) 
    3743        self.title(title=data.title) 
    3844 
     
    4450        zmin_2D_temp = self.zmin 
    4551        zmax_2D_temp = self.zmax 
     52        # self.scale predefined in the baseclass 
    4653        if self.scale == 'log_{10}': 
    4754            self.scale = 'linear' 
     
    5562                # min log value: no log(negative) 
    5663                if self.zmin <= 0: 
    57                     zmin_2D_temp = -32 
     64                    zmin_2D_temp = MIN_Z 
    5865                else: 
    5966                    zmin_2D_temp = numpy.log10(self.zmin) 
     
    115122        self.zmax = zmax 
    116123        # If we don't have any data, skip. 
    117         if data == None: 
     124        if data is None: 
    118125            return 
    119126        if data.ndim == 1: 
     
    132139                    zmin_temp = self.zmin 
    133140                    output[output > 0] = numpy.zeros(len(output)) 
    134                     output[output <= 0] = -32 
     141                    output[output <= 0] = MIN_Z 
    135142                else: 
    136143                    zmin_temp = self.zmin 
     
    163170                self.ax.set_title(label=self._title) 
    164171 
     172            if cbax is None: 
     173                ax.set_frame_on(False) 
     174                cb = self.figure.colorbar(im, shrink=0.8, aspect=20) 
     175            else: 
     176                cb = self.figure.colorbar(im, cax=cbax) 
     177 
     178            cb.update_bruteforce(im) 
     179            cb.set_label('$' + self.scale + '$') 
    165180 
    166181        else: 
     
    175190 
    176191            ax = Axes3D(self.figure) 
    177             cbax = self.figure.add_axes([0.84, 0.1, 0.02, 0.8]) 
     192            #cbax = self.figure.add_axes([0.84, 0.1, 0.02, 0.8]) 
    178193 
    179194            # Disable rotation for large sets. 
     
    188203            self.ax.set_axis_off() 
    189204 
    190         if cbax == None: 
    191             ax.set_frame_on(False) 
    192             cb = self.figure.colorbar(im, shrink=0.8, aspect=20) 
    193         else: 
    194             cb = self.figure.colorbar(im, cax=cbax) 
    195  
    196         cb.update_bruteforce(im) 
    197         cb.set_label('$' + self.scale + '$') 
    198  
    199205        if self.dimension != 3: 
    200206            self.figure.canvas.draw_idle() 
  • src/sas/qtgui/UnitTesting/PlotterTest.py

    r416fa8f rfecfe28  
    4444        self.assertEqual(self.plotter.yLabel, "$()$") 
    4545 
    46     def testPlot(self): 
    47         """ Look at the plotting """ 
     46    def testPlotWithErrors(self): 
     47        """ Look at the plotting with error bars""" 
    4848        self.plotter.data = self.data 
    4949        self.plotter.show() 
    5050        FigureCanvas.draw = MagicMock() 
    5151 
    52         self.plotter.plot() 
     52        self.plotter.plot(hide_error=False) 
    5353 
     54        self.assertEqual(self.plotter.ax.get_xscale(), 'log') 
     55        self.assertTrue(FigureCanvas.draw.called) 
     56 
     57    def testPlotWithoutErrors(self): 
     58        """ Look at the plotting without error bars""" 
     59        self.plotter.data = self.data 
     60        self.plotter.show() 
     61        FigureCanvas.draw = MagicMock() 
     62 
     63        self.plotter.plot(hide_error=True) 
     64 
     65        self.assertEqual(self.plotter.ax.get_yscale(), 'log') 
    5466        self.assertTrue(FigureCanvas.draw.called) 
    5567 
Note: See TracChangeset for help on using the changeset viewer.