Plot a line and point marker with color unspecified

37 vues (au cours des 30 derniers jours)
Jacqueline
Jacqueline le 30 Juin 2017
For any other marker,
plot(x,y,'-o')
plots a line with the marker identifier. However,
plot(x,y,'-.')
plots a dashed-dot line. As a workaround, I usually specify the color, '-k.' to force the plot to have a solid line with point markers. However, this messes up the usual order of colors when plotting multiple data sets. Is there a way to programmatically plot a solid line with a point marker while not specifying the color?
Thanks.

Réponse acceptée

Steven Lord
Steven Lord le 30 Juin 2017
You can be explicit that you want to change the Marker property of the line created by plot.
% Sample data
x = 1:10;
y = x.^2;
% Plot with 'o' Marker
figure
plot(x, y, '-', 'Marker', 'o')
% Plot with '.' Marker
figure
plot(x, y, '-', 'Marker', '.')
You can specify any of the modifiable properties of the line returned by plot in this way. If you want to be completely explicitly clear, you could use both LineStyle and Marker.
figure
plot(x, y, 'Marker', '.', 'LineStyle', '-')

Plus de réponses (0)

Catégories

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

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by