summaryrefslogtreecommitdiff
path: root/silx/gui/plot/backends/BackendMatplotlib.py
diff options
context:
space:
mode:
Diffstat (limited to 'silx/gui/plot/backends/BackendMatplotlib.py')
-rwxr-xr-xsilx/gui/plot/backends/BackendMatplotlib.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/silx/gui/plot/backends/BackendMatplotlib.py b/silx/gui/plot/backends/BackendMatplotlib.py
index 140672f..432b0b0 100755
--- a/silx/gui/plot/backends/BackendMatplotlib.py
+++ b/silx/gui/plot/backends/BackendMatplotlib.py
@@ -1,7 +1,7 @@
# coding: utf-8
# /*##########################################################################
#
-# Copyright (c) 2004-2020 European Synchrotron Radiation Facility
+# Copyright (c) 2004-2021 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -288,11 +288,17 @@ class _TextWithOffset(Text):
yoffset = 0
trans = self.get_transform()
- invtrans = self.get_transform().inverted()
-
x = super(_TextWithOffset, self).convert_xunits(self._x)
y = super(_TextWithOffset, self).convert_xunits(self._y)
pos = x, y
+
+ try:
+ invtrans = trans.inverted()
+ except numpy.linalg.LinAlgError:
+ # Cannot inverse transform, fallback: pos without offset
+ self.__cache = None
+ return pos
+
proj = trans.transform_point(pos)
proj = proj + numpy.array((xoffset, yoffset))
pos = invtrans.transform_point(proj)