Search code examples
matlabplotmatlab-figurescatter-plotscatter

Why are the scatterplot colors in MATLAB R2021a different?


I have installed Matlab R2021a, and when I run the command scatterplot for a vector, I get a figure as below:

R2021a - result

I mean black and yellow. However the default colors in older versions is as follows:

older versions - result

I mean the colors are white and blue.

My concern, I need my MATLAB shows the colors of the figure as shown in older version, I mean with white and blue colors.


Solution

  • The behavior indeed changed in R2021a as mentioned in the release notes:

    Visual appearance updates to plots generated with eyediagram and scatterplot functions.
    The eyediagram and scatterplot functions now provide black plot backgrounds by default.

    You can change the colors as desired by you by modifying the properties of axis/figure as shown below:

    %Taking the example from the documentation
    d = (0:63)';
    s = qammod(d,64);
    scatterplot(s);
    
    %Modifying the colors
    h=gca;                %Axis handle
    h.Title.Color='k'     %Color of title
    h.Children.Color='b'; %Color of points
    h.YColor='k';         %Y-axis color including ylabel
    h.XColor='k';         %X-axis color including xlabel
    h.Color ='w';         %inside-axis color
    h.Parent.Color='w'    %outside-axis color
    

    Without modification, we get this:

    before

    After modification, as desired, we get this:

    after