-
Notifications
You must be signed in to change notification settings - Fork 14
taurus tpg plot: curve names in legend cannot be changed #31
Comments
This option is not yet ready in pyqtgraph |
None of the 3 possible methods work yet:
|
Editions of the curve titles in the curves list widget are now applied on "Apply". Fixes taurus-org#31
Is it possible now to change/set the legends of curves in code? In my TaurusTrend panel I have 4 curves, whose data set by the |
Hi, @mariocaptain , you can do it, but it is not trivial. from taurus.qt.qtgui.application import TaurusApplication
from taurus_pyqtgraph import TaurusPlot
import sys
def change_curve_name(title, curve, plotItem):
# change curve title
curve.setData(name=title)
# update legend (if it exists)
if plotItem.legend is not None:
if hasattr(plotItem.legend, "getLabel"): # requires pyqtgraph > 0.11
plotItem.legend.getLabel(curve).setText(title)
else: # for pyqtgraph <= 0.11
for sample, label in plotItem.legend.items:
if sample.item == curve:
label.setText(title)
break
app = TaurusApplication(cmd_line_parser=None)
w = TaurusPlot()
w.setModel(["eval:rand(33)", "eval:2+rand(33)"])
change_curve_name("foo", w[0], w.getPlotItem())
change_curve_name("bar", w[1], w.getPlotItem())
w.show()
sys.exit(app.exec_()) |
Dear @cpascual , Thanks so much for the time. The function works very well. I am so happy with TaurusTrend now :) Best, |
Bug found during manual tests on win10 py3qt5 Jul19 release:
taurus tpg plot: curve names in legend cannot be changed
Even when clicking to 'apply', the curve titles are not changed in the legend
The text was updated successfully, but these errors were encountered: