Changeset 64f1e93 in sasview for src/sas/qtgui/Plotter2D.py


Ignore:
Timestamp:
Dec 7, 2016 5:47:22 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:
416fa8f
Parents:
55d89f8
Message:

2D plots: more unit tests + minor cleanup

File:
1 edited

Legend:

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

    r55d89f8 r64f1e93  
    99import sas.qtgui.PlotUtilities as PlotUtilities 
    1010from sas.qtgui.PlotterBase import PlotterBase 
     11from mpl_toolkits.mplot3d import Axes3D 
    1112 
    1213class Plotter2D(PlotterBase): 
     
    4041        Plot 2D self._data 
    4142        """ 
    42         # create an axis object 
     43        # Toggle the scale 
    4344        zmin_2D_temp = self.zmin 
    4445        zmax_2D_temp = self.zmax 
     
    6061                zmax_2D_temp = numpy.log10(self.zmax) 
    6162 
    62         self.image(data=self.data.data, qx_data=self.qx_data, 
    63                    qy_data=self.qy_data, xmin=self.xmin, 
    64                    xmax=self.xmax, 
    65                    ymin=self.ymin, ymax=self.ymax, 
    66                    cmap=self.cmap, zmin=zmin_2D_temp, 
    67                    zmax=zmax_2D_temp) 
     63        # Prepare and show the plot 
     64        self.showPlot(data=self.data.data, 
     65                      qx_data=self.qx_data, 
     66                      qy_data=self.qy_data, 
     67                      xmin=self.xmin, 
     68                      xmax=self.xmax, 
     69                      ymin=self.ymin, ymax=self.ymax, 
     70                      cmap=self.cmap, zmin=zmin_2D_temp, 
     71                      zmax=zmax_2D_temp) 
    6872 
    6973    def contextMenuQuickPlot(self): 
     
    96100        self.plot() 
    97101 
    98     def image(self, data, qx_data, qy_data, xmin, xmax, ymin, ymax, 
    99               zmin, zmax, color=0, symbol=0, markersize=0, 
    100               label='data2D', cmap=DEFAULT_CMAP): 
     102    def showPlot(self, data, qx_data, qy_data, xmin, xmax, ymin, ymax, 
     103                 zmin, zmax, color=0, symbol=0, markersize=0, 
     104                 label='data2D', cmap=DEFAULT_CMAP): 
    101105        """ 
    102         Render the current data 
     106        Render and show the current data 
    103107        """ 
    104108        self.qx_data = qx_data 
     
    152156        else: 
    153157            # clear the previous 2D from memory 
    154             # mpl is not clf, so we do 
    155158            self.figure.clear() 
    156159 
     
    161164            X, Y = numpy.meshgrid(X, Y) 
    162165 
    163             try: 
    164                 # mpl >= 1.0.0 
    165                 ax = self.figure.gca(projection='3d') 
    166                 cbax = self.figure.add_axes([0.84, 0.1, 0.02, 0.8]) 
    167                 if len(X) > 60: 
    168                     ax.disable_mouse_rotation() 
    169             except: 
    170                 # mpl < 1.0.0 
    171                 try: 
    172                     from mpl_toolkits.mplot3d import Axes3D 
    173                 except: 
    174                     logging.error("PlotPanel could not import Axes3D") 
    175                 self.figure.clear() 
    176                 ax = Axes3D(self.figure) 
    177                 if len(X) > 60: 
    178                     ax.cla() 
    179                 cbax = None 
     166            ax = Axes3D(self.figure) 
     167            cbax = self.figure.add_axes([0.84, 0.1, 0.02, 0.8]) 
     168            # Disable rotation for large sets. 
     169            # TODO: Define "large" for a dataset 
     170            SET_TOO_LARGE = 500 
     171            if len(X) > SET_TOO_LARGE: 
     172                ax.disable_mouse_rotation() 
     173 
    180174            self.figure.canvas.resizing = False 
    181175            im = ax.plot_surface(X, Y, output, rstride=1, cstride=1, cmap=cmap, 
     
    190184        cb.update_bruteforce(im) 
    191185        cb.set_label('$' + self.scale + '$') 
     186 
    192187        if self.dimension != 3: 
    193188            self.figure.canvas.draw_idle() 
Note: See TracChangeset for help on using the changeset viewer.