figure: move line to second y-axis

조회 수: 17 (최근 30일)
Andreas
Andreas 2020년 5월 18일
답변: Ameer Hamza 2020년 5월 18일
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".
  댓글 수: 2
darova
darova 2020년 5월 18일
Can you manually scale the data?
Andreas
Andreas 2020년 5월 18일
How do you mean that? Currently I have to plot volume flow and pressure drop of a pipe network vs. valve setting.
pressure drop and volume flow on the same scale does not work (unbalanced). How could scaling help?

댓글을 달려면 로그인하십시오.

답변 (1개)

Ameer Hamza
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.

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by