One Plot two different y-axis, how to scale second y-axis?

조회 수: 10 (최근 30일)
MPi
MPi 2018년 9월 15일
댓글: jonas 2018년 9월 15일
How can I plot one data set with two different scales, where the second (right) y-axis has no linear relation to the left one.
I only want to see the blue dots where instead the second (right) y-axis is scaled this points.
To reverse the axis I used set(gca, 'YDir','reverse') so far though it seems with yyaxis this issue is not solvable.
How can I do this?
  댓글 수: 3
MPi
MPi 2018년 9월 15일
E.g. the orange dot at x = 0 is around ~157 instead showing the orange dot I want to see only the blue one and the orange axis should be scaled due to this. Means the orange axis should start with 157 for example.
Or for the second point at x = 100 where blue y = 100, I don't want to see a orange don't instead I want the second axis scaled to that. Though the hard thing is, that there is no linear relation between the left and the right axis.
jonas
jonas 2018년 9월 15일
편집: jonas 2018년 9월 15일
OK, I think I get it. You want the y-value of the orange dots to be represented on the second yaxis as ticks? Bear in mind, the right yaxis will still be linear, just showing uneven ticks (?)

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

채택된 답변

jonas
jonas 2018년 9월 15일
편집: jonas 2018년 9월 15일
Probably not what you want, but perhaps one step closer:
x=[0 100 300 500 800 800]
y1=[0 100 180 200 255 260]
y2=[155 124 115 79 42 40]
yyaxis left
plot(x,y1,'o')
yyaxis right
plot(x,y2,'o','color','none');
set(gca,'ytick',flip(y2))
set(gca,'ylim',[min(y2) max(y2)])
set(gca, 'YDir','reverse')
  댓글 수: 10
MPi
MPi 2018년 9월 15일
This hack works perfectly fine for me! Thank you again!
jonas
jonas 2018년 9월 15일
My pleasure!

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by