I am plotting data with pyqtgraph inside a PySide6 Application. Anyways, the problem is that the text gets cut off if a name contains a special character like '<' or '>'.
Here is a minimal example:
from PySide6 import QtCore, QtWidgets
import pyqtgraph as pg
plt = pg.plot()
plt.addLegend()
c1 = plt.plot([1,2,3], pen='r', name="TEST_O<C_C*0.99>=H")
c2 = plt.plot([3,2,1], pen='g', name='green plot test blabla')
if __name__ == '__main__':
import sys
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
QtWidgets.QApplication.instance().exec()
Which outputs:
Why does this happen? Is there a work-around without replacing the characters?
I'd wager it's being interpreted as an HTML tag.
Try "TEST_O<C_C*0.99>=H"
, or, programmatically,
import html
# ...
c1 = plt.plot([1,2,3], pen='r', name=html.escape("TEST_O<C_C*0.99>=H"))