MATLAB: How to change the colors of the plots displayed by the Scope block in Simulink

graphgraphicshandlemodifyparameterparameterssimulink

I would like to have an automatic way in which I can change the color of the plots that I see in all my Simulink Scope blocks.

Best Answer

In order to change the colors of the plots displayed by Simulink Scope blocks, you can modify the "ColorOrder" property of the axes that displays the data. To do this, you need to obtain the handle to the axes, which can only be done after turning on the "ShowHiddenHandles" property of the MATLAB root object. Here is an example that changes the colors for all Scope blocks in a particular model:
scopes = find_system(gcs,'blocktype','Scope')
shh = get(0,'ShowHiddenHandles');
set(0,'ShowHiddenHandles','On');
for i = 1:length(scopes)
set_param (scopes{i},'open','on');
a = findobj (gcf,'type','axes')
set (a,'ColorOrder',[1 0 0;0 1 0;0 0 1;0 1 1]);
end
set(0,'ShowHiddenHandles',shh);
NOTE: Simulink does not support manipulating graphics properties using the Scope or Signal Viewer handle. When manipulating any graphics properties, do not change or alter the structure of the scope. For example, you should not delete any of the graphical objects (text, axes, menus, etc) in the scope as this could lead to unstable behavior.