Changeset 3983
- Timestamp:
- May 19, 2019 10:39:46 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIplot.py
r3982 r3983 1889 1889 elif event.key == 'o' and not G2frame.SinglePlot: 1890 1890 G2frame.Cmax = 1.0 1891 G2frame.Cmin = 0.0 1891 1892 Page.plotStyle['Offset'] = [0,0] 1892 1893 elif event.key == 'c' and 'PWDR' in plottype: … … 1895 1896 G2frame.SinglePlot = False 1896 1897 Page.plotStyle['Offset'] = [0.,0.] 1898 G2frame.FixedLimits['cylims'] = ['',''] # reset manual limits 1897 1899 else: 1898 1900 G2frame.SinglePlot = True … … 2528 2530 dbox[i].SetValue(dbox[i].GetValue()) 2529 2531 dbox[i].Enable(checked) 2532 def applyLims(event): 2533 Page.toolbar.push_current() 2534 CurLims = {} 2535 CurLims['xlims'] = list(Plot.get_xlim()) 2536 if G2frame.Weight: 2537 CurLims['ylims'] = list(Page.figure.axes[1].get_ylim()) 2538 CurLims['dylims'] = list(Page.figure.axes[2].get_ylim()) 2539 elif G2frame.Contour: 2540 CurLims['ylims'] = list(Plot.get_ylim()) 2541 CurLims['cylims'] = list(Page.Img.get_clim()) 2542 else: 2543 CurLims['ylims'] = list(Plot.get_ylim()) 2544 CurLims['dylims'] = [0,0] 2545 for var in 'xlims','ylims','dylims','cylims': 2546 for i in range(2): 2547 if not G2frame.UseLimits[var][i]: continue 2548 try: 2549 CurLims[var][i] = float(G2frame.FixedLimits[var][i]) 2550 CurLims[var][i] = float(G2frame.FixedLimits[var][i]) 2551 except: 2552 pass 2553 Plot.set_xlim(CurLims['xlims']) 2554 if G2frame.Weight: 2555 Page.figure.axes[1].set_ylim(CurLims['ylims']) 2556 Page.figure.axes[2].set_ylim(CurLims['dylims']) 2557 elif G2frame.Contour: 2558 Plot.set_ylim(CurLims['ylims']) 2559 Page.Img.set_clim(CurLims['cylims']) 2560 else: 2561 Plot.set_ylim(CurLims['ylims']) 2562 Page.toolbar.push_current() 2563 Plot.figure.canvas.draw() 2564 2565 # onSetPlotLim starts here 2530 2566 dlg = wx.Dialog(G2frame.plotFrame, 2531 2567 style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) … … 2545 2581 if G2frame.Weight: 2546 2582 lblkeys += [('(obs-calc)/sig ','dylims')] 2583 elif G2frame.Contour: 2584 lblkeys += [('contour','cylims')] 2585 2547 2586 for lbl,key in lblkeys: 2548 2587 gsizer.Add(wx.StaticText(dlg,wx.ID_ANY,lbl),0,wx.ALL) … … 2558 2597 vbox.Add((10,10),1,wx.ALL|wx.EXPAND,1) 2559 2598 hbox = wx.BoxSizer(wx.HORIZONTAL) 2599 hbox.Add((-1,-1),1,wx.ALL|wx.EXPAND,1) 2600 #btn = wx.Button(dlg, wx.ID_CLOSE) 2601 #btn.Bind(wx.EVT_BUTTON,lambda event:dlg.EndModal(wx.ID_CANCEL)) 2602 #hbox.Add(btn) 2603 btn = wx.Button(dlg, wx.ID_ANY, label='Apply') 2604 btn.Bind(wx.EVT_BUTTON,applyLims) 2605 hbox.Add(btn) 2560 2606 OKbtn = wx.Button(dlg, wx.ID_OK) 2561 2607 OKbtn.Bind(wx.EVT_BUTTON,lambda event:dlg.EndModal(wx.ID_OK)) 2562 hbox.Add((-1,-1),1,wx.ALL|wx.EXPAND,1)2563 2608 hbox.Add(OKbtn) 2564 2609 hbox.Add((-1,-1),1,wx.ALL|wx.EXPAND,1) … … 2568 2613 dlg.ShowModal() 2569 2614 dlg.Destroy() 2570 # apply values 2571 Page.toolbar.push_current() 2572 CurLims = {} 2573 CurLims['xlims'] = list(Plot.get_xlim()) 2574 if G2frame.Weight: 2575 CurLims['ylims'] = list(Page.figure.axes[1].get_ylim()) 2576 CurLims['dylims'] = list(Page.figure.axes[2].get_ylim()) 2577 else: 2578 CurLims['ylims'] = list(Plot.get_ylim()) 2579 CurLims['dylims'] = [0,0] 2580 for var in 'xlims','ylims','dylims': 2581 for i in range(2): 2582 if not G2frame.UseLimits[var][i]: continue 2583 try: 2584 CurLims[var][i] = float(G2frame.FixedLimits[var][i]) 2585 except: 2586 pass 2587 Plot.set_xlim(CurLims['xlims']) 2588 if G2frame.Weight: 2589 Page.figure.axes[1].set_ylim(CurLims['ylims']) 2590 Page.figure.axes[2].set_ylim(CurLims['dylims']) 2591 else: 2592 Plot.set_ylim(CurLims['ylims']) 2593 Page.toolbar.push_current() 2594 Plot.figure.canvas.draw() 2615 applyLims(None) # apply limits 2595 2616 #GSASIIpath.IPyBreak() 2596 2617 … … 2690 2711 G2frame.FixedLimits 2691 2712 except: 2692 G2frame.FixedLimits = {'xlims':['',''],'ylims':['',''], 2693 'dylims':['','']} 2713 G2frame.FixedLimits = {i:['',''] for i in ('xlims','ylims','dylims','cylims')} 2694 2714 try: 2695 2715 G2frame.UseLimits 2696 2716 except: 2697 G2frame.UseLimits = {'xlims':[False,False],'ylims':[False,False], 2698 'dylims':[False,False]} 2717 G2frame.UseLimits = {i:[False,False] for i in ('xlims','ylims','dylims','cylims')} 2699 2718 #===================================================================================== 2700 2719 # code to setup for plotting Rietveld results. Turns off multiplot, … … 2724 2743 G2frame.ErrorBars = True 2725 2744 newPlot = True 2745 G2frame.Cmin = 0.0 2726 2746 G2frame.Cmax = 1.0 2727 2747 # Page.canvas.mpl_connect('key_press_event', OnPlotKeyPress) … … 2768 2788 DifLine = [''] 2769 2789 if G2frame.Contour: 2770 Page.Choice = (' key press','d: lower contour max','u: raise contour max','o: reset contour max','g: toggle grid', 2790 Page.Choice = (' key press', 2791 'd: lower contour max','u: raise contour max', 2792 'D: lower contour min','U: raise contour min', 2793 'o: reset contour limits','g: toggle grid', 2771 2794 'i: interpolation method','S: color scheme','c: contour off','t: temperature for y-axis','s: toggle sqrt plot') 2772 2795 else: … … 3313 3336 time0 = time.time() 3314 3337 acolor = mpl.cm.get_cmap(G2frame.ContourColor) 3315 Img = Plot.imshow(ContourZ,cmap=acolor,vmin=0,vmax=Ymax*G2frame.Cmax,interpolation=G2frame.Interpolate, 3338 Page.Img = Plot.imshow(ContourZ,cmap=acolor, 3339 vmin=Ymax*G2frame.Cmin,vmax=Ymax*G2frame.Cmax, 3340 interpolation=G2frame.Interpolate, 3316 3341 extent=[ContourX[0],ContourX[-1],ContourY[0],ContourY[-1]],aspect='auto',origin='lower') 3317 3342 if G2frame.TforYaxis: 3318 imgAx = Img.axes3343 imgAx = Page.Img.axes 3319 3344 ytics = imgAx.get_yticks() 3320 3345 ylabs = [Temps[int(i)] for i in ytics[:-1]] 3321 3346 imgAx.set_yticklabels(ylabs) 3322 Page.figure.colorbar( Img)3347 Page.figure.colorbar(Page.Img) 3323 3348 if timeDebug: 3324 3349 print('Contour display time: %.3f'%(time.time()-time0)) … … 4623 4648 if G2frame.Contour and len(PlotList)>1: 4624 4649 acolor = mpl.cm.get_cmap(G2frame.ContourColor) 4625 Img = Plot.imshow(ContourZ,cmap=acolor,vmin=Ymax*G2frame.Cmin,vmax=Ymax*G2frame.Cmax,interpolation=G2frame.Interpolate, 4650 Img = Plot.imshow(ContourZ,cmap=acolor, 4651 vmin=Ymax*G2frame.Cmin,vmax=Ymax*G2frame.Cmax, 4652 interpolation=G2frame.Interpolate, 4626 4653 extent=[ContourX[0],ContourX[-1],ContourY[0],ContourY[-1]],aspect='auto',origin='lower') 4627 4654 Page.figure.colorbar(Img)
Note: See TracChangeset
for help on using the changeset viewer.