0
votes

I am drawing several graphs in the same plot in matlab by using the command, hold on. My problem is that I am drawing points with big markersize on top of some of the graphs, and I would like theses points to have some specific color. Only what happens is that some of them will take some color and some others take another color, my guess is that the colors of my points get mixed with the colors of the graphs on top of which i put them. Is there a mean to ask matlap to overwrite whatever is under my points so that they get the color I assign to them?

Example:

x= 0:1:10;

plot(x,x,'r',x,-x,'b','linewidth',2)

hold on

plot(5,-5,'.',10,10,'.','MarkerColor',[0,0.5,0],'Markersize',24)
hold on
plot(5,5,'.',10,-10,'.','MarkerFaceColor',[0,0.75,0],'MarkerSize', 24)

Imagine that the curves are much more complicated than theses simple lines so no way to start having fun cutting them each time I want to represent a point... Now my problem is that I would like that the points 5,-5 and 10,10 to have the same color. Namely 0 0.5 0 dark green. but their color get mixed depending on which line they lie. If I specify their color as '.g' I don't get this problem, but the problem is that I got too many points to get covered by the few number of colors that are labeled by letters (eg 'r' 'b' 'k' etc..).

Thankfully

1

1 Answers

0
votes

Note that 'MarkerColor' doesn't exist, so I suppose it's a type and you meant 'MarkerFaceColor', just like in the other plot.

Then, hold on once is enough, you don't need to repeat it every time you want overlap another plot.

Finally, I suggest you simply use 'Color' instead of MarkerFaceColor. This should display your dots with the wanted color.

x= 0:1:10;
plot(x,x,'r',x,-x,'b','linewidth',2)
hold on
plot(5,-5,'.',10,10,'.','Color',[0,0.5,0],'Markersize',24)
plot(5,5,'.',10,-10,'.','Color',[0,0.75,0],'MarkerSize', 24)

dots