Label Every Other Point In a Plot
조회 수: 6 (최근 30일)
이전 댓글 표시
Say I were to do a plot as such
scatter(x,y)
How would I label every other point. For example, if there were 7 points. How should I go about labeling 1,3,5,7? Would I use a for loop? Or check if each point is odd?
Thanks all.
댓글 수: 0
답변 (1개)
Walter Roberson
2022년 3월 5일
See https://www.mathworks.com/help/matlab/creating_plots/create-line-plot-with-markers.html#bvcbmlx-1 -- plot() with 'MarkerIndices'
Provided, that is, by "label" you mean "put a marker"
If you mean put a text point, then
%data for demonstration
x = rand(1,7);
y = rand(1,7);
%the work
scatter(x,y)
hold on
text(x(1:2:end), y(1:2:end), string(1:2:length(x)).')
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
