Starting in R2024a, you can specify a "Line Label" for each signal that is mapped to Axes (see the release notes). The corresponding code is: myLineStyle = slrealtime.instrument.LineStyle();
myLineStyle.Label = 'Custom Label';
hInst.connectLine(app.myAxes, {'myModel/myBlock'}, 1, ...
'LineStyle', myLineStyle);
In R2023b and prior, the ability to customize the legend labels when using instruments and SLRT App Generator is not available.
Workaround for scalar signals:
Make sure that you name the signals in your model for what you want them to appear in the legend. This way, the signal will appear in the dedicated "Named Signals" section in SLRT App Generator: After selecting the signal from the "Named Signals" section and adding it to your app, the App Designer code for the SLRT connectLine() function will look like the following:
hInst.connectLine(app.myAxes, {'MySignal'});
So instead of using connectLine() and passing by block path and port ID, the instrumented signal name is passed to connectLine() instead. This way, the legend will just show the name of the signal.
To use a different signal label for a signal that is already named, you can make a second dummy signal branched from it like below with a Signal Copy block:
Workaround for bus signals:
For bus signals, the workaround is to create lines of scalar signals for each signal that you want to observe, and add a signal label: The corresponding code is:
hInst.connectLine(app.myAxes, {'MySig1', 'MySig2'});