Esempio n. 1
0
    def run(self):
        yrange = None
        xtitle = 'Wavelength (nm)'
        ytitle = None
        lbl = None
        one_to_one = False
        dpi = 1000
        annot_mask = None
        cmap = None
        colortitle = ''
        marker = None

        datakey = self.chooseDataComboBox.currentText()
        try:
            xcol = self.xVariableListWidget.selectedItems()[0].text()
        except:
            xcol = 'wvl'
        col = self.chooseColumnComboBox.currentText()
        try:
            row = self.chooseRowsListWidget.selectedItems()[0].text()
        except:
            row = 'None Selected'
        figname = self.figureNameLineEdit.text()
        title = self.plotTitleLineEdit.text()
        figfile = self.plotFilenameLineEdit.text()
        figpath, figfile = '/'.join(
            figfile.split('/')[:-1]), figfile.split('/')[-1]
        color = self.colorComboBox.currentText()
        alpha = self.alphaDoubleSpinBox.value()
        linewidth = self.lineWidthDoubleSpinBox.value()

        if color == 'Red':
            color = [1, 0, 0, alpha]
        elif color == 'Green':
            color = [0, 1, 0, alpha]
        elif color == 'Blue':
            color = [0, 0, 1, alpha]
        elif color == 'Cyan':
            color = [0, 1, 1, alpha]
        elif color == 'Yellow':
            color = [1, 1, 0, alpha]
        elif color == 'Magenta':
            color = [1, 0, 1, alpha]
        elif color == 'Black':
            color = [0, 0, 0, alpha]
        else:
            color = [0, 0, 0, alpha]

        line = self.lineComboBox.currentText()
        if line == 'Points (No Line)':
            linestyle = 'None'
        elif line == 'Line':
            linestyle = '-'
        elif line == 'Dashed Line':
            linestyle = '--'
        elif line == 'Dotted Line':
            linestyle = ':'
        else:
            linestyle = '-'

        xmin = self.minDoubleSpinBox.value()
        xmax = self.maxDoubleSpinBox.value()
        xrange = [xmin, xmax]
        self.data[datakey].enumerate_duplicates(col)
        data = self.data[datakey].df

        y = np.squeeze(
            np.array(data.loc[data[('meta', col)].isin([row])][xcol].T))
        x = np.array(data[xcol].columns.values)
        if linestyle == 'None':
            marker = 'o'
        try:
            loadfig = self.figs[figname]
        except:
            loadfig = None

        self.figs[figname] = make_plot(x,
                                       y,
                                       figpath=figpath,
                                       figfile=figfile,
                                       xrange=xrange,
                                       yrange=yrange,
                                       xtitle=xtitle,
                                       ytitle=ytitle,
                                       title=title,
                                       lbl=lbl,
                                       one_to_one=one_to_one,
                                       dpi=dpi,
                                       color=color,
                                       annot_mask=annot_mask,
                                       cmap=cmap,
                                       colortitle=colortitle,
                                       loadfig=loadfig,
                                       marker=marker,
                                       linestyle=linestyle,
                                       linewidth=linewidth)
Esempio n. 2
0
    def run(self):
        cmap = 'viridis'
        datakey = self.chooseDataComboBox.currentText()
        xvar = self.chooseXVariableComboBox.currentText()
        yvar = self.chooseYVariableComboBox.currentText()
        colorvar = self.comboBoxcolorvar.currentText()

        if colorvar != 'None':
            for top_col_val in list(self.data[datakey].df.columns.levels[0]):
                try:
                    colorval = self.data[datakey].df[(top_col_val, colorvar)]
                except:
                    pass

        else:
            colorval = None

        if self.figname_comboBox.currentText() == 'New Figure':
            figname = self.newfig_lineEdit.text()
        else:
            figname = self.figname_comboBox.currentText()

        loadfig = None
        if not figname in self.figname:
            self.figname.append(figname)
        if figname in self.figs:
            loadfig = self.figs[figname]

        title = self.plotTitleLineEdit.text()
        xrange = self.xMinDoubleSpinBox.value(), self.xMaxDoubleSpinBox.value()
        yrange = self.yMinDoubleSpinBox.value(), self.yMaxDoubleSpinBox.value()
        xtitle = self.xTitleLineEdit.text()
        ytitle = self.yTitleLineEdit.text()
        lbl = self.legendLineEdit.text()
        one_to_one = self.oneToOneCheckBox.isChecked()
        color = self.colorComboBox.currentText()

        alpha = self.alphaDoubleSpinBox.value() / 100.0
        annot_mask = None
        colortitle = ''
        dpi = 1000

        if color == 'Red':
            color = [1, 0, 0, alpha]
        elif color == 'Green':
            color = [0, 1, 0, alpha]
        elif color == 'Blue':
            color = [0, 0, 1, alpha]
        elif color == 'Cyan':
            color = [0, 1, 1, alpha]
        elif color == 'Yellow':
            color = [1, 1, 0, alpha]
        elif color == 'Magenta':
            color = [1, 0, 1, alpha]
        elif color == 'Black':
            color = [0, 0, 0, alpha]

        marker = self.markerComboBox.currentText()
        if marker == 'Circles':
            marker = 'o'
        if marker == 'Squares':
            marker = 's'
        if marker == 'Diamonds':
            marker = 'D'
        if marker == 'Triangle Up':
            marker = '^'
        if marker == 'Triangle Down':
            marker = 'v'
        if marker == 'Triangle Right':
            marker = '>'
        if marker == 'Triangle Left':
            marker = '<'

        linestyle = self.lineComboBox.currentText()
        if linestyle == 'No Line':
            linestyle = 'None'
        if linestyle == 'Line':
            linestyle = '-'
        if linestyle == 'Dashed Line':
            linestyle = '--'
        if linestyle == 'Dotted Line':
            linestyle = ':'

        try:
            if self.data[datakey].df.columns.nlevels == 2:
                vars_level0 = self.data[datakey].df.columns.get_level_values(0)
                vars_level1 = self.data[datakey].df.columns.get_level_values(1)
                vars_level1 = list(vars_level1[vars_level0 != 'wvl'])
                vars_level0 = list(vars_level0[vars_level0 != 'wvl'])
                xvar = (vars_level0[vars_level1.index(xvar)], xvar)
                yvar = (vars_level0[vars_level1.index(yvar)], yvar)
        except AttributeError:  # df attribute doesn't exist.
            pass

        try:
            x = self.data[datakey].df[xvar]
            y = self.data[datakey].df[yvar]
        except:
            x = self.data[datakey]['cv'][xvar]
            y = self.data[datakey]['cv'][yvar]

        figpath = self.plotFilenameLineEdit.text()
        figpath, figfile = '/'.join(
            figpath.split('/')[:-1]), figpath.split('/')[-1]
        if self.plotFilenameLineEdit.text(
        ) == "" or self.plotFilenameLineEdit.text() == "*.png":
            figpath, figfile = self.outpath, figname
        self.figs[figname] = make_plot(x,
                                       y,
                                       figpath,
                                       figfile,
                                       xrange=xrange,
                                       yrange=yrange,
                                       xtitle=xtitle,
                                       ytitle=ytitle,
                                       title=title,
                                       lbl=lbl,
                                       one_to_one=one_to_one,
                                       dpi=dpi,
                                       colorvar=colorvar,
                                       colorval=colorval,
                                       annot_mask=annot_mask,
                                       cmap=cmap,
                                       color=color,
                                       colortitle=colortitle,
                                       loadfig=loadfig,
                                       marker=marker,
                                       linestyle=linestyle)