コード例 #1
0
ファイル: main.py プロジェクト: sdiehl/rpygtk
 def output(self,text,title=None):
     '''Output text to the output tab'''
     text = str(text)
     if title:
         text = '%s\n' % title + text
     summary = self.builder.get_object('summaryview')
     summary.get_buffer().set_text(text)
     if prefs.get_pref('auto_switch'):
         self.builder.get_object('main_tabview').set_current_page(1)
コード例 #2
0
ファイル: regression.py プロジェクト: sdiehl/rpygtk
    def hide(self):
        # Stop sending updates from the main window
        self.parent.child_windows.remove(self)

        if prefs.get_pref("close_plots"):
            rsession.r["graphics.off"]()
            self.killall()

        # self.window.hide()
        return True
コード例 #3
0
ファイル: main.py プロジェクト: sdiehl/rpygtk
 def set_active_robject(self,object):
     #If we have a dataframe
     if object.outputsTo == "frame":
         self.active_robject = object
         self.handle_dataview(object.rawdata,object.columns,rownames=object.rownames)
         if prefs.get_pref('auto_switch'):
             self.builder.get_object('main_tabview').set_current_page(0)
         for window in self.child_windows:
             window.active_r_object = object
             window.show_variables(object)
     elif object.outputsTo == "output":
         self.active_robject = object
         self.active_output = object
         self.output(object.text)
         if prefs.get_pref('auto_switch'):
             self.builder.get_object('main_tabview').set_current_page(1)
         self.clear_dataview()
     elif object.outputsTo == 'graphics':
         pass
     else:
         error('Cannot render object.')
コード例 #4
0
ファイル: rsession.py プロジェクト: sdiehl/rpygtk
    def run (self):
        #Plot types
        plot = r.plot
        hist = r.hist
        barplot = r.barplot
        pie = r.pie
        qqnorm = r.qqnorm
        qqplot= r.qqplot

        #Export types
        if self.export:
            #Shut down all other plots before we do anything involving exporting
            r['graphics.off']()
            filename,extension = self.export

            if extension not in filename:
                extension += filename

            if extension == '.svg':
                svg(filename)
            elif extension == '.png':
                png(filename)
            elif extension == '.ps':
                postscript(filename)
            elif extension == '.pdf':
                #There is a rather strange bug where points get rendered as
                #letters unless we toggle useDingbats=False
                pdf(filename,useDingbats=False)

            if self.par_mode:
                rows, columns = self.par_mode
                r('par(mfrow=c(%s,%s))' % (rows,columns))
        else:
            #Don't bother opening a new window if there already is an open one
            #unless the user has specified that every new plot should open in a
            #new window
            if thereArePlotWindowsOpen() and prefs.get_pref('single_plot'):
                #Clear the previous plots, unless we're in par mode
                if not self.par_mode:
                    r('plot.new()')
                else:
                    rows, columns = self.par_mode
                    r('par(mfrow=c(%s,%s))' % (rows,columns))
            else:
                X11()

        if self.type=='scatter':
            x = self.data['x']
            y = self.data['y']
            plot(x,y,**self.args)

        if self.type=='scatter.smooth':
            x = self.data['x']
            y = self.data['y']

            r['scatter.smooth'](x=x,y=y,**self.args)

        if self.type=='matplot':
            df = robjects.r['data.frame'](**self.data)
            plot(df,**self.args)

        if self.type=='histogram':
            x = self.data['x']
            hist(x,**self.args)

        if self.type=='bar':
            x = self.data['x']
            barplot(x,**self.args)

        if self.type=='pie':
            x = self.data['x']
            pie(x,**self.args)

        if self.type=='qqnorm':
            x = self.data['x']
            qqnorm(x,**self.args)

        if self.type=='qqplot':
            x = self.data['x']
            y = self.data['y']
            qqplot(x,y,**self.args)

        if self.type=='boxplot':
            data = r['data.frame'](**self.data)
            r['boxplot'](data,**self.args)

        if self.type=='general':
            '''data is passed directly to plot'''
            plot(self.data,**self.args)

        if self.export:
            #Run through an secondary commands before we save the image
            for c in self.cmd_stack:
                cmd,args,kwargs = c
                apply(cmd,args,kwargs)
                self.cmd_stack.remove(c)
            devoff()
            return

        self.t = threading.Timer(0.1, self.refresh)
        self.t.start()