필터 지우기
필터 지우기

How can a draw a line between two points?

조회 수: 24 (최근 30일)
Sandy
Sandy 2014년 4월 3일
댓글: Sandy 2014년 4월 9일
I have a plot that looks like the one below. I want to make vertical lines that connect each individual pair of blue & red points. How can I do this?
PARTIAL CODE:
plot(x, average,'o', 'MarkerEdgeColor', 'b', 'MarkerFaceColor', 'b'); % Blue points
hold on
plot(x, average_2,'o', 'MarkerEdgeColor', 'r', 'MarkerFaceColor', 'r'); % Red points

채택된 답변

Kelly Kearney
Kelly Kearney 2014년 4월 3일
Assuming that x, average, and average_2 are all row vectors
axes;
hold on;
plot(x, average,'o', 'MarkerEdgeColor', 'b', 'MarkerFaceColor', 'b'); % Blue points
plot(x, average_2,'o', 'MarkerEdgeColor', 'r', 'MarkerFaceColor', 'r'); % Red points
plot([x;x], [average; average_2], '-k');
If the data are column vectors you'll have to transpose the arrays.

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2014년 4월 3일
편집: Azzi Abdelmalek 2014년 4월 3일
plot(x, average,'-o', 'MarkerEdgeColor', 'b', 'MarkerFaceColor', 'b');
hold on
plot(x, average_2,'-o', 'MarkerEdgeColor', 'r', 'MarkerFaceColor', 'r');
hold off

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by