Skip to content

Commit

Permalink
Scatter Plot: Error bar icon
Browse files Browse the repository at this point in the history
  • Loading branch information
VesnaT committed Dec 5, 2024
1 parent 33369e1 commit 2a74ca6
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 9 deletions.
14 changes: 14 additions & 0 deletions Orange/widgets/visualize/icons/interval-horizontal.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions Orange/widgets/visualize/icons/interval-vertical.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 26 additions & 9 deletions Orange/widgets/visualize/owscatterplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
from sklearn.metrics import r2_score

from AnyQt.QtCore import Qt, QTimer, QPointF
from AnyQt.QtGui import QColor, QFont
from AnyQt.QtGui import QColor, QFont, QFontMetrics
from AnyQt.QtWidgets import QGroupBox, QSizePolicy, QPushButton

import pyqtgraph as pg

from orangewidget.utils import load_styled_icon
from orangewidget.utils.combobox import ComboBoxSearch

from Orange.data import Table, Domain, DiscreteVariable, Variable
Expand Down Expand Up @@ -481,29 +482,33 @@ def _add_controls_axis(self):
dmod = DomainModel
self.xy_model = DomainModel(dmod.MIXED, valid_types=dmod.PRIMITIVE)

hbox = gui.hBox(self.attr_box, spacing=2)
hor_icon, ver_icon = self.__get_bar_icons()
width = 3 * QFontMetrics(self.font()).horizontalAdvance("m")
hbox = gui.hBox(self.attr_box, spacing=0)
self.cb_attr_x = gui.comboBox(
hbox, self, "attr_x", label="Axis x:",
callback=self.set_attr_from_combo,
model=self.xy_model, **common_options,
)
self.button_attr_x = gui.button(
hbox, self, "ϵ", callback=self.__on_x_button_clicked,
autoDefault=False, width=20, enabled=False,
sizePolicy=(QSizePolicy.Maximum, QSizePolicy.Maximum)
hbox, self, "", callback=self.__on_x_button_clicked,
autoDefault=False, width=width, enabled=False,
sizePolicy=(QSizePolicy.Fixed, QSizePolicy.Fixed)
)
self.button_attr_x.setIcon(hor_icon)

hbox = gui.hBox(self.attr_box, spacing=2)
hbox = gui.hBox(self.attr_box, spacing=0)
self.cb_attr_y = gui.comboBox(
hbox, self, "attr_y", label="Axis y:",
callback=self.set_attr_from_combo,
model=self.xy_model, **common_options,
)
self.button_attr_y = gui.button(
hbox, self, "ϵ", callback=self.__on_y_button_clicked,
autoDefault=False, width=20, enabled=False,
sizePolicy=(QSizePolicy.Maximum, QSizePolicy.Maximum)
hbox, self, "", callback=self.__on_y_button_clicked,
autoDefault=False, width=width, enabled=False,
sizePolicy=(QSizePolicy.Fixed, QSizePolicy.Fixed)
)
self.button_attr_y.setIcon(ver_icon)

vizrank_box = gui.hBox(self.attr_box)
button = self.vizrank_button("Find Informative Projections")
Expand Down Expand Up @@ -846,6 +851,18 @@ def migrate_context(cls, context, version):
if values["attr_x"][1] % 100 == 1 or values["attr_y"][1] % 100 == 1:
raise IncompatibleContext()

__HorizontalBarIcon = None
__VerticalBarIcon = None

@classmethod
def __get_bar_icons(cls):
if cls.__HorizontalBarIcon is None:
cls.__HorizontalBarIcon = load_styled_icon(
"Orange.widgets.visualize", "icons/interval-horizontal.svg")
cls.__VerticalBarIcon = load_styled_icon(
"Orange.widgets.visualize", "icons/interval-vertical.svg")
return cls.__HorizontalBarIcon, cls.__VerticalBarIcon


if __name__ == "__main__": # pragma: no cover
table = Table("iris")
Expand Down

0 comments on commit 2a74ca6

Please sign in to comment.