gpt4 book ai didi

matlab - 在使用 plotyy 创建的现有线上方/下方绘制一条线

转载 作者:太空宇宙 更新时间:2023-11-03 19:57:51 26 4
gpt4 key购买 nike

我正在运行这段代码:

t = linspace(0, 10, 1000);
y1 = 2*t;
y2 = 3*t;
figure;
[ax, h1, h2] = plotyy(t, y1, t, y2);
set(h1, 'LineWidth', 4);
set(h2, 'LineWidth', 4);
hold on;
h3 = plot([5, 5], [0, 3000], 'LineWidth', 6, 'Color', [0.6, 0.6, 0.6]);

创建此图的原因:

enter image description here

请注意垂直灰色线是如何出现在蓝线 (y1) 上方但在绿线 (y2) 下方的。

如何在其他两条线的上方或下方绘制灰线?

最佳答案

我看到两个选项:

一个。通过将灰色线移动到由 plotyy 命令创建的第二个轴

来向前移动灰色线
set(h3,'parent',ax(2));

B.通过重新排列蓝线和灰线的顺序,将灰线放在底部轴。

chld = [h1 h3];
set(ax(1),'children',chld); %# reorders the two lines so that the gray line is in back.

关于matlab - 在使用 plotyy 创建的现有线上方/下方绘制一条线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9674121/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com