def __init__(self, parent=None): super().__init__(parent) self.data = None box = gui.widgetBox(self.controlArea, "Variable") self.varmodel = itemmodels.VariableListModel() self.groupvarmodel = itemmodels.VariableListModel() self.varview = QtGui.QListView( selectionMode=QtGui.QListView.SingleSelection) self.varview.setModel(self.varmodel) self.varview.setSelectionModel( itemmodels.ListSingleSelectionModel(self.varmodel)) self.varview.selectionModel().selectionChanged.connect( self._on_variable_idx_changed) box.layout().addWidget(self.varview) box = gui.widgetBox(self.controlArea, "Group") self.groupvarview = QtGui.QListView( selectionMode=QtGui.QListView.SingleSelection) self.groupvarview.setModel(self.groupvarmodel) self.groupvarview.selectionModel().selectionChanged.connect( self._on_groupvar_idx_changed) box.layout().addWidget(self.groupvarview) box = gui.widgetBox(self.controlArea, "Options") self.estimator = 0 box = gui.radioButtons(box, self, "cont_est_type", [ "Histogram", "Average shifted histogram", "Kernel density estimator" ], callback=self._on_cont_est_type_changed) plotview = pg.PlotWidget(background=None) self.mainArea.layout().addWidget(plotview) w = QtGui.QLabel() w.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) self.mainArea.layout().addWidget(w, Qt.AlignCenter) self.plot = pg.PlotItem() # self.plot.getViewBox().setMouseEnabled(False, False) self.plot.getViewBox().setMenuEnabled(False) plotview.setCentralItem(self.plot) self.plot.getAxis("left").setLabel("Frequency") axis = self.plot.getAxis("left") axis.setLabel("Density") axis.setPen(QtGui.QPen(self.palette().color(QtGui.QPalette.Text))) axis = self.plot.getAxis("bottom") axis.setPen(QtGui.QPen(self.palette().color(QtGui.QPalette.Text)))
def __init__(self): super().__init__() self.data = None self.distributions = None self.contingencies = None self.var = self.cvar = None varbox = gui.vBox(self.controlArea, "Variable") self.varmodel = itemmodels.VariableListModel() self.groupvarmodel = [] self.varview = QListView( selectionMode=QListView.SingleSelection, uniformItemSizes=True ) self.varview.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding) self.varview.setModel(self.varmodel) self.varview.setSelectionModel( itemmodels.ListSingleSelectionModel(self.varmodel) ) self.varview.selectionModel().selectionChanged.connect( self._on_variable_idx_changed ) varbox.layout().addWidget(self.varview) box = gui.vBox(self.controlArea, "Precision") gui.separator(self.controlArea, 4, 4) box2 = gui.hBox(box) self.l_smoothing_l = gui.widgetLabel(box2, "Smooth") gui.hSlider( box2, self, "smoothing_index", minValue=0, maxValue=len(self.smoothing_facs) - 1, callback=self._on_set_smoothing, createLabel=False, ) self.l_smoothing_r = gui.widgetLabel(box2, "Precise") self.cb_disc_cont = gui.checkBox( gui.indentedBox(box, sep=4), self, "disc_cont", "Bin numeric variables", callback=self._on_groupvar_idx_changed, tooltip="Show numeric variables as categorical.", ) box = gui.vBox(self.controlArea, "Group by") self.icons = gui.attributeIconDict self.groupvarview = gui.comboBox( box, self, "groupvar_idx", callback=self._on_groupvar_idx_changed, valueType=str, contentsLength=12, ) box2 = gui.indentedBox(box, sep=4) self.cb_rel_freq = gui.checkBox( box2, self, "relative_freq", "Show relative frequencies", callback=self._on_relative_freq_changed, tooltip="Normalize probabilities so that probabilities " "for each group-by value sum to 1.", ) gui.separator(box2) self.cb_prob = gui.comboBox( box2, self, "show_prob", label="Show probabilities:", orientation=Qt.Horizontal, callback=self._on_relative_freq_changed, tooltip="Show probabilities for a chosen group-by value " "(at each point probabilities for all group-by values sum to 1).", ) self.plotview = pg.PlotWidget(background=None) self.plotview.setRenderHint(QPainter.Antialiasing) self.mainArea.layout().addWidget(self.plotview) w = QLabel() w.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self.mainArea.layout().addWidget(w, Qt.AlignCenter) self.ploti = pg.PlotItem() self.plot = self.ploti.vb self.ploti.hideButtons() self.plotview.setCentralItem(self.ploti) self.plot_prob = pg.ViewBox() self.ploti.hideAxis("right") self.ploti.scene().addItem(self.plot_prob) self.ploti.getAxis("right").linkToView(self.plot_prob) self.ploti.getAxis("right").setLabel("Probability") self.plot_prob.setZValue(10) self.plot_prob.setXLink(self.ploti) self.update_views() self.ploti.vb.sigResized.connect(self.update_views) self.plot_prob.setRange(yRange=[0, 1]) def disable_mouse(plot): plot.setMouseEnabled(False, False) plot.setMenuEnabled(False) disable_mouse(self.plot) disable_mouse(self.plot_prob) self.tooltip_items = [] self.plot.scene().installEventFilter(HelpEventDelegate(self.help_event, self)) pen = QPen(self.palette().color(QPalette.Text)) for axis in ("left", "bottom"): self.ploti.getAxis(axis).setPen(pen) self._legend = LegendItem() self._legend.setParentItem(self.plot) self._legend.hide() self._legend.anchor((1, 0), (1, 0))
def __init__(self, parent=None): super().__init__(parent) self.data = None self.distributions = None self.contingencies = None self.var = self.cvar = None varbox = gui.widgetBox(self.controlArea, "Variable") self.varmodel = itemmodels.VariableListModel() self.groupvarmodel = itemmodels.VariableListModel() self.varview = QtGui.QListView( selectionMode=QtGui.QListView.SingleSelection) self.varview.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.varview.setModel(self.varmodel) self.varview.setSelectionModel( itemmodels.ListSingleSelectionModel(self.varmodel)) self.varview.selectionModel().selectionChanged.connect( self._on_variable_idx_changed) varbox.layout().addWidget(self.varview) gui.separator(varbox, 8, 8) gui.comboBox(varbox, self, "cont_est_type", label="Show continuous variables by", valueType=int, items=[ "Histograms", "Average shifted histograms", "Kernel density estimators" ], callback=self._on_cont_est_type_changed) box = gui.widgetBox(self.controlArea, "Group by") self.groupvarview = QtGui.QListView( selectionMode=QtGui.QListView.SingleSelection) self.groupvarview.setFixedHeight(100) self.groupvarview.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred) self.groupvarview.setModel(self.groupvarmodel) self.groupvarview.selectionModel().selectionChanged.connect( self._on_groupvar_idx_changed) box.layout().addWidget(self.groupvarview) self.cb_rel_freq = gui.checkBox( box, self, "relative_freq", "Show relative frequencies", callback=self._on_relative_freq_changed) plotview = pg.PlotWidget(background=None) self.mainArea.layout().addWidget(plotview) w = QtGui.QLabel() w.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) self.mainArea.layout().addWidget(w, Qt.AlignCenter) self.plot = pg.PlotItem() # self.plot.getViewBox().setMouseEnabled(False, False) self.plot.getViewBox().setMenuEnabled(False) plotview.setCentralItem(self.plot) pen = QtGui.QPen(self.palette().color(QtGui.QPalette.Text)) for axis in ("left", "bottom"): self.plot.getAxis(axis).setPen(pen)
def __init__(self): super().__init__() self.data = None self.distributions = None self.contingencies = None self.var = self.cvar = None varbox = gui.widgetBox(self.controlArea, "Variable") self.varmodel = itemmodels.VariableListModel() self.groupvarmodel = [] self.varview = QtGui.QListView( selectionMode=QtGui.QListView.SingleSelection) self.varview.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.varview.setModel(self.varmodel) self.varview.setSelectionModel( itemmodels.ListSingleSelectionModel(self.varmodel)) self.varview.selectionModel().selectionChanged.connect( self._on_variable_idx_changed) varbox.layout().addWidget(self.varview) box = gui.widgetBox(self.controlArea, "Precision") gui.separator(self.controlArea, 4, 4) box2 = gui.widgetBox(box, orientation="horizontal") self.l_smoothing_l = gui.widgetLabel(box2, "Smooth") gui.hSlider(box2, self, "smoothing_index", minValue=0, maxValue=len(self.smoothing_facs) - 1, callback=self._on_set_smoothing, createLabel=False) self.l_smoothing_r = gui.widgetLabel(box2, "Precise") self.cb_disc_cont = gui.checkBox( gui.indentedBox(box, sep=4), self, "disc_cont", "Bin continuous variables", callback=self._on_groupvar_idx_changed) box = gui.widgetBox(self.controlArea, "Group by") self.icons = gui.attributeIconDict self.groupvarview = gui.comboBox( box, self, "groupvar_idx", callback=self._on_groupvar_idx_changed, valueType=str, contentsLength=12) box2 = gui.indentedBox(box, sep=4) self.cb_rel_freq = gui.checkBox( box2, self, "relative_freq", "Show relative frequencies", callback=self._on_relative_freq_changed) gui.separator(box2) self.cb_prob = gui.comboBox(box2, self, "show_prob", label="Show probabilities", orientation="horizontal", callback=self._on_relative_freq_changed) plotview = pg.PlotWidget(background=None) self.mainArea.layout().addWidget(plotview) w = QtGui.QLabel() w.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) self.mainArea.layout().addWidget(w, Qt.AlignCenter) self.plot = pg.PlotItem() self.plot.hideButtons() plotview.setCentralItem(self.plot) self.plot_prob = pg.ViewBox() self.plot.hideAxis('right') self.plot.scene().addItem(self.plot_prob) self.plot.getAxis("right").linkToView(self.plot_prob) self.plot.getAxis("right").setLabel("Probability") self.plot_prob.setZValue(10) self.plot_prob.setXLink(self.plot) self.update_views() self.plot.vb.sigResized.connect(self.update_views) self.plot_prob.setRange(yRange=[0, 1]) def disable_mouse(plot): plot.setMouseEnabled(False, False) plot.setMenuEnabled(False) disable_mouse(self.plot.getViewBox()) disable_mouse(self.plot_prob) pen = QtGui.QPen(self.palette().color(QtGui.QPalette.Text)) for axis in ("left", "bottom"): self.plot.getAxis(axis).setPen(pen) self._legend = LegendItem() self._legend.setParentItem(self.plot.getViewBox()) self._legend.hide() self._legend.anchor((1, 0), (1, 0)) self.graphButton.clicked.connect(self.save_graph)