Changeset 3320 for trunk/GSASIIplot.py
- Timestamp:
- Mar 23, 2018 1:41:13 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIplot.py
r3316 r3320 425 425 new = False 426 426 plotNum,Page = self.GetTabIndex(label) 427 if Type == 'mpl' or Type == '3d': 427 if Type == 'mpl' or Type == '3d': 428 Axes = Page.figure.get_axes() 428 429 Plot = Page.figure.gca() #get previous plot 429 limits = Plot.get_xlim(),Plot.get_ylim() # save previous limits 430 # print 'Plot limits:',limits 430 limits = [Plot.get_xlim(),Plot.get_ylim()] # save previous limits 431 if len(Axes)>1: 432 limits[1] = Axes[1].get_ylim() 433 # print('Axes[1]',Axes[1].get_ylim()) 434 # print ('Plot limits:',limits,Axes) 431 435 if newImage: 432 436 Page.figure.clf() … … 581 585 deleted = False 582 586 Toolbar.__init__(self,plotCanvas) 583 G2path = os.path.split(os.path.abspath(__file__))[0]587 # G2path = os.path.split(os.path.abspath(__file__))[0] 584 588 self.updateActions = None # defines a call to be made as part of plot updates 585 589 self.plotCanvas = plotCanvas … … 599 603 fil = ''.join([i[0].lower() for i in direc.split()]+['arrow.ico']) 600 604 self.arrows[direc] = self.AddToolBarTool(sprfx+direc,prfx+direc,fil,self.OnArrow) 601 G2path = os.path.split(os.path.abspath(__file__))[0]605 # G2path = os.path.split(os.path.abspath(__file__))[0] 602 606 if publish: 603 607 self.AddToolBarTool('Publish plot','Create publishable version of plot','publish.ico',publish) … … 1494 1498 return 1495 1499 newPlot = False 1496 if event.key == 'w' :1500 if event.key == 'w' and not G2frame.plotStyle['qPlot'] and not G2frame.plotStyle['dPlot']: #can't do weight plots when x-axis is different 1497 1501 G2frame.Weight = not G2frame.Weight 1498 1502 if not G2frame.Weight and 'PWDR' in plottype: … … 1601 1605 G2frame.plotStyle['qPlot'] = not G2frame.plotStyle['qPlot'] 1602 1606 if G2frame.plotStyle['qPlot']: 1607 G2frame.Weight = False 1603 1608 G2frame.Contour = False 1604 1609 G2frame.plotStyle['dPlot'] = False … … 1609 1614 if G2frame.plotStyle['dPlot']: 1610 1615 G2frame.Contour = False 1616 G2frame.Weight = False 1611 1617 G2frame.plotStyle['qPlot'] = False 1612 1618 newPlot = True … … 2174 2180 if msg: msg += '\n' 2175 2181 msg += " * only when the intensity scale is linear (not log or sqrt)" 2182 if G2frame.Weight: 2183 if msg: msg += '\n' 2184 msg += " * only when weight plot is set to no weight plot" 2176 2185 if msg: 2177 2186 msg = 'Publication export is only available under limited plot settings\n'+msg … … 2187 2196 else: 2188 2197 publish = None 2189 new,plotNum,Page,Plot,limits = G2frame.G2plotNB.FindPlotTab('Powder Patterns','mpl', 2190 publish=publish) 2198 new,plotNum,Page,Plot,limits = G2frame.G2plotNB.FindPlotTab('Powder Patterns','mpl',publish=publish) 2191 2199 if not new: 2192 2200 G2frame.xylim = limits … … 2236 2244 Page.Choice = (' key press','n: log(I) off', 2237 2245 'c: contour on','q: toggle q plot','t: toggle d-spacing plot', 2238 'm: toggle multidata plot',' w: toggle divide by sig','+: toggle selection')2246 'm: toggle multidata plot','+: toggle selection') 2239 2247 else: 2240 2248 Page.Choice = (' key press','n: log(I) off', 2241 2249 'd: offset down','l: offset left','r: offset right','u: offset up','o: reset offset', 2242 2250 'c: contour on','q: toggle q plot','t: toggle d-spacing plot','f: select data', 2243 'm: toggle multidata plot',' w: toggle divide by sig','+: toggle selection')2251 'm: toggle multidata plot','+: toggle selection') 2244 2252 elif plottype in ['SASD','REFD']: 2245 2253 if G2frame.SinglePlot: … … 2256 2264 'b: toggle subtract background','n: log(I) on','s: toggle sqrt plot','c: contour on', 2257 2265 'q: toggle q plot','t: toggle d-spacing plot','m: toggle multidata plot', 2258 'w: toggle divide by sig','+: no selection')2266 'w: toggle (Io-Ic)/sig plot','+: no selection') 2259 2267 else: 2260 2268 Page.Choice = (' key press','l: offset left','r: offset right','d/D: offset down/10x','u/U: offset up/10x','o: reset offset', 2261 2269 'b: toggle subtract background','n: log(I) on','c: contour on','q: toggle q plot','t: toggle d-spacing plot', 2262 'm: toggle multidata plot',' f: select data','s: color scheme','w: toggle divide by sig','+: no selection')2270 'm: toggle multidata plot','w: toggle (Io-Ic)/sig plot','f: select data','s: color scheme','+: no selection') 2263 2271 elif plottype in ['SASD','REFD']: 2264 2272 if G2frame.SinglePlot: … … 2336 2344 #Plot.set_title(Title) # show title only w/o magnification 2337 2345 if G2frame.plotStyle['qPlot'] or plottype in ['SASD','REFD'] and not G2frame.Contour: 2338 Plot.set_xlabel(r'$Q, \AA^{-1}$',fontsize=16)2346 xLabel = r'$Q, \AA^{-1}$' 2339 2347 elif G2frame.plotStyle['dPlot'] and 'PWDR' in plottype and not G2frame.Contour: 2340 Plot.set_xlabel(r'$d, \AA$',fontsize=16)2348 xLabel = r'$d, \AA$' 2341 2349 else: 2342 if 'C' in ParmList[0]['Type'][0]: 2343 Plot.set_xlabel(r'$\mathsf{2\theta}$',fontsize=16)2350 if 'C' in ParmList[0]['Type'][0]: 2351 xLabel = r'$\mathsf{2\theta}$' 2344 2352 else: 2345 2353 if G2frame.Contour: 2346 Plot.set_xlabel(r'Channel no.',fontsize=16)2354 xLabel = r'Channel no.' 2347 2355 else: 2348 Plot.set_xlabel(r'$TOF, \mathsf{\mu}$s',fontsize=16)2356 xLabel = r'$TOF, \mathsf{\mu}$s' 2349 2357 if G2frame.Weight: 2358 Plot.tick_params('x',length=0,labelbottom=False) 2359 Plot.tick_params('y',length=0,labelleft=False) 2360 GS_kw = {'height_ratios':[4, 1],} 2361 Plot,Plot1 = Page.figure.subplots(2,1,sharex=True,gridspec_kw=GS_kw) 2362 Plot1.set_ylabel(r'$\mathsf{\Delta(I)/\sigma(I)}$',fontsize=16) 2363 Plot1.set_xlabel(xLabel,fontsize=16) 2364 Page.figure.subplots_adjust(left=16/100.,bottom=16/150., 2365 right=.98,top=1.-16/200.,hspace=0) 2366 else: 2367 Plot.set_xlabel(xLabel,fontsize=16) 2368 if 'C' in ParmList[0]['Type'][0]: 2350 2369 if 'PWDR' in plottype: 2351 Plot.set_ylabel(r'$\mathsf{I/\sigma(I)}$',fontsize=16)2352 elif plottype in ['SASD','REFD']:2353 Plot.set_ylabel(r'$\mathsf{\Delta(I)/\sigma(I)}$',fontsize=16)2354 else:2355 if 'C' in ParmList[0]['Type'][0]:2356 if 'PWDR' in plottype:2357 if G2frame.plotStyle['sqrtPlot']:2358 Plot.set_ylabel(r'$\sqrt{Intensity}$',fontsize=16)2359 else:2360 Plot.set_ylabel(r'$Intensity$',fontsize=16)2361 elif plottype == 'SASD':2362 if G2frame.plotStyle['sqPlot']:2363 Plot.set_ylabel(r'$S(Q)=I*Q^{4}$',fontsize=16)2364 else:2365 Plot.set_ylabel(r'$Intensity,\ cm^{-1}$',fontsize=16)2366 elif plottype == 'REFD':2367 if G2frame.plotStyle['sqPlot']:2368 Plot.set_ylabel(r'$S(Q)=R*Q^{4}$',fontsize=16)2369 else:2370 Plot.set_ylabel(r'$Reflectivity$',fontsize=16)2371 else: #neutron TOF2372 2370 if G2frame.plotStyle['sqrtPlot']: 2373 Plot.set_ylabel(r'$\sqrt{ Normalized\ intensity}$',fontsize=16)2371 Plot.set_ylabel(r'$\sqrt{Intensity}$',fontsize=16) 2374 2372 else: 2375 Plot.set_ylabel(r'$Normalized\ intensity$',fontsize=16) 2373 Plot.set_ylabel(r'$Intensity$',fontsize=16) 2374 elif plottype == 'SASD': 2375 if G2frame.plotStyle['sqPlot']: 2376 Plot.set_ylabel(r'$S(Q)=I*Q^{4}$',fontsize=16) 2377 else: 2378 Plot.set_ylabel(r'$Intensity,\ cm^{-1}$',fontsize=16) 2379 elif plottype == 'REFD': 2380 if G2frame.plotStyle['sqPlot']: 2381 Plot.set_ylabel(r'$S(Q)=R*Q^{4}$',fontsize=16) 2382 else: 2383 Plot.set_ylabel(r'$Reflectivity$',fontsize=16) 2384 else: #neutron TOF 2385 if G2frame.plotStyle['sqrtPlot']: 2386 Plot.set_ylabel(r'$\sqrt{Normalized\ intensity}$',fontsize=16) 2387 else: 2388 Plot.set_ylabel(r'$Normalized\ intensity$',fontsize=16) 2376 2389 mpl.rcParams['image.cmap'] = G2frame.ContourColor 2377 2390 mcolors = mpl.cm.ScalarMappable() #wants only default as defined in previous line!! … … 2555 2568 else: 2556 2569 Plot.set_ylim(bottom=np.min(np.trim_zeros(YB))/2.,top=np.max(Y)*2.) 2570 if G2frame.Weight: 2571 Ibeg = np.searchsorted(X,limits[1][0]) 2572 Ifin = np.searchsorted(X,limits[1][1]) 2573 Plot1.set_yscale("linear") 2574 DZ = (xye[1]-xye[3])*np.sqrt(xye[2]) 2575 DifLine = Plot1.plot(X[Ibeg:Ifin],DZ[Ibeg:Ifin],colors[3],picker=1.,label='_diff') #(Io-Ic)/sig(Io) 2576 Plot1.axhline(0.,color='k') 2577 Plot1.set_ylim(bottom=np.min(DZ[Ibeg:Ifin])*1.2,top=np.max(DZ[Ibeg:Ifin])*1.2) 2557 2578 if G2frame.logPlot: 2558 2579 if 'PWDR' in plottype: … … 2565 2586 Ibeg = np.searchsorted(X,limits[1][0]) 2566 2587 Ifin = np.searchsorted(X,limits[1][1]) 2567 if G2frame.Weight: 2568 Plot.set_yscale("linear") 2569 DS = (YB-ZB)*np.sqrt(xye[2]) 2570 Plot.plot(X[Ibeg:Ifin],DS[Ibeg:Ifin],colors[3],picker=False,label='_diff') 2571 Plot.axhline(0.,color='k') 2572 Plot.set_ylim(bottom=np.min(DS[Ibeg:Ifin])*1.2,top=np.max(DS[Ibeg:Ifin])*1.2) 2588 Plot.set_yscale("log",nonposy='mask') 2589 if G2frame.ErrorBars: 2590 if G2frame.plotStyle['sqPlot']: 2591 Plot.errorbar(X,YB,yerr=X**4*Sample['Scale'][0]*np.sqrt(1./(Pattern[0]['wtFactor']*xye[2])), 2592 ecolor=colors[0],picker=3.,clip_on=Clip_on) 2593 else: 2594 Plot.errorbar(X,YB,yerr=Sample['Scale'][0]*np.sqrt(1./(Pattern[0]['wtFactor']*xye[2])), 2595 ecolor=colors[0],picker=3.,clip_on=Clip_on,label='_obs') 2573 2596 else: 2574 Plot.set_yscale("log",nonposy='mask') 2575 if G2frame.ErrorBars: 2576 if G2frame.plotStyle['sqPlot']: 2577 Plot.errorbar(X,YB,yerr=X**4*Sample['Scale'][0]*np.sqrt(1./(Pattern[0]['wtFactor']*xye[2])), 2578 ecolor=colors[0],picker=3.,clip_on=Clip_on) 2579 else: 2580 Plot.errorbar(X,YB,yerr=Sample['Scale'][0]*np.sqrt(1./(Pattern[0]['wtFactor']*xye[2])), 2581 ecolor=colors[0],picker=3.,clip_on=Clip_on,label='_obs') 2582 else: 2583 Plot.plot(X,YB,colors[0]+pP,picker=3.,clip_on=Clip_on,label='_obs') 2584 Plot.plot(X,W,colors[2],picker=False,label='_bkg') #const. background 2585 Plot.plot(X,ZB,colors[1],picker=False,label='_calc') 2586 elif G2frame.Weight and 'PWDR' in plottype: 2587 DY = xye[1]*np.sqrt(xye[2]) 2588 Ymax = max(DY) 2589 DZ = xye[3]*np.sqrt(xye[2]) 2590 DS = xye[5]*np.sqrt(xye[2])-Ymax*Pattern[0]['delOffset'] 2591 ObsLine = Plot.plot(X,DY,colors[0]+pP,picker=3.,clip_on=Clip_on,label='_obs') #Io/sig(Io) 2592 Plot.plot(X,DZ,colors[1],picker=False,label='_calc') #Ic/sig(Io) 2593 DifLine = Plot.plot(X,DS,colors[3],picker=1.,label='_diff') #(Io-Ic)/sig(Io) 2594 Plot.axhline(0.,color='k') 2597 Plot.plot(X,YB,colors[0]+pP,picker=3.,clip_on=Clip_on,label='_obs') 2598 Plot.plot(X,W,colors[2],picker=False,label='_bkg') #const. background 2599 Plot.plot(X,ZB,colors[1],picker=False,label='_calc') 2595 2600 else: 2596 2601 if G2frame.SubBack: … … 2608 2613 Plot.plot(X,YB,colors[0]+pP,picker=3.,clip_on=Clip_on,label='_obs') 2609 2614 Plot.plot(X,ZB,colors[1],picker=False,label='_calc') 2610 if 'PWDR' in plottype: 2615 if 'PWDR' in plottype: 2611 2616 Plot.plot(X,W,colors[2],picker=False,label='_bkg') #Ib 2612 DifLine = Plot.plot(X,D,colors[3],picker=1.,label='_diff') #Io-Ic2617 if not G2frame.Weight: DifLine = Plot.plot(X,D,colors[3],picker=1.,label='_diff') #Io-Ic 2613 2618 Plot.axhline(0.,color='k',label='_zero') 2614 2619 Page.SetToolTipString('') … … 2920 2925 ''' 2921 2926 hcfigure = mpl.figure.Figure(dpi=plotOpt['dpi'],figsize=(plotOpt['width'],plotOpt['height'])) 2922 hccanvas = hcCanvas(hcfigure)2927 # hccanvas = hcCanvas(hcfigure) 2923 2928 CopyRietveldPlot(G2frame,Pattern,Plot,Page,hcfigure) 2924 2929 longFormatName,typ = plotOpt['format'].split(',')
Note: See TracChangeset
for help on using the changeset viewer.