Ignore:
Timestamp:
Jul 2, 2017 7:27:09 PM (5 years ago)
Author:
toby
Message:

merge trunk changes to 2984

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branch/2frame/GSASIIplot.py

    r2891 r2895  
    11811181##### PlotPatterns
    11821182################################################################################
     1183def SequentialPlotPattern(G2frame,refdata,histogram):
     1184    '''This is passed into :func:`GSASIIstrMain.SeqRefine` where it is used to
     1185    provide a plot of the current powder histogram just after a refinement. It
     1186    takes the old refinement information (Rfactors, curve locations, etc.) and
     1187    combines it with the refinement results in refdata and passes that to
     1188    :func:`PlotPatterns`
     1189    '''
     1190    if not histogram.startswith('PWDR'): return
     1191    pickId = G2frame.PickId
     1192    G2frame.PickId = G2frame.PatternId = G2gd.GetPatternTreeItemId(G2frame, G2frame.root, histogram)
     1193    treedata = G2frame.PatternTree.GetItemPyData(G2frame.PatternId)
     1194    PlotPatterns(G2frame,newPlot=True,plotType='PWDR',data=[treedata[0],refdata])
     1195    wx.Yield() # force a plot update (needed on Windows?)
     1196    G2frame.PickId = pickId
     1197   
    11831198def ReplotPattern(G2frame,newPlot,plotType,PatternName=None,PickName=None):
    11841199    '''This does the same as PlotPatterns except that it expects the information
     
    11961211    PlotPatterns(G2frame,newPlot,plotType)
    11971212
    1198 def PlotPatterns(G2frame,newPlot=False,plotType='PWDR'):
     1213def PlotPatterns(G2frame,newPlot=False,plotType='PWDR',data=None):
    11991214    '''Powder pattern plotting package - displays single or multiple powder patterns as intensity vs
    12001215    2-theta, q or TOF. Can display multiple patterns as "waterfall plots" or contour plots. Log I
     
    12201235        return
    12211236#patch
    1222     data = G2frame.PatternTree.GetItemPyData(G2frame.PatternId)
     1237    if data is None:
     1238        data = G2frame.PatternTree.GetItemPyData(G2frame.PatternId)
    12231239    if 'Offset' not in data[0] and plotType in ['PWDR','SASD','REFD']:     #plot offset data
    12241240        Ymax = max(data[1][1])
     
    18241840        Page.canvas.mpl_connect('button_press_event',OnPress)
    18251841    if 'PWDR' in G2frame.PatternTree.GetItemText(G2frame.PickId):
     1842        Histograms,Phases = G2frame.GetUsedHistogramsAndPhasesfromTree()
     1843        refColors=['b','r','c','g','m','k']
     1844        Page.phaseColors = {p:refColors[i%len(refColors)] for i,p in enumerate(Phases)}
    18261845        Phases = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId,'Reflection Lists'))
    18271846        Page.phaseList = sorted(Phases.keys()) # define an order for phases (once!)
     
    22152234        elif G2frame.PatternTree.GetItemText(PickId) in ['Reflection Lists'] or \
    22162235            'PWDR' in G2frame.PatternTree.GetItemText(PickId):
    2217             refColors=['b','r','c','g','m','k']
    22182236            Phases = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId,'Reflection Lists'))
    22192237            l = GSASIIpath.GetConfigValue('Tick_length',8.0)
     
    22302248                    peak = np.array([[peak[4],peak[5]] for peak in peaks])
    22312249                pos = Pattern[0]['refOffset']-pId*Pattern[0]['refDelt']*np.ones_like(peak)
     2250                plsym = Page.phaseColors.get(phase,'y')+'|' # yellow should never happen!
    22322251                if G2frame.plotStyle['qPlot']:
    2233                     Page.tickDict[phase],j = Plot.plot(2*np.pi/peak.T[0],pos,refColors[pId%6]+'|',mew=w,ms=l,picker=3.,label=phase)
     2252                    Page.tickDict[phase],j = Plot.plot(2*np.pi/peak.T[0],pos,plsym,mew=w,ms=l,picker=3.,label=phase)
    22342253                elif G2frame.plotStyle['dPlot']:
    2235                     Page.tickDict[phase],j = Plot.plot(peak.T[0],pos,refColors[pId%6]+'|',mew=w,ms=l,picker=3.,label=phase)
     2254                    Page.tickDict[phase],j = Plot.plot(peak.T[0],pos,plsym,mew=w,ms=l,picker=3.,label=phase)
    22362255                else:
    2237                     Page.tickDict[phase],j = Plot.plot(peak.T[1],pos,refColors[pId%6]+'|',mew=w,ms=l,picker=3.,label=phase)
     2256                    Page.tickDict[phase],j = Plot.plot(peak.T[1],pos,plsym,mew=w,ms=l,picker=3.,label=phase)
    22382257            if len(Phases):
    22392258                handles,legends = Plot.get_legend_handles_labels()  #got double entries in the legends for some reason
Note: See TracChangeset for help on using the changeset viewer.