2

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.

Sardar Usama
  • 19,536
  • 9
  • 36
  • 58
Zeyad_Zeyad
  • 250
  • 1
  • 8
  • 1
    Have you configured a dark theme? Maybe your window manager is inverting all colors? – Cris Luengo Jul 31 '21 at 14:36
  • @CrisLuengo but other ways of plotting show the figures as usual in white and black, for example when using commands plot and stem, the figures are shown in white and black. These colors are shown only when using the command scatterplot . . Plus, I have another matlab installed in the same PC, MATLAB2014b, it shows the scatterplot figure in white and black as usuall. – Zeyad_Zeyad Jul 31 '21 at 15:04
  • `scatterplot` is not a standard MATLAB function. `scatter` is. You are using some sort of custom plotting function. – Cris Luengo Jul 31 '21 at 15:08
  • My data is a vector of length 1000, when using `scatterplot(data)`, it directly plot the data, but when using `scatter(data)`, it gives be an error `Error using scatter (line 54) Not enough input arguments`. – Zeyad_Zeyad Jul 31 '21 at 15:30
  • It seems that you have complex numbers. In that case, you can also draw scatter plot with `scatter` using: `scatter(real(s), imag(s), 6, 'filled');` – Sardar Usama Jul 31 '21 at 19:21

1 Answers1

3

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

Sardar Usama
  • 19,536
  • 9
  • 36
  • 58
  • Thank you ! Is it possible to make this colors by default. It means when running `scatterplot(s)`, the black/white figures shows without running the code you provided every time. – Zeyad_Zeyad Aug 01 '21 at 04:28
  • 1
    @Zeyad It is possible but it'll require overwriting/overshadowing the original `scatterplot` function so I would recommend against that. If you want to write a code that gives you the same result in all versions, you can also run the code with modifications in the older versions and you will still get the desired result. Alternatively, you can obtain the same result with `scatter` e.g for the example shown in the code above, you can get similar result with `scatter(real(s),imag(s),6,'filled');` but `scatter` doesn't give those axis labels/title by default but this can be adjusted. – Sardar Usama Aug 01 '21 at 04:43