Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
eff5944
utils/dendrogram: Use palette colors
ales-erjavec Oct 14, 2021
e5d3235
graphicstextlist: Use palette colors
ales-erjavec Oct 14, 2021
4d86528
heatmap: Use palette colors
ales-erjavec Oct 14, 2021
4cf9267
owtreeviewer: Use palette colors
ales-erjavec Oct 14, 2021
d635839
widgets: Use palette colors
ales-erjavec Oct 14, 2021
659d4c0
owvenndiagram: Use palette colors
ales-erjavec Oct 14, 2021
51a09ef
plotutils: Add pg.PlotWidget pg.AxisItem that are palette aware
ales-erjavec Oct 14, 2021
a99e732
owsilhouetteplot: Use palette for GUI element colors
ales-erjavec Oct 5, 2017
0a535f1
owhierarchicalclustering: Use palette colors
ales-erjavec Oct 14, 2021
f6fc6a4
Use PlotWidget
ales-erjavec Oct 18, 2021
b1afbd7
slidergraph: Use palette
ales-erjavec Oct 18, 2021
384f6f4
AnchorItem: Change parent class to GraphicsWidget
ales-erjavec Oct 18, 2021
673bc4c
owscatterplotgraph: Use palette colors for selection tips
ales-erjavec Oct 19, 2021
0a8f528
plotutils: Add palette aware GraphicsView, PlotItem
ales-erjavec Oct 21, 2021
2d3d9d6
Use plotutils.GraphicsView and PlotItem
ales-erjavec Oct 22, 2021
d1abedb
owscatterplotgraph: Use palette colors for legend item
ales-erjavec Oct 22, 2021
cf35548
heatmap: Adapt to palette change
ales-erjavec Oct 25, 2021
d19cb06
owhierarchicalclustering: Inherit SliderLine from QGraphicsWidget
ales-erjavec Oct 26, 2021
55ff045
owdistancematrix: Specify foreground when overriding background
ales-erjavec Oct 27, 2021
ca9b973
plotutils: Reset the palette in GraphicsView/PlotWidget constructors
ales-erjavec Feb 4, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Orange/widgets/data/owpaintdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

from Orange.util import scale, namegen
from Orange.widgets.utils.widgetpreview import WidgetPreview
from Orange.widgets.visualize.utils.plotutils import PlotWidget
from Orange.widgets.widget import OWWidget, Msg, Input, Output


Expand Down Expand Up @@ -512,7 +513,8 @@ def mouseReleaseEvent(self, event):

def activate(self):
if self._item is None:
self._item = _RectROI((0, 0), (0, 0), pen=(25, 25, 25))
pen = self._plot.palette().color(QPalette.Text)
self._item = _RectROI((0, 0), (0, 0), pen=pen)
self._item.setAcceptedMouseButtons(Qt.LeftButton)
self._item.setVisible(False)
self._item.setCursor(Qt.OpenHandCursor)
Expand Down Expand Up @@ -938,8 +940,7 @@ def _init_ui(self):

# main area GUI
viewbox = PaintViewBox(enableMouse=False)
self.plotview = pg.PlotWidget(background="w", viewBox=viewbox)
self.plotview.sizeHint = lambda: QSize(200, 100) # Minimum size for 1-d painting
self.plotview = PlotWidget(viewBox=viewbox)
self.plot = self.plotview.getPlotItem()

axis_color = self.palette().color(QPalette.Text)
Expand Down
4 changes: 2 additions & 2 deletions Orange/widgets/data/owselectrows.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ def add_row(self, attr=None, condition_type=None, condition_value=None):

index = QPersistentModelIndex(model.index(row, 3))
temp_button = QPushButton('×', self, flat=True,
styleSheet='* {font-size: 16pt; color: silver}'
'*:hover {color: black}')
styleSheet='* {font-size: 16pt; color: palette(button-text) }'
'*:hover {color: palette(bright-text)}')
temp_button.clicked.connect(lambda: self.remove_one(index.row()))
self.cond_list.setCellWidget(row, 3, temp_button)

Expand Down
10 changes: 3 additions & 7 deletions Orange/widgets/evaluate/owcalibrationplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from Orange.widgets.utils.widgetpreview import WidgetPreview
from Orange.widgets.visualize.utils.customizableplot import \
CommonParameterSetter
from Orange.widgets.visualize.utils.plotutils import AxisItem
from Orange.widgets.visualize.utils.plotutils import GraphicsView, PlotItem
from Orange.widgets.widget import Input, Output, Msg
from Orange.widgets import report

