In Matlab 2025a, how do I hide a plot trace

I often plot three or more traces on one plot, sometimes using both right and left axes. It is useful to be able to temporarily hide one or more traces, to inspect the remaining trace(s) more easily. With older versions of Matlab, I did this using the plot browser. How do I do it in Matlab 2025a?

1 comentario

Mathieu NOE
Mathieu NOE el 2 de Oct. de 2025
funny, I never used the plot browser ...
but I use since long time this excellent plot alternative from Paul Mennen : pltSig - File Exchange - MATLAB Central

Iniciar sesión para comentar.

Respuestas (2)

Benjamin Kraus
Benjamin Kraus el 2 de Oct. de 2025

0 votos

There are several options, but I think the closest to the plot browser is to use the Property Inspector:
1. Click on the "Format" tab.
2. Click on "Select & Plot Edit"
3. Click on "More Propertes"
4. Once the property inspector is open, show the tree at the top of the property inspector:
5. Now you can right-click on each line and choose to "Show" or "Hide" the line.

2 comentarios

Benjamin Kraus
Benjamin Kraus el 2 de Oct. de 2025
Editada: Benjamin Kraus el 2 de Oct. de 2025
Another option, which requires a little more effort to setup, but works pretty nicely once it is setup, is to leverage the ItemHitFcn on the Legend. For more details on the ItemHitFcn, you can see the documentation for the property.
plot(magic(5))
legend(ItemHitFcn=@(~,e) set(e.Peer, Visible=~e.Peer.Visible))
This adds a callback that runs when you click on entries in the legend. The callback will set the visibility of the "Peer" to the opposite of the current visibility, basically allowing you to click on the legend to toggle line visibility on/off.
Sven
Sven el 22 de Mayo de 2026 a las 13:44
While it is nice that there are some workarounds, it is a shame that the plotbrowser option is not available anymore. We routinely generate figures with dozens of lines that are turned on/off for comparison. The plotbrowser provides checkboxes, allows to scroll through the list of lines. This is simply not possible with the alternatives. We hope that version 2024 will work for a long time, or that the plotbrowser comes back in a future matlab version.

Iniciar sesión para comentar.

Image Analyst
Image Analyst el 3 de Oct. de 2025
Editada: Image Analyst el 3 de Oct. de 2025
If you want to show or hide plotted curves programmatically (say when a use checks or unchecks a checkbox on your GUI), you can get the handle to the plot and then set it's Visibility property. Here is a short demo:
hp1 = plot(rand(1, 20), 'b.-', 'MarkerSize', 25);
uiwait(msgbox('Click OK to create a second plot.'))
hold on;
hp2 = plot(rand(1, 20), 'r.-', 'LineWidth', 3);
% Programatically hide the first plot temporarily.
uiwait(msgbox('Click OK to have plot 1 disappear temporarily.'))
hp1.Visible = "off"
uiwait(msgbox('Click OK to have plot 1 appear again.'))
hp1.Visible = "on"

Categorías

Más información sobre Environment and Settings en Centro de ayuda y File Exchange.

Productos

Versión

R2025a

Preguntada:

DH
el 2 de Oct. de 2025

Comentada:

el 22 de Mayo de 2026 a las 13:44

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by