figure: move line to second y-axis
17 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
when using matlab figures, is there a way to move only one signal/line to a second y-axis?
plotyy
and
yyaxis
is no solution for me, because the figures are derived from the simulation data inspector and thus without workspace data.
I would have expected to find such controls in the property inspector, similar to the functionality in excel, where you can choose "show on secondary axis".
回答(1 个)
Ameer Hamza
2020-5-18
The following example shows how to transfer signals from 1 axes to other axes. First, create an example axes with two signals
fig = figure;
ax = axes();
hold(ax);
p1 = plot(1:10);
p2 = plot(rand(1,10));
Now you can transfer p2 to the right axes using
yyaxis(ax, 'right');
p2_new = copyobj(p2, ax);
delete(p2);
Note that if you don't already have handles of lines (p1, p2) then you can use findall() to get them.
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!