Skip to content

Figures in MATLAB

Hierarchy of Figure objects.

v2_gobjects_top-01

Commonly usefull plot options

Take the following example:

plot(x, y, '-', DisplayName='blabla', HandleVisibility='off')
  • DisplayName: Label for the data. Calling legend() will create thee legend using the DisplayName.
  • HandleVisibility: If off the series will not appear in the legend.

Select a different color theme

Before ploting:

set(groot,'defaultAxesColorOrder',turbo(7));

A list of built-in themes here.

Reset color order

Reset color order so MATLAB goes back to the initial color. Good when trying to match colors (e.g., of points and lines) in same plot.

set(gca,'ColorOrderIndex',1)  % reset color order for plot

or

ax = gca;
ax.ColorOrderIndex = 1;  % reset color order for plot