Changeset 2187 for trunk/GSASIIplot.py
- Timestamp:
- Mar 31, 2016 3:17:43 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIplot.py
r2183 r2187 2397 2397 '''simple contour plot of xyz data, used for diagnostic purposes 2398 2398 ''' 2399 def OnKeyPress(event): 2400 if event.key == 'u': 2401 G2frame.Cmax = min(1.0,G2frame.Cmax*1.2) 2402 elif event.key == 'd': 2403 G2frame.Cmax = max(0.0,G2frame.Cmax*0.8) 2404 elif event.key == 'o': 2405 G2frame.Cmax = 1.0 2406 2407 elif event.key == 'i': 2408 choice = ['nearest','bilinear','bicubic','spline16','spline36','hanning', 2409 'hamming','hermite','kaiser','quadric','catrom','gaussian','bessel', 2410 'mitchell','sinc','lanczos'] 2411 dlg = wx.SingleChoiceDialog(G2frame,'Select','Interpolation',choice) 2412 if dlg.ShowModal() == wx.ID_OK: 2413 sel = dlg.GetSelection() 2414 G2frame.Interpolate = choice[sel] 2415 else: 2416 G2frame.Interpolate = 'nearest' 2417 dlg.Destroy() 2418 2419 elif event.key == 's': 2420 choice = [m for m in mpl.cm.datad.keys() if not m.endswith("_r")] 2421 choice.sort() 2422 dlg = wx.SingleChoiceDialog(G2frame,'Select','Color scheme',choice) 2423 if dlg.ShowModal() == wx.ID_OK: 2424 sel = dlg.GetSelection() 2425 G2frame.ContourColor = choice[sel] 2426 else: 2427 G2frame.ContourColor = 'Paired' 2428 dlg.Destroy() 2429 wx.CallAfter(PlotXYZ,G2frame,XY,Z,labelX,labelY,False,Title) 2430 2399 2431 def OnMotion(event): 2400 2432 xpos = event.xdata 2401 if xpos: #avoid out of frame mouse position2433 if Xmin<xpos<Xmax: #avoid out of frame mouse position 2402 2434 ypos = event.ydata 2403 Page.canvas.SetCursor(wx.CROSS_CURSOR) 2404 ix = int(Nxy[0]*(xpos-Xmin)+0.5) 2405 iy = int(Nxy[1]*(ypos-Ymin)+0.5) 2406 try: 2407 G2frame.G2plotNB.status.SetStatusText('%s =%9.3f %s =%9.3f val =%9.3f'% \ 2408 (labelX,xpos,labelY,ypos,Z[ix,iy]),1) 2409 except TypeError: 2410 G2frame.G2plotNB.status.SetStatusText('Select '+Title+' pattern first',1) 2411 2435 if Ymin<ypos<Ymax: 2436 Xwd = Xmax-Xmin 2437 Ywd = Ymax-Ymin 2438 Page.canvas.SetCursor(wx.CROSS_CURSOR) 2439 ix = int(Nxy[0]*(xpos-Xmin)/Xwd) 2440 iy = int(Nxy[1]*(ypos-Ymin)/Ywd) 2441 try: 2442 G2frame.G2plotNB.status.SetStatusText('%s =%9.3f %s =%9.3f val =%9.3f'% \ 2443 (labelX,xpos,labelY,ypos,Z[ix,iy]),1) 2444 except TypeError: 2445 G2frame.G2plotNB.status.SetStatusText('Select '+Title+' pattern first',1) 2446 2412 2447 try: 2413 2448 plotNum = G2frame.G2plotNB.plotList.index(Title) … … 2424 2459 Page = G2frame.G2plotNB.nb.GetPage(plotNum) 2425 2460 Page.canvas.mpl_connect('motion_notify_event', OnMotion) 2461 Page.canvas.mpl_connect('key_press_event', OnKeyPress) 2426 2462 2427 Page.Choice = None 2463 Page.Choice = (' key press','d: lower contour max','u: raise contour max','o: reset contour max', 2464 'i: interpolation method','s: color scheme') 2428 2465 Page.SetFocus() 2429 2466 G2frame.G2plotNB.status.DestroyChildren() 2430 2467 Nxy = Z.shape 2468 Zmax = np.max(Z) 2431 2469 Xmin = np.min(XY[0]) 2432 2470 Xmax = np.max(XY[0]) … … 2442 2480 else: 2443 2481 Plot.set_ylabel(r'Y',fontsize=14) 2444 Img = Plot.imshow(Z.T,cmap='Paired',interpolation='nearest',origin='lower', \ 2445 aspect='auto',extent=[Xmin,Xmax,Ymin,Ymax]) 2482 acolor = mpl.cm.get_cmap(G2frame.ContourColor) 2483 Img = Plot.imshow(Z.T,cmap=acolor,interpolation=G2frame.Interpolate,origin='lower', \ 2484 aspect='auto',extent=[Xmin,Xmax,Ymin,Ymax],vmin=0,vmax=Zmax*G2frame.Cmax) 2446 2485 Page.figure.colorbar(Img) 2447 2486 if not newPlot:
Note: See TracChangeset
for help on using the changeset viewer.