Plot a line and point marker with color unspecified

26 次查看(过去 30 天)
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.

采纳的回答

Steven Lord
Steven Lord 2017-6-30
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', '-')

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by