Changeset 3967 for trunk/fprime.py


Ignore:
Timestamp:
May 11, 2019 10:12:27 AM (2 years ago)
Author:
vondreele
Message:

embed fprime & absorb plots in GSAS-II plot window as separate tabs. This removes conflict between contour plots & fprime/absorb plots

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/fprime.py

    r3963 r3967  
    99import wx
    1010import numpy as np
    11 import matplotlib as mpl
    12 import matplotlib.pyplot as plt
    1311import sys
    1412import GSASIIpath
     
    231229    def __init__(self, parent):
    232230        self._init_ctrls(parent)
    233         mpl.rcParams['axes.grid'] = True
    234         mpl.rcParams['legend.fontsize'] = 10
     231        self.parent = parent
    235232        self.Lines = []
    236233        self.linePicked = None
    237234       
    238235    def OnFPRIMEExitMenu(self, event):
    239         plt.close('all')
     236        self.parent.G2plotNB.Delete('Fprime')
    240237        self.Close()
    241238        self.Destroy()
     
    334331        bxylim = []
    335332        try:
    336             self.fplot.canvas.set_window_title('X-Ray Resonant Scattering')
    337333            if rePlot:
    338                 asb,bsb = self.fplot.get_children()[1:]
     334                asb,bsb = self.Page.get_children()[1:]
    339335                axylim = asb.get_xlim(),asb.get_ylim()
    340336                bxylim = bsb.get_xlim(),bsb.get_ylim()
    341337            newPlot = False
    342338        except:
    343             self.fplot = plt.figure(facecolor='white',figsize=(8,8))  #BTW: default figsize is (8,6)
    344             self.fplot.canvas.set_window_title('X-Ray Resonant Scattering')
    345             self.fplot.canvas.mpl_connect('pick_event', self.OnPick)
    346             self.fplot.canvas.mpl_connect('button_release_event', self.OnRelease)
    347             self.fplot.canvas.mpl_connect('motion_notify_event', self.OnMotion)
     339            new,plotNum,self.Page,self.fplot,lim = self.parent.G2plotNB.FindPlotTab('Fprime','mpl')
     340            self.Page.canvas.mpl_connect('pick_event', self.OnPick)
     341            self.Page.canvas.mpl_connect('button_release_event', self.OnRelease)
     342            self.Page.canvas.mpl_connect('motion_notify_event', self.OnMotion)
    348343            newPlot = True
    349         ax = self.fplot.add_subplot(211)
     344        self.fplot.set_visible(False)
     345        ax = self.Page.figure.add_subplot(211)
    350346        ax.clear()
    351347        ax.set_title('Resonant Scattering Factors',x=0,ha='left')
     
    374370        if self.FPPS:
    375371            ax.legend(loc='best')
    376         bx = self.fplot.add_subplot(212)
    377         self.fplot.subplots_adjust(hspace=0.25)
     372        bx = self.Page.figure.add_subplot(212)
     373        self.Page.figure.subplots_adjust(hspace=0.25)
    378374        bx.clear()
    379375        if self.ifWave:
     
    428424        if newPlot:
    429425            newPlot = False
    430             plt.show()
     426            self.Page.canvas.draw()
    431427        else:
    432428            if rePlot:
    433                 tb = self.fplot.canvas.toolbar
     429                tb = self.Page.canvas.toolbar
    434430                tb.push_current()
    435431                ax.set_xlim(axylim[0])
     
    441437                bxylim = []
    442438                tb.push_current()
    443             plt.draw()
     439            self.Page.canvas.draw()
    444440       
    445441    def OnPick(self, event):
     
    592588        '''
    593589        wxadv.AboutBox(info)
    594 
    595 class FprimeApp(wx.App):
    596     ''' '''
    597     def OnInit(self):
    598         self.main = Fprime(None)
    599         self.main.Show()
    600         self.SetTopWindow(self.main)
    601         self.main.OnFPRIMENewMenu(None)
    602         return True
    603 
    604 def main():
    605     ''' '''
    606     application = FprimeApp(0)
    607     application.MainLoop()
    608 
    609 if __name__ == '__main__':
    610     main()
Note: See TracChangeset for help on using the changeset viewer.