Changeset 5318 for trunk/GSASIIplot.py
- Timestamp:
- Aug 2, 2022 3:50:22 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/GSASIIplot.py ¶
r5312 r5318 1140 1140 RefreshPlot() 1141 1141 dlg.ShowModal() 1142 #### #PlotSngl ################################################################1142 #### PlotSngl ################################################################ 1143 1143 def PlotSngl(G2frame,newPlot=False,Data=None,hklRef=None,Title=''): 1144 1144 '''Structure factor plotting package - displays zone of reflections as rings proportional … … 1373 1373 Page.canvas.draw() 1374 1374 1375 #### #Plot1DSngl ################################################################################1375 #### Plot1DSngl ################################################################################ 1376 1376 def Plot1DSngl(G2frame,newPlot=False,hklRef=None,Super=0,Title=False): 1377 1377 '''1D Structure factor plotting package - displays reflections as sticks proportional … … 1490 1490 Draw() 1491 1491 1492 #### #Plot3DSngl ################################################################################1492 #### Plot3DSngl ################################################################################ 1493 1493 def Plot3DSngl(G2frame,newPlot=False,Data=None,hklRef=None,Title=False): 1494 1494 '''3D Structure factor plotting package - displays reflections as spots proportional … … 1995 1995 # if firstCall: Draw('main') # draw twice the first time that graphics are displayed 1996 1996 1997 #### #PlotPatterns ################################################################################1997 #### PlotPatterns ################################################################################ 1998 1998 def ReplotPattern(G2frame,newPlot,plotType,PatternName=None,PickName=None): 1999 1999 '''This does the same as PlotPatterns except that it expects the information … … 3051 3051 return '_'+string 3052 3052 3053 ###### beginning PlotPatterns execution3053 #### beginning PlotPatterns execution 3054 3054 global exclLines,Page 3055 3055 global DifLine # BHT: probably does not need to be global … … 5097 5097 ax0.legend(legLine,legLbl,loc='best',prop={'size':plotOpt['labelSize']}) 5098 5098 5099 #### #PlotDeltSig #############################################################5099 #### PlotDeltSig ############################################################# 5100 5100 def PlotDeltSig(G2frame,kind,PatternName=None): 5101 5101 'Produces normal probability plot for a powder or single crystal histogram' … … 5177 5177 Page.canvas.draw() 5178 5178 5179 #### #PlotISFG ################################################################5179 #### PlotISFG ################################################################ 5180 5180 def PlotISFG(G2frame,data,newPlot=False,plotType='',peaks=None): 5181 5181 ''' Plotting package for PDF analysis; displays I(Q), S(Q), F(Q) and G(r) as single … … 5363 5363 wx.CallAfter(PlotISFG,G2frame,data,peaks=Peaks,newPlot=False) 5364 5364 5365 ##### PlotISFG continues here ############################################################5365 #### PlotISFG continues here ############################################################ 5366 5366 xylim = [] 5367 5367 new,plotNum,Page,Plot,lim = G2frame.G2plotNB.FindPlotTab(plotType,'mpl') … … 5602 5602 Page.canvas.draw() 5603 5603 5604 #### #PlotCalib ###############################################################5604 #### PlotCalib ############################################################### 5605 5605 def PlotCalib(G2frame,Inst,XY,Sigs,newPlot=False): 5606 5606 '''plot of CW or TOF peak calibration … … 5687 5687 Page.canvas.draw() 5688 5688 5689 #### #PlotXY ##################################################################5689 #### PlotXY ################################################################## 5690 5690 def PlotXY(G2frame,XY,XY2=[],labelX='X',labelY='Y',newPlot=False, 5691 5691 Title='',lines=False,names=[],names2=[],vertLines=[]): … … 5810 5810 5811 5811 5812 #### #PlotXYZ ################################################################################5812 #### PlotXYZ ################################################################################ 5813 5813 def PlotXYZ(G2frame,XY,Z,labelX='X',labelY='Y',newPlot=False,Title='',zrange=None,color=None,buttonHandler=None): 5814 5814 '''simple contour plot of xyz data … … 5935 5935 Page.canvas.draw() 5936 5936 5937 #### #PlotXYZvect ################################################################################5937 #### PlotXYZvect ################################################################################ 5938 5938 def PlotXYZvect(G2frame,X,Y,Z,R,labelX=r'X',labelY=r'Y',labelZ=r'Z',Title='',PlotName=None): 5939 5939 ''' To plot a quiver of quaternion vectors colored by the rotation … … 5981 5981 Page.canvas.draw() 5982 5982 5983 #### #Plot3dXYZ ################################################################################5983 #### Plot3dXYZ ################################################################################ 5984 5984 def Plot3dXYZ(G2frame,nX,nY,Zdat,labelX=r'X',labelY=r'Y',labelZ=r'Z',newPlot=False,Title='',Centro=False): 5985 5985 … … 6034 6034 Page.canvas.draw() 6035 6035 6036 #### #PlotAAProb ################################################################################6036 #### PlotAAProb ################################################################################ 6037 6037 def PlotAAProb(G2frame,resNames,Probs1,Probs2,Title='',thresh=None,pickHandler=None): 6038 6038 'Needs a description' … … 6092 6092 Draw() 6093 6093 6094 #### #PlotStrain ################################################################################6094 #### PlotStrain ################################################################################ 6095 6095 def PlotStrain(G2frame,data,newPlot=False): 6096 6096 '''plot of strain data, used for diagnostic purposes … … 6139 6139 Page.canvas.draw() 6140 6140 6141 #### #PlotBarGraph ################################################################################6141 #### PlotBarGraph ################################################################################ 6142 6142 def PlotBarGraph(G2frame,Xarray,Xname='',Yname='Number',Title='',PlotName=None,ifBinned=False,maxBins=None): 6143 6143 ''' does a vertical bar graph … … 6183 6183 Page.canvas.draw() 6184 6184 6185 #### #PlotNamedFloatBarGraph ################################################################################6185 #### PlotNamedFloatBarGraph ################################################################################ 6186 6186 def PlotNamedFloatHBarGraph(G2frame,Xvals,Ynames,Xlabel='Value',Ylabel='',Title='',PlotName=None): 6187 6187 ''' does a horizintal bar graph … … 6219 6219 Page.canvas.draw() 6220 6220 6221 #### #PlotSASDSizeDist ################################################################################6221 #### PlotSASDSizeDist ################################################################################ 6222 6222 def PlotSASDSizeDist(G2frame): 6223 6223 'Needs a description' … … 6271 6271 Page.canvas.draw() 6272 6272 6273 #### #PlotSASDPairDist ################################################################################6273 #### PlotSASDPairDist ################################################################################ 6274 6274 def PlotSASDPairDist(G2frame): 6275 6275 'Needs a description' … … 6312 6312 Page.canvas.draw() 6313 6313 6314 #### #PlotPowderLines ################################################################################6314 #### PlotPowderLines ################################################################################ 6315 6315 def PlotPowderLines(G2frame): 6316 6316 ''' plotting of powder lines (i.e. no powder pattern) as sticks … … 6617 6617 Page.canvas.draw() 6618 6618 6619 #### #PlotSizeStrainPO ################################################################################6619 #### PlotSizeStrainPO ################################################################################ 6620 6620 def PlotSizeStrainPO(G2frame,data,hist='',Start=False): 6621 6621 '''Plot 3D mustrain/size/preferred orientation figure. In this instance data is for a phase … … 6897 6897 Page.canvas.draw() 6898 6898 6899 #### #PlotTexture ################################################################################6899 #### PlotTexture ################################################################################ 6900 6900 def PlotTexture(G2frame,data,Start=False): 6901 6901 '''Pole figure, inverse pole figure plotting. … … 7088 7088 Page.canvas.draw() 7089 7089 7090 #### #Plot Modulation ################################################################################7090 #### Plot Modulation ################################################################################ 7091 7091 def ModulationPlot(G2frame,data,atom,ax,off=0): 7092 7092 'Needs a description' … … 7201 7201 Page.canvas.draw() 7202 7202 7203 #### #PlotCovariance ################################################################################7203 #### PlotCovariance ################################################################################ 7204 7204 def PlotCovariance(G2frame,Data): 7205 7205 '''Plots the covariance matrix. Also shows values for parameters … … 7314 7314 Page.canvas.draw() 7315 7315 7316 #### #PlotTorsion ################################################################################7316 #### PlotTorsion ################################################################################ 7317 7317 def PlotTorsion(G2frame,phaseName,Torsion,TorName,Names=[],Angles=[],Coeff=[]): 7318 7318 'needs a doc string' … … 7373 7373 Page.canvas.draw() 7374 7374 7375 #### #PlotRama ################################################################################7375 #### PlotRama ################################################################################ 7376 7376 def PlotRama(G2frame,phaseName,Rama,RamaName,Names=[],PhiPsi=[],Coeff=[]): 7377 7377 'needs a doc string' … … 7466 7466 7467 7467 7468 #### #PlotSeq ################################################################################7468 #### PlotSeq ################################################################################ 7469 7469 def PlotSelectedSequence(G2frame,ColumnList,TableGet,SelectX,fitnum=None,fitvals=None): 7470 7470 '''Plot a result from a sequential refinement … … 7599 7599 SeqDraw() 7600 7600 7601 #### #PlotExposedImage & PlotImage ################################################################################7601 #### PlotExposedImage & PlotImage ################################################################################ 7602 7602 def PlotExposedImage(G2frame,newPlot=False,event=None): 7603 7603 '''General access module for 2D image plotting … … 8479 8479 # try: 8480 8480 Plot1,Plot = Page.figure.subplots(1,2,gridspec_kw=GS_kw) 8481 # except AttributeError: # figure.Figure.subplots added in MPL 2.28482 # Plot1,Plot = MPLsubplots(Page.figure, 1,2, gridspec_kw=GS_kw)8483 8481 Plot1.set_title('Line scan at azm= %6.1f'%Data['linescan'][1]) 8484 8482 Plot1.set_xlabel(r'$\mathsf{2\Theta}$',fontsize=12) … … 8761 8759 wx.EndBusyCursor() 8762 8760 8763 #### #PlotIntegration ################################################################################8761 #### PlotIntegration ################################################################################ 8764 8762 def PlotIntegration(G2frame,newPlot=False,event=None): 8765 8763 '''Plot of 2D image after image integration with 2-theta and azimuth as coordinates … … 8813 8811 Page.canvas.draw() 8814 8812 8815 #### #PlotRawImage ################################################################################8813 #### PlotRawImage ################################################################################ 8816 8814 def PlotRawImage(G2frame,image,label,newPlot=False): 8817 8815 '''Plot an image without axes etc. … … 8824 8822 Page.canvas.draw() 8825 8823 8826 #### #PlotTRImage ################################################################################8824 #### PlotTRImage ################################################################################ 8827 8825 def PlotTRImage(G2frame,tax,tay,taz,newPlot=False): 8828 8826 '''a test plot routine - not normally used … … 8888 8886 Page.canvas.draw() 8889 8887 8890 #### #PlotStructure ################################################################################8888 #### PlotStructure ################################################################################ 8891 8889 def PlotStructure(G2frame,data,firstCall=False,pageCallback=None): 8892 8890 '''Crystal structure plotting package. Can show structures as balls, sticks, lines, … … 11567 11565 Page.canvas.SetCurrent(Page.context) 11568 11566 wx.CallAfter(Draw,'main') 11569 11567 11568 #### Plot Cluster Analysis #################################################### 11569 11570 def PlotDendogram(G2frame,CLuDict,CLuZ,newPlot=True): 11571 11572 import scipy.cluster.hierarchy as SCH 11573 global Plot 11574 def OnMotion(event): 11575 xpos = event.xdata 11576 if xpos: #avoid out of frame mouse position 11577 ypos = event.ydata 11578 SetCursor(Page) 11579 try: 11580 G2frame.G2plotNB.status.SetStatusText('X =%9.3f %s =%9.3g'%(xpos,Title,ypos),1) 11581 except TypeError: 11582 G2frame.G2plotNB.status.SetStatusText('Select '+Title+' pattern first',1) 11583 xylim = [] 11584 Title = 'Cluster dendogram' 11585 new,plotNum,Page,Plot,lim = G2frame.G2plotNB.FindPlotTab(Title,'mpl') 11586 if not new: 11587 if not newPlot: 11588 xylim = copy.copy(lim) 11589 else: 11590 newPlot = True 11591 Page.canvas.mpl_connect('motion_notify_event', OnMotion) 11592 11593 Page.Choice = None 11594 G2frame.G2plotNB.status.DestroyChildren() #get rid of special stuff on status bar 11595 Plot.set_title('%s %s'%(CLuDict['LinkMethod'],Title)) 11596 Plot.set_xlabel(r''+CLuDict['Method']+' distance',fontsize=14) 11597 Plot.set_ylabel(r''+'data set no.',fontsize=14) 11598 11599 CLR = SCH.dendrogram(CLuZ,orientation='right',ax=Plot) 11600 11601 if not newPlot: 11602 Page.toolbar.push_current() 11603 Plot.set_xlim(xylim[0]) 11604 Plot.set_ylim(xylim[1]) 11605 Page.toolbar.push_current() 11606 Page.ToolBarDraw() 11607 else: 11608 Page.canvas.draw() 11609 11610 def PlotClusterXYZ(G2frame,YM,XYZ,CLuDict,Title='',PlotName=None): 11611 ''' To plot cluster vectors 11612 :param wx.Frame G2frame: The main GSAS-II tree "window" 11613 :param array whitMat: whitened data matrix 11614 :param array codebook: array of cluster centers 11615 11616 :param str labelX,labelY,labelZ: labels for X,Y,Z-axes 11617 :param str Title: plot title 11618 :param str PlotName: plot tab name 11619 ''' 11620 import scipy.cluster.hierarchy as SCH 11621 from mpl_toolkits.axes_grid1.inset_locator import inset_axes 11622 def OnMotion(event): 11623 11624 if event.xdata and event.ydata: 11625 G2frame.G2plotNB.status.SetStatusText('x=%.3f y=%.3f'%(event.xdata,event.ydata),1) 11626 11627 def OnPick(event): 11628 ind = event.ind 11629 print(CLuDict['Files'][ind[0]]) 11630 11631 Colors = ['xkcd:blue','xkcd:red','xkcd:green','xkcd:cyan','xkcd:magenta','xkcd:black', 11632 'xkcd:pink','xkcd:brown','xkcd:teal','xkcd:orange','xkcd:grey','xkcd:violet',] 11633 G2frame.G2plotNB.Delete(PlotName) #A cluge: to avoid AccessExceptions on replot 11634 new,plotNum,Page,Plot,lim = G2frame.G2plotNB.FindPlotTab(PlotName,'mpl') 11635 Plot.set_visible(False) #hide old plot frame, will get replaced below 11636 if new: 11637 Page.canvas.mpl_connect('motion_notify_event', OnMotion) 11638 Page.canvas.mpl_connect('pick_event', OnPick) 11639 G2frame.G2plotNB.status.SetStatusText('',1) 11640 Page.Choice = None 11641 np.seterr(all='ignore') 11642 11643 Imin = np.min(YM) 11644 Imax = np.max(YM) 11645 if CLuDict['CLuZ'] is not None: 11646 gs = mpl.gridspec.GridSpec(2,2,figure=Page.figure) 11647 ax1 = Page.figure.add_subplot(gs[0,0]) 11648 ax2 = Page.figure.add_subplot(gs[1,1],projection='3d') 11649 ax3 = Page.figure.add_subplot(gs[0,1]) 11650 ax4 = Page.figure.add_subplot(gs[1,0]) 11651 else: 11652 ax1 = Page.figure.add_subplot(211) 11653 ax2 = Page.figure.add_subplot(212,projection='3d') 11654 Page.figure.tight_layout() 11655 Page.ImgObj = ax1.imshow(YM,interpolation='nearest',vmin=Imin,vmax=Imax,origin='lower') 11656 cax = inset_axes(ax1,width="5%",height="100%",loc='lower left',bbox_to_anchor=(1.05, 0., 1, 1), 11657 bbox_transform=ax1.transAxes,borderpad=0) 11658 Page.figure.colorbar(Page.ImgObj, cax=cax) 11659 if CLuDict['codes'] is not None: 11660 ax2.scatter(XYZ[0],XYZ[1],XYZ[2],color=[Colors[code] for code in CLuDict['codes']],picker=True) 11661 else: 11662 ax2.scatter(XYZ[0],XYZ[1],XYZ[2],color=Colors[0],picker=True) 11663 ax1.set_title(Title+' distances') 11664 ax1.set_xlabel('Data set',fontsize=12) 11665 ax1.set_ylabel('Data set',fontsize=12) 11666 ax2.set_xlabel('PCA axis-1',fontsize=12) 11667 ax2.set_ylabel('PCA axis-2',fontsize=12) 11668 ax2.set_zlabel('PCA axis-3',fontsize=12) 11669 if CLuDict['CLuZ'] is not None: 11670 CLR = SCH.dendrogram(CLuDict['CLuZ'],orientation='right',ax=ax3) 11671 ax3.set_title('%s %s'%(CLuDict['LinkMethod'],Title)) 11672 ax3.set_xlabel(r''+'data set no.',fontsize=12) 11673 ax3.set_ylabel(r''+CLuDict['Method']+' distance',fontsize=12) 11674 ax4.plot(100.*CLuDict['PCA'][:10]/np.sum(CLuDict['PCA'])) 11675 ax4.set_xlabel('PCA index',fontsize=12) 11676 ax4.set_ylabel('% of total',fontsize=12) 11677 Page.canvas.draw() 11678
Note: See TracChangeset
for help on using the changeset viewer.