Plot a line and point marker with color unspecified

45 ビュー (過去 30 日間)
Jacqueline
Jacqueline 2017 年 6 月 30 日
回答済み: Steven Lord 2017 年 6 月 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 Center および File ExchangeLine Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by