Changeset 2634 for trunk/GSASIIplot.py


Ignore:
Timestamp:
Jan 16, 2017 4:41:14 PM (6 years ago)
Author:
vondreele
Message:

add ExpandAll? to main File menu
change PDF plotting to use color schemes for multiplots
's' option on multiplot changed to color scheme selection
removed G9r0-4pi*r plot

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIplot.py

    r2618 r2634  
    23482348    or multiple plots with waterfall and contour plots as options
    23492349    '''
     2350    import matplotlib.collections as mplC
    23502351    if not plotType:
    23512352        plotType = G2frame.G2plotNB.plotList[G2frame.G2plotNB.nb.GetSelection()]
     
    23952396            newPlot = True
    23962397        elif event.key == 's':
    2397             if G2frame.Contour:
    2398                 choice = [m for m in mpl.cm.datad.keys() if not m.endswith("_r")]
    2399                 choice.sort()
    2400                 dlg = wx.SingleChoiceDialog(G2frame,'Select','Color scheme',choice)
    2401                 if dlg.ShowModal() == wx.ID_OK:
    2402                     sel = dlg.GetSelection()
    2403                     G2frame.ContourColor = choice[sel]
    2404                 else:
    2405                     G2frame.ContourColor = 'Paired'
    2406                 dlg.Destroy()
     2398            choice = [m for m in mpl.cm.datad.keys() if not m.endswith("_r")]
     2399            choice.sort()
     2400            dlg = wx.SingleChoiceDialog(G2frame,'Select','Color scheme',choice)
     2401            if dlg.ShowModal() == wx.ID_OK:
     2402                sel = dlg.GetSelection()
     2403                G2frame.ContourColor = choice[sel]
    24072404            else:
    2408                 G2frame.SinglePlot = not G2frame.SinglePlot               
     2405                G2frame.ContourColor = 'Paired'
     2406            dlg.Destroy()
    24092407        elif event.key == 'i':                  #for smoothing contour plot
    24102408            choice = ['nearest','bilinear','bicubic','spline16','spline36','hanning',
     
    24542452        Page.Choice = (' key press','l: offset left','r: offset right','d: offset down','u: offset up',
    24552453            'o: reset offset','t: toggle legend','c: contour on',
    2456             'm: toggle multiplot','s: toggle single plot','f: select data' )
     2454            'm: toggle multiplot','s: color scheme','f: select data' )
    24572455    Page.keyPress = OnPlotKeyPress
    24582456    PatternId = G2frame.PatternId
    2459     if plotType == 'G(R)':
    2460         Plot.set_xlabel(r'r,$\AA$',fontsize=14)
    2461         Plot.set_ylabel(r'G(r), $\AA^{-2}$',fontsize=14)
    2462         Plot.set_title('G(r)')
    2463     else:
    2464         Plot.set_xlabel(r'$Q,\AA^{-1}$'+superMinusOne,fontsize=14)
    2465         Plot.set_ylabel(r''+plotType,fontsize=14)
    2466         Plot.set_title(plotType)
    2467     colors=['b','g','r','c','m','k']
    24682457    name = G2frame.PatternTree.GetItemText(PatternId)[4:]
    24692458    Pattern = []   
     
    24902479                Pattern.append(item)
    24912480                PlotList.append(Pattern)
     2481        name = plotType
     2482    if plotType == 'G(R)':
     2483        Plot.set_xlabel(r'r,$\AA$',fontsize=14)
     2484        Plot.set_ylabel(r'G(r), $\AA^{-2}$',fontsize=14)
     2485        Plot.set_title(name)
     2486    else:
     2487        Plot.set_xlabel(r'$Q,\AA^{-1}$',fontsize=14)
     2488        Plot.set_ylabel(r''+plotType,fontsize=14)
     2489        Plot.set_title(name)
     2490    colors=['b','g','r','c','m','k']
    24922491    PDFdata = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'PDF Controls'))
    24932492    numbDen = G2pwd.GetNumDensity(PDFdata['ElList'],PDFdata['Form Vol'])
     
    25042503        ContourY = []
    25052504        Nseq = 0
     2505    else:
     2506        XYlist = []
    25062507    for N,Pattern in enumerate(PlotList):
    25072508        xye = Pattern[1]
     
    25202521            X = xye[0]+Page.Offset[0]*.005*N
    25212522            Y = xye[1]+Page.Offset[1]*.01*N
    2522             if G2frame.Legend:
    2523                 Plot.plot(X,Y,colors[N%6],picker=False,label='Azm:'+Pattern[2].split('=')[1])
    2524             else:
    2525                 Plot.plot(X,Y,colors[N%6],picker=False)
    2526             if plotType == 'G(R)':
    2527                 Xb = [0.,2.5]
    2528                 Yb = [0.,-10.*np.pi*numbDen]
    2529                 Plot.plot(Xb,Yb,color='k',dashes=(5,5))
    2530             elif plotType == 'F(Q)':
    2531                 Plot.axhline(0.,color=wx.BLACK)
    2532             elif plotType == 'S(Q)':
    2533                 Plot.axhline(1.,color=wx.BLACK)
     2523            XYlist.append(list(zip(X,Y)))
     2524#            if G2frame.Legend:
     2525#                Plot.plot(X,Y,colors[N%6],picker=False,label='Azm:'+Pattern[2].split('=')[1])
     2526#            else:
     2527#                Plot.plot(X,Y,colors[N%6],picker=False)
    25342528    if G2frame.Contour and len(Pattern)>1:
    25352529        acolor = mpl.cm.get_cmap(G2frame.ContourColor)
     
    25372531            extent=[ContourX[0],ContourX[-1],ContourY[0],ContourY[-1]],aspect='auto',origin='lower')
    25382532        Page.figure.colorbar(Img)
    2539     elif G2frame.Legend:
    2540         Plot.legend(loc='best')
     2533    else:
     2534        XYlist = np.array(XYlist)
     2535        Xmin = np.amin(XYlist.T[0])
     2536        Xmax = np.amax(XYlist.T[0])
     2537        dx = 0.02*(Xmax-Xmin)
     2538        Ymin = np.amin(XYlist.T[1])
     2539        Ymax = np.amax(XYlist.T[1])
     2540        dy = 0.02*(Ymax-Ymin)
     2541        Plot.set_xlim(Xmin-dx,Xmax+dx)
     2542        Plot.set_ylim(Ymin-dy,Ymax+dy)
     2543        acolor = mpl.cm.get_cmap(G2frame.ContourColor)
     2544        if XYlist.shape[0]>1:           
     2545            lines = mplC.LineCollection(XYlist,cmap=acolor)
     2546        else:
     2547            lines = mplC.LineCollection(XYlist,color=colors[0])
     2548        lines.set_array(np.arange(XYlist.shape[0]))
     2549        Plot.add_collection(lines)
     2550        if plotType == 'G(R)':
     2551            Xb = [0.,2.5]
     2552            Yb = [0.,-10.*np.pi*numbDen]
     2553            Plot.plot(Xb,Yb,color='k',dashes=(5,5))
     2554        elif plotType == 'F(Q)':
     2555            Plot.axhline(0.,color=wx.BLACK)
     2556        elif plotType == 'S(Q)':
     2557            Plot.axhline(1.,color=wx.BLACK)
     2558        if XYlist.shape[0] > 1:
     2559            axcb = Page.figure.colorbar(lines)
     2560            axcb.set_label('Run number')
     2561       
     2562#    elif G2frame.Legend:
     2563#        Plot.legend(loc='best')
    25412564    if not newPlot:
    25422565        Page.toolbar.push_current()
Note: See TracChangeset for help on using the changeset viewer.