Changeset 2634 for trunk/GSASIIplot.py
- Timestamp:
- Jan 16, 2017 4:41:14 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIplot.py
r2618 r2634 2348 2348 or multiple plots with waterfall and contour plots as options 2349 2349 ''' 2350 import matplotlib.collections as mplC 2350 2351 if not plotType: 2351 2352 plotType = G2frame.G2plotNB.plotList[G2frame.G2plotNB.nb.GetSelection()] … … 2395 2396 newPlot = True 2396 2397 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] 2407 2404 else: 2408 G2frame.SinglePlot = not G2frame.SinglePlot 2405 G2frame.ContourColor = 'Paired' 2406 dlg.Destroy() 2409 2407 elif event.key == 'i': #for smoothing contour plot 2410 2408 choice = ['nearest','bilinear','bicubic','spline16','spline36','hanning', … … 2454 2452 Page.Choice = (' key press','l: offset left','r: offset right','d: offset down','u: offset up', 2455 2453 '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' ) 2457 2455 Page.keyPress = OnPlotKeyPress 2458 2456 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']2468 2457 name = G2frame.PatternTree.GetItemText(PatternId)[4:] 2469 2458 Pattern = [] … … 2490 2479 Pattern.append(item) 2491 2480 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'] 2492 2491 PDFdata = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'PDF Controls')) 2493 2492 numbDen = G2pwd.GetNumDensity(PDFdata['ElList'],PDFdata['Form Vol']) … … 2504 2503 ContourY = [] 2505 2504 Nseq = 0 2505 else: 2506 XYlist = [] 2506 2507 for N,Pattern in enumerate(PlotList): 2507 2508 xye = Pattern[1] … … 2520 2521 X = xye[0]+Page.Offset[0]*.005*N 2521 2522 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) 2534 2528 if G2frame.Contour and len(Pattern)>1: 2535 2529 acolor = mpl.cm.get_cmap(G2frame.ContourColor) … … 2537 2531 extent=[ContourX[0],ContourX[-1],ContourY[0],ContourY[-1]],aspect='auto',origin='lower') 2538 2532 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') 2541 2564 if not newPlot: 2542 2565 Page.toolbar.push_current()
Note: See TracChangeset
for help on using the changeset viewer.