how to plot two y axes with different zeros?

Hi all
I want to have a plot similar to the attached figure.
It should have 2 y-axes, but the right one is shifted in position instead of having it from the original zero
the x-axis is the same.
Could anyone help?
Much appreciated.

6 件のコメント

dpb
dpb 2020 年 5 月 13 日
Forgot the attachment...best fo use the colored figure/image icon and attach the image to do so...
But, look at documentation for yyaxis -- it can more than likely do all you need...
Lilya
Lilya 2020 年 5 月 13 日
i upload it now.
would appreciat if you check it
dpb
dpb 2020 年 5 月 13 日
Have you tried anything at all? As noted yyaxis will give you two y axes and you could set the x-axis origin to 'origin' and ylimits such as to move the RH x-axis to a location that suits.
Or, this could be also done by creating a second axis and setting the 'Position' property to the location of the top of the first after reducing its height by half.
Or you could start with subplot(2,1,1) and subplot(2,1,2) and adjust their 'Position' properties to suit.
Lilya
Lilya 2020 年 5 月 13 日
yes I did try that but the problem is to shift the RH y axis plot to not be overlapped with the LH y axis plot.
dpb
dpb 2020 年 5 月 13 日
Be a little creative...try
yyaxis right
ylim([-20 20])
yt=yticks;
yticks(yt(yt>=0))
and see what you get...
Lilya
Lilya 2020 年 5 月 13 日
Thanks a bunch!! it works.

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLine Plots についてさらに検索

タグ

質問済み:

2020 年 5 月 13 日

コメント済み:

2020 年 5 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by