Skip to content

Commit f3c2a13

Browse files
committed
highligh offset in OpenGL backend
1 parent 958ac02 commit f3c2a13

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

src/silx/gui/plot/backends/glutils/GLPlotFrame.py

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def __init__(
103103
self._foregroundColor = foregroundColor
104104
self._labelAlign = labelAlign
105105
self._labelVAlign = labelVAlign
106-
self._orderOffetAnchor = (1.0, 0.0)
106+
self._orderOffsetAnchor = (1.0, 0.0)
107107
self._orderOffsetAlign = orderOffsetAlign
108108
self._orderOffsetVAlign = orderOffsetVAlign
109109
self._titleAlign = titleAlign
@@ -211,14 +211,14 @@ def title(self, title):
211211
self._dirtyPlotFrame()
212212

213213
@property
214-
def orderOffetAnchor(self) -> tuple[float, float]:
214+
def orderOffsetAnchor(self) -> tuple[float, float]:
215215
"""Anchor position for the tick order&offset text"""
216-
return self._orderOffetAnchor
216+
return self._orderOffsetAnchor
217217

218-
@orderOffetAnchor.setter
219-
def orderOffetAnchor(self, position: tuple[float, float]):
220-
if position != self._orderOffetAnchor:
221-
self._orderOffetAnchor = position
218+
@orderOffsetAnchor.setter
219+
def orderOffsetAnchor(self, position: tuple[float, float]):
220+
if position != self._orderOffsetAnchor:
221+
self._orderOffsetAnchor = position
222222
self._dirtyTicks()
223223

224224
@property
@@ -315,11 +315,20 @@ def getVerticesAndLabels(self):
315315
labels.append(axisTitle)
316316

317317
if self._orderAndOffsetText:
318-
xOrderOffset, yOrderOffet = self.orderOffetAnchor
318+
orderAndOffsetFont = qt.QFont(self.font)
319+
orderAndOffsetFont.setWeight(qt.QFont.ExtraBold)
320+
pointSize = orderAndOffsetFont.pointSizeF()
321+
if pointSize > 0:
322+
orderAndOffsetFont.setPointSizeF(1.2 * pointSize)
323+
pixelSize = orderAndOffsetFont.pixelSize()
324+
if pixelSize > 0:
325+
orderAndOffsetFont.setPixelSize(int(1.2 * pixelSize))
326+
327+
xOrderOffset, yOrderOffet = self.orderOffsetAnchor
319328
labels.append(
320329
Text2D(
321330
text=self._orderAndOffsetText,
322-
font=self.font,
331+
font=orderAndOffsetFont,
323332
color=self._foregroundColor,
324333
x=xOrderOffset,
325334
y=yOrderOffet,
@@ -856,7 +865,7 @@ def __init__(self, marginRatios, foregroundColor, gridColor, font: qt.QFont):
856865
foregroundColor=self._foregroundColor,
857866
labelAlign=RIGHT,
858867
labelVAlign=CENTER,
859-
orderOffsetAlign=LEFT,
868+
orderOffsetAlign=RIGHT,
860869
orderOffsetVAlign=BOTTOM,
861870
titleAlign=CENTER,
862871
titleVAlign=BOTTOM,
@@ -871,7 +880,7 @@ def __init__(self, marginRatios, foregroundColor, gridColor, font: qt.QFont):
871880
foregroundColor=self._foregroundColor,
872881
labelAlign=LEFT,
873882
labelVAlign=CENTER,
874-
orderOffsetAlign=RIGHT,
883+
orderOffsetAlign=LEFT,
875884
orderOffsetVAlign=BOTTOM,
876885
titleAlign=CENTER,
877886
titleVAlign=TOP,
@@ -1342,17 +1351,17 @@ def _buildVerticesAndLabels(self):
13421351
if fontPixelSize == -1:
13431352
fontPixelSize = self._font.pointSizeF() / 72.0 * self.dotsPerInch
13441353

1345-
self.axes[0].orderOffetAnchor = (
1354+
self.axes[0].orderOffsetAnchor = (
13461355
xCoords[1],
13471356
yCoords[0] + fontPixelSize * 1.2,
13481357
)
1349-
self.axes[1].orderOffetAnchor = (
1358+
self.axes[1].orderOffsetAnchor = (
13501359
xCoords[0],
1351-
yCoords[1] - 4 * self.devicePixelRatio,
1360+
yCoords[1] - 4 * self.devicePixelRatio - fontPixelSize / 2.0,
13521361
)
1353-
self._y2Axis.orderOffetAnchor = (
1362+
self._y2Axis.orderOffsetAnchor = (
13541363
xCoords[1],
1355-
yCoords[1] - 4 * self.devicePixelRatio,
1364+
yCoords[1] - 4 * self.devicePixelRatio - fontPixelSize / 2.0,
13561365
)
13571366

13581367
if self.isYAxisInverted:

0 commit comments

Comments
 (0)