Changeset 4265 for trunk/GSASIIplot.py
- Timestamp:
- Jan 25, 2020 12:47:07 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIplot.py
r4236 r4265 5109 5109 5110 5110 ################################################################################ 5111 ##### Plot3dXYZ 5112 ################################################################################ 5113 5114 def Plot3dXYZ(G2frame,nX,nY,Zdat,labelX='X',labelY='Y',labelZ='Z',newPlot=False,Title=''): 5115 5116 def OnMotion(event): 5117 xpos = event.xdata 5118 if xpos: #avoid out of frame mouse position 5119 ypos = event.ydata 5120 G2frame.G2plotNB.status.SetStatusText('X =%.3f Y =%.4f'%(xpos,ypos),1) 5121 5122 def OnKeyPress(event): 5123 if event.key == 'g': 5124 mpl.rcParams['axes.grid'] = not mpl.rcParams['axes.grid'] 5125 5126 new,plotNum,Page,Plot,lim = G2frame.G2plotNB.FindPlotTab(Title,'3d') 5127 if not new: 5128 if not Page.IsShown(): 5129 Page.Show() 5130 else: 5131 Page.canvas.mpl_connect('motion_notify_event', OnMotion) 5132 Page.Choice = None 5133 G2frame.G2plotNB.status.SetStatusText('',1) 5134 Zmul = Zdat.reshape((nX,-1)).T 5135 PHI = np.linspace(0.,360.,int(nY),True) 5136 PSI = np.linspace(0.,180.,int(nX),True) 5137 X = Zmul*np.outer(npcosd(PHI),npsind(PSI))/2. 5138 Y = Zmul*np.outer(npsind(PHI),npsind(PSI))/2. 5139 Z = Zmul*np.outer(np.ones(np.size(PHI)),npcosd(PSI))/2. 5140 5141 if np.any(X) and np.any(Y) and np.any(Z): 5142 np.seterr(all='ignore') 5143 Plot.plot_surface(X,Y,Z,rstride=1,cstride=1,color='g',linewidth=1) 5144 xyzlim = np.array([Plot.get_xlim3d(),Plot.get_ylim3d(),Plot.get_zlim3d()]).T 5145 XYZlim = [min(xyzlim[0]),max(xyzlim[1])] 5146 Plot.contour(X,Y,Z,10,zdir='x',offset=XYZlim[0]) 5147 Plot.contour(X,Y,Z,10,zdir='y',offset=XYZlim[1]) 5148 Plot.contour(X,Y,Z,10,zdir='z',offset=XYZlim[0]) 5149 Plot.set_xlim3d(XYZlim) 5150 Plot.set_ylim3d(XYZlim) 5151 Plot.set_zlim3d(XYZlim) 5152 try: 5153 Plot.set_aspect('equal') 5154 except: #broken in mpl 3.1.1; worked in mpl 3.0.3 5155 pass 5156 Plot.set_title(Title) 5157 Plot.set_xlabel(labelX) 5158 Plot.set_ylabel(labelY) 5159 Plot.set_zlabel(labelZ) 5160 Page.canvas.draw() 5161 5162 ################################################################################ 5111 5163 ##### PlotHist 5112 5164 ################################################################################
Note: See TracChangeset
for help on using the changeset viewer.