how to change colour of dots on graph in matlab

To change the color of dots on a graph in MATLAB, you can use the scatter function and specify the desired color for each point. Here's an example:

main.m
% Create some data
x = 1:10;
y = [2 4 6 8 10 8 6 4 2 0];
colors = [1 0 0; 0 1 0; 0 0 1; 1 1 0; 0 1 1; 1 0 1; 0.5 0.5 0.5; 0 0 0; 0.75 0.25 0.25; 0.25 0.25 0.75]; % Specify colors for each point

% Plot the graph
scatter(x, y, 100, colors, 'filled'); % Use the scatter function and specify the colors and size of dots
317 chars
8 lines

In this example, the colors array specifies the color for each point. Each row in the colors array represents a point, and each column represents the RGB values for that point's color. You can specify any valid RGB color values between 0 and 1.

By using the scatter function with the 'filled' option, the dots will be filled with the specified colors.

You can customize the colors to your preference by modifying the colors array.

related categories

gistlibby LogSnag