Expand Down Expand Up @@ -191,17 +191,13 @@ def __init__(self):

gui.auto_apply(self.buttonsArea, self, "auto_commit")

self.plotview = pg.GraphicsView(background="w")
axes = {"bottom": AxisItem(orientation="bottom"),
"left": AxisItem(orientation="left")}
self.plot = pg.PlotItem(enableMenu=False, axisItems=axes)
self.plotview = GraphicsView()
self.plot = PlotItem(enableMenu=False)
self.plot.parameter_setter = ParameterSetter(self.plot)
self.plot.setMouseEnabled(False, False)
self.plot.hideButtons()

for axis_name in ("bottom", "left"):
axis = self.plot.getAxis(axis_name)
axis.setPen(pg.mkPen(color=0.0))
# Remove the condition (that is, allow setting this for bottom
# axis) when pyqtgraph is fixed
# Issue: https://github.com/pyqtgraph/pyqtgraph/issues/930
Expand Down
2 changes: 2 additions & 0 deletions Orange/widgets/evaluate/owconfusionmatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,8 @@ def _isinvalid(x):
[0, 240][i == j], 160,
255 if _isinvalid(col_val) else int(255 - 30 * col_val))
item.setData(QBrush(bkcolor), Qt.BackgroundRole)
# bkcolor is light-ish so use a black text
item.setData(QBrush(Qt.black), Qt.ForegroundRole)
item.setData("trbl", BorderRole)
item.setToolTip("actual: {}\npredicted: {}".format(
self.headers[i], self.headers[j]))
Expand Down
14 changes: 4 additions & 10 deletions Orange/widgets/evaluate/owliftcurve.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np

from AnyQt.QtWidgets import QListView, QFrame
from AnyQt.QtGui import QColor, QPen, QPalette, QFont
from AnyQt.QtGui import QColor, QPen, QFont
from AnyQt.QtCore import Qt

import pyqtgraph as pg
Expand All @@ -22,7 +22,7 @@
from Orange.widgets.utils.widgetpreview import WidgetPreview
from Orange.widgets.visualize.utils.customizableplot import Updater, \
CommonParameterSetter
from Orange.widgets.visualize.utils.plotutils import AxisItem
from Orange.widgets.visualize.utils.plotutils import GraphicsView, PlotItem
from Orange.widgets.widget import Input
from Orange.widgets import report

Expand Down Expand Up @@ -214,12 +214,9 @@ def __init__(self):

gui.rubber(self.controlArea)

self.plotview = pg.GraphicsView(background="w")
self.plotview = GraphicsView()
self.plotview.setFrameStyle(QFrame.StyledPanel)

axes = {"bottom": AxisItem(orientation="bottom"),
"left": AxisItem(orientation="left")}
self.plot = pg.PlotItem(enableMenu=False, axisItems=axes)
self.plot = PlotItem(enableMenu=False)
self.plot.parameter_setter = ParameterSetter(self.plot)
self.plot.curve_items = []
self.plot.hull_items = []
Expand All @@ -228,15 +225,12 @@ def __init__(self):
self.plot.setMouseEnabled(False, False)
self.plot.hideButtons()

pen = QPen(self.palette().color(QPalette.Text))

