Combine two existing Matlab figs, into one figure with two y axes (keeping the respective axes titles and units)

2 views (last 30 days)
Hi, I have two Matlab figs, although not the original data in a *.mat file, which share the same 'x' axis, but not 'y' (one curve in each figure). I wish to combine Fig. 2 into Fig, 1, but have two y axes, with the original axis titles and units. I also wish to keep the original symbols and the same color map for the curves from the two pictures. What is the easiest way to do that?
Thank you.
  4 Comments
dpb
dpb on 5 Aug 2018
Edited: dpb on 5 Aug 2018
I think I mistyped/misnamed the new world replacement for the deprecated plotyy :)
-- it's |yyaxis| instead. Sorry...
ADDENDUM
I did just try a 'spearmint; took the example for two axes and created two figures instead of the L/R axes. Then with some rigamarole to get all the necessary handles to the lines that are children of their respective axes,
yyaxis left
hAxL=gca;
copyobj(hL1,hAxL)
yyaxis right
hAxR=gca;
copyobj(hL2,hAxR)
did bring over the line colors, markers, etc., ... I didn't experiment with the titles and all, but the basic operations seems to work ok.
Erez
Erez on 6 Aug 2018
Edited: Erez on 6 Aug 2018
Thanks a lot, but unfortunately it still doesn't work. Ok, I've copied your exact code. I also had a mistake, I am using Matlab 2014b, so maybe this version is not familiar with this syntax. The error message is:
"Undefined function 'yyaxis' for input arguments of
type 'char'.
Did you mean:
>> axis left "
Perhaps there is a way to download the function `yyaxis' and add it into my script?

Sign in to comment.

Answers (0)

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!