Changeset 4641 for trunk/GSASIIplot.py


Ignore:
Timestamp:
Nov 3, 2020 8:30:31 AM (2 years ago)
Author:
vondreele
Message:

add color contouring to map slice display. Will plot lines, colors or lines+colors. Allows color scheme selection

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIplot.py

    r4639 r4641  
    81488148           
    81498149        elif key in ['K'] and generalData['Map']['MapType']:
    8150             drawingData['showSlice'] = not drawingData.get('showSlice',False)
     8150            drawingData['showSlice'] = (drawingData['showSlice']+1)%4
    81518151            SetShowCS(drawingData['showSlice'])
     8152           
     8153        elif key in ['S']:
     8154            choice = [m for m in mpl.cm.datad.keys()]   # if not m.endswith("_r")
     8155            choice.sort()
     8156            dlg = wx.SingleChoiceDialog(G2frame,'Select','Color scheme',choice)
     8157            if dlg.ShowModal() == wx.ID_OK:
     8158                sel = dlg.GetSelection()
     8159                drawingData['contourColor'] = choice[sel]
     8160            dlg.Destroy()
    81528161               
    81538162        elif key in ['P']:
     
    83888397                    G2frame.G2plotNB.status.SetStatusText('New quaternion: %.2f+, %.2fi+ ,%.2fj+, %.2fk'%(Q[0],Q[1],Q[2],Q[3]),1)
    83898398                Draw('move')
    8390         elif drawingData.get('showSlice'):
     8399        elif drawingData['showSlice']:
    83918400            View = GL.glGetIntegerv(GL.GL_VIEWPORT)
    83928401            Tx,Ty,Tz = drawingData['viewPoint'][0]
     
    83948403            Cx,Cy,Cz = GLU.gluUnProject(newxy[0],View[3]-newxy[1],tz)
    83958404            rho = G2mth.getRho([Cx,Cy,Cz],mapData)
    8396             contlevels = contourSet.get_array()
    8397             contstr = str(contlevels).strip('[]')
    8398             G2frame.G2plotNB.status.SetStatusText('Cursor position: %.4f, %.4f, %.4f; density: %.4f, contours at: %s'%(Cx,Cy,Cz,rho,contstr),1)
     8405            if drawingData['showSlice'] in [1,3]:
     8406                contlevels = contourSet.get_array()
     8407                contstr = str(contlevels).strip('[]')
     8408                G2frame.G2plotNB.status.SetStatusText('Cursor position: %.4f, %.4f, %.4f; density: %.4f, contours at: %s'%(Cx,Cy,Cz,rho,contstr),1)
     8409            else:
     8410                G2frame.G2plotNB.status.SetStatusText('Cursor position: %.4f, %.4f, %.4f; density: %.4f'%(Cx,Cy,Cz,rho),1)
    83998411       
    84008412    def OnMouseWheel(event):
     
    94159427                for plane in Planes:
    94169428                    RenderPlane(plane,color)
    9417         if drawingData.get('showSlice',False):      #must be done last to properly show things behind as faded
     9429        if drawingData.get('showSlice',0):      #must be done last to properly show things behind as faded
    94189430            global contourSet,Zslice
    94199431            if len(D4mapData.get('rho',[])):        #preferentially select 4D map if there
     
    94419453                Zslice = np.reshape(map_coordinates(rho,(SXYZ%1.*rho.shape).T,order=1,mode='wrap'),(npts,npts))
    94429454            Z = np.where(Zslice<=Rmax,Zslice,Rmax)
     9455            ZU = np.flipud(Z)
    94439456            plt.rcParams['figure.facecolor'] = (1.,1.,1.,.5)
    94449457            oldSize = plt.rcParams['figure.figsize']
    94459458            plt.rcParams['figure.figsize'] = [6.0,6.0]
    94469459            plt.cla()
    9447             contourSet = plt.contour(Z,colors='k',linewidths=1)
     9460            if drawingData['showSlice'] in [1,]:
     9461                contourSet = plt.contour(Z,colors='k',linewidths=1)
     9462            if drawingData['showSlice'] in [2,3]:
     9463                acolor = mpl.cm.get_cmap(drawingData.get('contourColor','Paired'))                   
     9464                plt.imshow(ZU,aspect='equal',cmap=acolor,alpha=0.75,interpolation='bilinear')
     9465                if drawingData['showSlice'] in [3,]:
     9466                    contourSet = plt.contour(ZU,colors='k',linewidths=1)
    94489467            plt.axis("off")
    94499468            plt.subplots_adjust(bottom=0.,top=1.,left=0.,right=1.,wspace=0.,hspace=0.)
     
    95759594    choice = [' save as/key:','jpeg','tiff','bmp','c: center on 1/2,1/2,1/2']
    95769595    if mapData['MapType']:
    9577         choice += ['k: toggle contour plot',]
     9596        choice += ['k: none, lines, color, color+lines contour plot switch',]
     9597        choice += ['s: select map slice color scheme',]
    95789598    if mapData.get('Flip',False):
    95799599        choice += ['u: roll up','d: roll down','l: roll left','r: roll right']
Note: See TracChangeset for help on using the changeset viewer.