Main Content

Simulink.sdi.getLegendPosition

Get legend position in Simulation Data Inspector

Since R2023b

    Description

    example

    pos = Simulink.sdi.getLegendPosition returns the position pos of the legend in the Simulation Data Inspector.

    Examples

    collapse all

    Simulate the model vdp.

    mdl = "vdp";
    sim(mdl);

    Open the Simulation Data Inspector.

    Simulink.sdi.view

    Select signals from the table on the left to view them in the Simulation Data Inspector. By default, the legend is located outside of the subplot at the top-left.

    The legend is located outside the plot area at the top-left. The signals in the legend are aligned horizontally.

    Use the Simulink.sdi.setLegendPosition function to move the legend inside the subplot and to the right.

    Simulink.sdi.setLegendPosition("InsideRight")

    The legend is located inside the subplot in the upper right corner. The signals in the legend are aligned vertically.

    You can confirm the location of the legend programmatically using the Simulink.sdi.getLegendPosition function.

    Simulink.sdi.getLegendPosition
    ans = 
    'InsideRight'
    

    You can also use the Simulink.sdi.setLegendPosition function to remove the legend.

    Simulink.sdi.setLegendPosition("None")

    The legend is no longer visible.

    Output Arguments

    collapse all

    Legend position in the Simulation Data Inspector, returned as one of these values:

    • "OutsideTop" — Outside the subplot area on the top-left

    • "OutsideRight" — Outside the subplot area on the top-right

    • "InsideTop" — Inside the subplot area on the top-left

    • "InsideRight" — Inside the subplot area on the top-right

    • "None" — No legend

    When the legend position is "OutsideTop" or "InsideTop", the software lists legend entries horizontally. When the legend position is "OutsideRight" or "InsideRight", the software lists legend entries vertically.

    Version History

    Introduced in R2023b