在子图matlab中绘制两点之间的线

时间:2020-12-31 19:36:19

标签: matlab subplot

我想在两个子情节点之间绘制一条线,但我不知道如何指向它们。 我有这个想法,但它引发了错误。

plot(subplot(1,2,1),[1 2],subplot(1,2,2),[3 4]);

1 个答案:

答案 0 :(得分:0)

在子图之间绘制红线:

下面是使用 annotation() 函数绘制的一条线。此函数可以有多个输入属性,例如 arrowline,用于指示注释采用的形状。您可以通过调整下方的 XY 来编辑线的位置/坐标。

Red Line Between Subplots

clf;
subplot(1,2,1); plot([1 2]);
subplot(1,2,2); plot([3 4]);
X = [0.465,0.57];
Y = [0.48,0.48];

Line_Annotation = annotation('line',X,Y);
Line_Annotation.LineWidth = 3;
Line_Annotation.Color = 'red';

在两个子图点之间绘制一条红线:

Line Between Two Subplot Points

clf;
subplot(1,2,1); plot([1 2]);
subplot(1,2,2); plot([3 4]);
X = [0.282,0.792];
Y = [0.48,0.65];

Line_Annotation = annotation('line',X,Y);
Line_Annotation.LineWidth = 1;
Line_Annotation.Color = 'red';

使用 MATLAB R2019b 运行

相关问题