how to format a graph so that data point varies if..............
1 view (last 30 days)
Jack Shannon on 2 Feb 2021
Edited: Jack Shannon on 2 Feb 2021
Plots have an option to set the color using either a string or an RGB triplet. You can get the default color order for a figure using the syntax get(gca,'colororder'). You can reset this color order, but if you want to manually control the color of each element of your figure it's best to get/create your color order and then explicitly set the color of each plot you make.
Not sure this is what you're looking for, but here's a simple example. You have two different values of x, so I'll just use the second one:
colors = get(gca,'colororder'); % matrix where each row is an RGB triplet
plot(z,x,'k-') % plot your data
for i = 1:numel(z) % loop over values of z
plot(z(i),x(i),'o',... % create a marker at point i
'color',colors(i,:),... % set the color of the marker border
'MarkerFaceColor',colors(i,:)); % set the face color of the marker
This creates the following plot: