Plot a line and point marker with color unspecified

33 Ansichten (letzte 30 Tage)
Jacqueline
Jacqueline am 30 Jun. 2017
Beantwortet: Steven Lord am 30 Jun. 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.

Akzeptierte Antwort

Steven Lord
Steven Lord am 30 Jun. 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', '-')

Weitere Antworten (0)

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by