How can I create a plot with two different yaxis, with one of them inside the figure?

1 view (last 30 days)
I'd like to produce a plot that has two different yaxis, sharing the same xaxis, but with one of them inside the plot itself. Thus, this script behaviour should be similar to the behaviour of yyaxis left/right, but the right axis should be inside the figure. For clarity's sake, I'd like to have an output similar to this (obtained with Paint):
I tried with subplot, but I was not successful. Do you have any suggestion to obtain such a graph?

Accepted Answer

Jan
Jan on 20 May 2022
Edited: Jan on 20 May 2022
Simply create 2 axes:
FigH = figure;
Axes1H = axes(FigH, 'Position', [0.1300 0.1100 0.5 0.8150], ...
'Box', 'on');
Axes1H = axes(FigH, 'Position', [0.6300 0.1100 0.2750 0.8150], ...
'Box', 'on');
The axes can overlap also:
FigH = figure;
Axes1H = axes(FigH, 'Position', [0.1300 0.1100 0.7750 0.8150]);
Axes1H = axes(FigH, 'Position', [0.6300 0.1100 0.2750 0.8150]);
Adjust the XTicks accordingly to avoid overlapping labels.

More Answers (0)

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!