# Set MarkerFaceColor to plot with multiple items.

351 vues (au cours des 30 derniers jours)
Lizeth Andrea Gómez Ochoa le 17 Déc 2021
Commenté : Chunru le 23 Mai 2023
I wanna fill with color the figure 'o' of my plot, but I know how. My plot is this way:
plot(X1,Y1,LineSpec1,...,Xn,Yn,Linespecn)
And I tried with this:
plot(X1,Y1,'om','MarkerFaceColor','k',...,Xn,Yn,LineSpecn)
But it didn't work.
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Chunru le 17 Déc 2021
n = 10;
x1 =(1:n)';
y1 = rand(10, 1);
x2 = (1:n);
y2 = rand(10,1);
% Use separate plot when you need to specify additional properties
plot(x1, y1, 'om-', 'MarkerFaceColor','k');
hold on
plot(x2, y2, 'ob:', 'MarkerFaceColor','r');
##### 3 commentairesAfficher 1 commentaire plus ancienMasquer 1 commentaire plus ancien
Brian le 17 Mai 2023
If I want to use the automatic color sequencing that plot provides, I cannot use an explicit color for MarkerFaceColor. How do I get the face to fill with the automatically cycled color?
Chunru le 23 Mai 2023
Assign the line color (in defaut color order) to MarkerFaceColor
n = 10;
x1 =(1:n)';
y1 = rand(10, 1);
x2 = (1:n);
y2 = rand(10,1);
% Use separate plot when you need to specify additional properties
p = plot(x1, y1, 'o-');
p.MarkerFaceColor = p.Color;
hold on
p1= plot(x2, y2, 'o:');
p1.MarkerFaceColor = p1.Color;

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Scatter Plots dans Help Center et File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by