tickfont = QFont(self.font())
tickfont.setPixelSize(max(int(tickfont.pixelSize() * 2 // 3), 11))

for pos, label in (("bottom", "P Rate"), ("left", "")):
axis = self.plot.getAxis(pos)
axis.setTickFont(tickfont)
axis.setPen(pen)
axis.setLabel(label)
self._set_left_label()

Expand Down
27 changes: 14 additions & 13 deletions Orange/widgets/evaluate/owrocanalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from Orange.widgets.evaluate.utils import check_results_adequacy
from Orange.widgets.utils import colorpalettes
from Orange.widgets.utils.widgetpreview import WidgetPreview
from Orange.widgets.visualize.utils.plotutils import GraphicsView, PlotItem
from Orange.widgets.widget import Input
from Orange.widgets import report

Expand Down Expand Up @@ -395,32 +396,28 @@ def __init__(self):
grid.addWidget(QLabel("Prior probability:"))
grid.addWidget(self.target_prior_sp, 2, 1)

self.plotview = pg.GraphicsView(background="w")
self.plotview = GraphicsView(background=None)
self.plotview.setFrameStyle(QFrame.StyledPanel)
self.plotview.scene().sigMouseMoved.connect(self._on_mouse_moved)

self.plot = pg.PlotItem(enableMenu=False)
self.plot = PlotItem(enableMenu=False)
self.plot.setMouseEnabled(False, False)
self.plot.hideButtons()

pen = QPen(self.palette().color(QPalette.Text))

tickfont = QFont(self.font())
tickfont.setPixelSize(max(int(tickfont.pixelSize() * 2 // 3), 11))

axis = self.plot.getAxis("bottom")
axis.setTickFont(tickfont)
axis.setPen(pen)
axis.setLabel("FP Rate (1-Specificity)")
axis.setGrid(16)

axis = self.plot.getAxis("left")
axis.setTickFont(tickfont)
axis.setPen(pen)
axis.setLabel("TP Rate (Sensitivity)")
axis.setGrid(16)

self.plot.showGrid(True, True, alpha=0.1)
self.plot.showGrid(True, True, alpha=0.2)
self.plot.setRange(xRange=(0.0, 1.0), yRange=(0.0, 1.0), padding=0.05)

self.plotview.setCentralItem(self.plot)
Expand Down Expand Up @@ -553,14 +550,15 @@ def merge_averaging():
ind = np.argmin(np.abs(points.thresholds - 0.5))
item = pg.TextItem(
text="{:.3f}".format(points.thresholds[ind]),
color=foreground
)
item.setPos(points.fpr[ind], points.tpr[ind])
self.plot.addItem(item)

hull_curves = [curve.merged.hull for curve in selected]
if hull_curves:
self._rocch = convex_hull(hull_curves)
iso_pen = QPen(QColor(Qt.black), 1)
iso_pen = QPen(foreground, 1.0)
iso_pen.setCosmetic(True)
self._perf_line = InfiniteLine(pen=iso_pen, antialias=True)
self.plot.addItem(self._perf_line)
Expand Down Expand Up @@ -596,7 +594,7 @@ def no_averaging():
OWROCAnalysis.Threshold: threshold_averaging,
OWROCAnalysis.NoAveraging: no_averaging
}

foreground = self.plotview.scene().palette().color(QPalette.Text)
target = self.target_index
selected = self.selected_classifiers

Expand All @@ -606,16 +604,19 @@ def no_averaging():

if self.display_convex_hull and hull_curves:
hull = convex_hull(hull_curves)
hull_pen = QPen(QColor(200, 200, 200, 100), 2)
hull_color = QColor(foreground)
hull_color.setAlpha(100)
hull_pen = QPen(hull_color, 2)
hull_pen.setCosmetic(True)
hull_color.setAlpha(50)
item = self.plot.plot(
hull.fpr, hull.tpr,
pen=hull_pen,
brush=QBrush(QColor(200, 200, 200, 50)),
brush=QBrush(hull_color),
fillLevel=0)
item.setZValue(-10000)

pen = QPen(QColor(100, 100, 100, 100), 1, Qt.DashLine)
line_color = self.palette().color(QPalette.Disabled, QPalette.Text)
pen = QPen(QColor(*line_color.getRgb()[:3], 200), 1.0, Qt.DashLine)
pen.setCosmetic(True)
self.plot.plot([0, 1], [0, 1], pen=pen, antialias=True)

Expand Down
15 changes: 8 additions & 7 deletions Orange/widgets/unsupervised/owcorrespondence.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
import numpy as np

from AnyQt.QtWidgets import QListView, QApplication, QSizePolicy
from AnyQt.QtGui import QBrush, QColor, QPainter
from AnyQt.QtGui import QBrush, QColor, QPainter, QPalette
from AnyQt.QtCore import QEvent, Qt
from orangewidget.utils.listview import ListViewSearch

import pyqtgraph as pg

from orangewidget.utils.listview import ListViewSearch

from Orange.data import Table, Domain, ContinuousVariable, StringVariable
from Orange.statistics import contingency

from Orange.widgets import widget, gui, settings
from Orange.widgets.utils import itemmodels, colorpalettes
from Orange.widgets.utils.itemmodels import select_rows
from Orange.widgets.utils.widgetpreview import WidgetPreview

from Orange.widgets.visualize.owscatterplotgraph import ScatterPlotItem
from Orange.widgets.visualize.utils.plotutils import PlotWidget
from Orange.widgets.widget import Input, Output
from Orange.widgets.settings import Setting

Expand Down Expand Up @@ -93,7 +93,7 @@ def __init__(self):

gui.auto_send(self.buttonsArea, self, "auto_commit")

self.plot = pg.PlotWidget(background="w")
self.plot = PlotWidget()
self.plot.setMenuEnabled(False)
self.mainArea.layout().addWidget(self.plot)

Expand Down Expand Up @@ -277,6 +277,7 @@ def get_minmax(points):
margin = margin * 0.05 if margin > 1e-10 else 1
self.plot.setYRange(minmax[2] - margin, minmax[3] + margin)

foreground = self.palette().color(QPalette.Text)
for i, (v, points) in enumerate(zip(variables, points)):
color_outline = colors[i]
color_outline.setAlpha(200)
Expand All @@ -290,7 +291,7 @@ def get_minmax(points):
self.plot.addItem(item)

for name, point in zip(v.values, points):
item = pg.TextItem(name, anchor=(0.5, 0))
item = pg.TextItem(name, anchor=(0.5, 0), color=foreground)
self.plot.addItem(item)
item.setPos(point[0], point[1])

Expand Down
3 changes: 2 additions & 1 deletion Orange/widgets/unsupervised/owdistancemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from Orange.widgets.visualize.utils.plotutils import HelpEventDelegate
from Orange.widgets.widget import Input, Output
from Orange.widgets.utils.dendrogram import DendrogramWidget
from Orange.widgets.visualize.utils.plotutils import GraphicsView
from Orange.widgets.visualize.utils.heatmap import (
GradientColorMap, GradientLegendWidget,
)
Expand Down Expand Up @@ -344,7 +345,7 @@ def _set_thresholds(low, high):

gui.auto_send(self.buttonsArea, self, "autocommit")

self.view = GraphicsView(background="w")
self.view = GraphicsView(background=None)
self.mainArea.layout().addWidget(self.view)

self.grid_widget = pg.GraphicsWidget()
Expand Down
16 changes: 12 additions & 4 deletions Orange/widgets/unsupervised/owdistancematrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def dimension(self, parent=None):

def color_for_label(self, ind, light=100):
if self.label_colors is None:
return Qt.lightGray
return None
return QBrush(self.label_colors[ind].lighter(light))

def color_for_cell(self, row, col):
Expand All @@ -80,7 +80,7 @@ def data(self, index, role=Qt.DisplayRole):
return Qt.AlignRight | Qt.AlignVCenter
row, col = index.row(), index.column()
if self.distances is None:
return
return None
if role == TableBorderItem.BorderColorRole:
return self.color_for_label(col), self.color_for_label(row)
if role == FixedFormatNumericColumnDelegate.ColumnDataSpanRole:
Expand All @@ -93,15 +93,21 @@ def data(self, index, role=Qt.DisplayRole):
return float(self.distances[row, col])
if role == Qt.BackgroundColorRole:
return self.color_for_cell(row, col)
if role == Qt.ForegroundRole:
return QColor(Qt.black) # the background is light-ish
return None

def headerData(self, ind, orientation, role):
if not self.labels:
return
return None
if role == Qt.DisplayRole and ind < len(self.labels):
return self.labels[ind]
# On some systems, Qt doesn't respect the following role in the header
if role == Qt.BackgroundRole:
return self.color_for_label(ind, 150)
if role == Qt.ForegroundRole and self.label_colors is not None:
return QColor(Qt.black)
return None


class TableBorderItem(FixedFormatNumericColumnDelegate):
Expand Down Expand Up @@ -194,7 +200,9 @@ def __init__(self):
view.setWordWrap(False)
view.setTextElideMode(Qt.ElideNone)
view.setEditTriggers(QTableView.NoEditTriggers)
view.setItemDelegate(TableBorderItem(roles=(Qt.DisplayRole, Qt.BackgroundRole)))
view.setItemDelegate(
TableBorderItem(
roles=(Qt.DisplayRole, Qt.BackgroundRole, Qt.ForegroundRole)))
view.setModel(self.tablemodel)
view.setShowGrid(False)
for header in (view.horizontalHeader(), view.verticalHeader()):
Expand Down
Loading