version 1.1.0.0 (21.4 KB) by
Harry Lee

Add multiple y-axes to plots. zoomable with zoom modification.

**Editor's Note:** This file was selected as MATLAB Central Pick of the Week

Adds multiple axes to plots using addaxis.m. Automatically adjusts axes to accomodate as many axes as you want.

Add more plots to any added axes with addaxisplot.m

Add y-labels to any of the axes with addaxislabels.m

All plots zoom together. A small modification to the zoom function allows all of the added axes to update with zoom.

zoom modifications for R11.1 and R14SP2 are included.

Usage is almost exactly like the plot command, see the help for addaxis.m for examples.

Harry Lee (2021). addaxis (https://www.mathworks.com/matlabcentral/fileexchange/9016-addaxis), MATLAB Central File Exchange. Retrieved .

Created with
R2010a

Compatible with any release

**Inspired:**
myaxisc, addy_axis, plotNAx, addaxes.m v1.1 (Sep 2009), Axis XX

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

Start Hunting!Create scripts with code, output, and formatted text in a single executable document.

Frederik ReeseDoes anyone know why it doesn't work with bar- graphs? Can you recommend another funktion ?

Andres GomezI don't know why it does't work. I'm using MatLab R2019a

Gernot Steinerseung gi kimjasongrigjasongrigdoes not work on R2018b

Diego VeraThanks a lot! is just what i needed

For those who have the problem with "cololorord", look the answers below.

Daniel AgramonteFrankly, I believe that a Github should be made for this. I like this function quite a bit, but frankly, it's outdated and in need of some TLC. There are also some basic functions that are quite lacking, such as recoloring and resizing of axes. It is possible to do these functions with MATLAB's built in functionality, but it is simply not implemented seamlessly with base functionality.

Zarah ZhengIf changing the colorord to ColorOrder doesn't work for you (my version is 2017a and somehow changing the code doesn't work for me), Alysia Herr has suggested a great solution. And when you use the function, now put [h,a]=addaxis(x,y); instead of addaxis(x,y), then call the handles to adjust your axis properties.

lvnriccardo scandrogliousing Matlab R2019b - not working

figure

x = 0:.1:4*pi;

plot(x,sin(x));

addaxis(x,sin(x-pi/3));

Error using matlab.graphics.axis.Axes/get

There is no colorord property on the Axes class.

Error in aa_splot (line 13)

cord = get(gca,'colorord');

Error in addaxis (line 135)

hplts = aa_splot(varargin{:});

Charlie WeiAthina KontopoulouThis fuction is working fine for one plot per added axis. Can someone tell me how I can add 2 plots per axis?

Samuel MontalvoDid not work for me.

Yuyun YangI'm trying the example in the addaxes.m function description, however getting an error "Out of memory. The likely cause is an infinite recursion within the program." What could be the problem?

Abhijit DasI have used both addaxis and myaxisc and for my case, I was able to create plots without any issues. Great work!

Jason Nicholsonmyaxisc looks promising. I think will try it before forking addaxis.

Jason NicholsonI don't think Harry has updated this in years. I think it is time to fork it, put it on Github, and patch it.

Anna TuzovaAdeel YousufThe function file is really nice. I wish there were same for x-axis & both were part of MATLAB plot() package

NabaThanks for this great tool. But I'm having a problem setting the axis limit on the added axis. Does anybody have some ideas?

Arun KumarIs the datavalue cursor issue solved? I see few have mentioned this issue below but I couldn't find a solution.

LogjamThank you for such a well-written function! Easy to use and thanks also to those who mentioned the ColorOrder fix below.

VijayRegarding my yesterday's query (25 May 2020) I found a temporary solution. I just replaced cord(mod([0:6]+1,7)+1,:) with 'default' in aa_splot.m file. This gives the same color to the line and axis. But for the first plot (as the plot option in example code) color should to be defined manually.

VijayHi Harry, This is a great function.

I got a little issue here. The lines' colors aren't matching with the axes colors. (1) How can I fix it? (2) Also, can I make the axes to a default color like black (as I want to have the lines with different markers) ?

Jeppe FærgemandZongwei YaoHi,the function is great！

There is a small issue. In the 2020a version, the 'colorord' has been replaced by 'colororder', so aa_splot.m may need to be adjusted.

KatharinaThe function works really well! However, the axis label and ticks always get cut off, so I cannot save the figure because one would not see the labels. I can of course stretch the windows but then the whole plot would stretch with it. Anyone an idea what I do wrong?

Debora MartogiFor those on Matlab 2018b and beyond, if you are having an error for (line 13) found this on the comment below by Kartikeya Gupta.

1) Open the aa_splot.m file

2) change 'colorord' with 'ColorOrder' --> I do this by doing CTRL+F to replace every 'colorord' with 'ColorOrder'

If it does not work, most likely you did not replace every 'colorord'

I hope this is helpful!

This is a great grahing tool. Thank you for sharing!

Michael HornIn 2018a I get the following errors when plotting the commented example in "addaxis.m"

Error using matlab.graphics.axis.Axes/get

There is no colorord property on the Axes class.

Error in aa_splot (line 13)

cord = get(gca,'colorord');

Error in addaxis (line 135)

hplts = aa_splot(varargin{:});

Error in test_addaxis_plotting (line 3)

addaxis(x,sin(x-pi/3));

Jakob WeisAdded output variables h and hplt for axis and line handle output:

function [h,hplt] = ...

Added the following line to the last if-environment for the axis handle output (both into the "if" and "else" parts):

h = axhand(end);

Added the following if-environment into the nested for-loop of the last if-environment (only in the "else" part), in order to (visually) remove the offset between the first addaxis (right-hand y-axis) and the primary axis:

if I == 1

set(axhand(indshift(I)+1),'Color',[1 1 1];

end

Jakob WeisLooks like the comment with my edits got deleted...

Jakob WeisAwesome little function! Cheers for that. I added an axis and line handle output, and (visually) removed the offset between the first addaxis (right-hand y-axis) and the primary axis. See code down below.

KubraDHi Dear Authorized, this function is very usefull and i congratulated you wholeheartedly. I used this function in my matlab gui. But datacursor (in figure) not working with addaxis. Please help me. I will be waiting your answers with curiosity.

WONMOOK LEEIs there no solution to the problem below? T_T

- When you insert a "Data Tips" to verify the value of data added with addaxis function, the Y value always are of the main plot and not of the the added axis

Rene LabounekAndre AlmeidaDear Harry Lee, your addaxis function is great and very useful, I've applied in a data analyze that I'm doing that I need to plot more than 3 Y axis on the same plot and it worked fine, but I've got a problems that I'd like you help to solve:

Problem 1 - When we pan vertically the plot the scales added using the addaxis function does not update (axes are not linked with main scale plot) and if we zoom, after pan vertically and after "Restore View" you will see that the scales stay non coherent with the original data plotted. I've tried to use the linkaxes function but I couldn't realize how.

Problem 2 - When you insert a "Data Tips" to verify the value of data added with addaxis function, the Y value always are of the main plot and not of the the added axis. For example if you have Y1 (0 to 10) values and you added a new axis using Y2 (500 to 1000) values, if you insert a "Data Tip" on Y2 plot you will see values of Y1.

Problem 3 - The "Home button" that appear o on the upper right corner of the plot used to "Restore View" does not work. It is just possible to do this function open Tools>Restore View

I'm using Matlab R2019a on Windows 10.

I've spend some weeks trying to find the solution for this problems but I have not success. I would appreciate if you or the Matlab community.

PS: The problems can be reproduced using application example on the comments of the addaxis function.

addaxis (https://www.mathworks.com/matlabcentral/fileexchange/9016-addaxis)

Ehsan SadighradLukas SchaubSuper useful as soon as the aa_splot.m file is edited by changing all "colorord" to "ColorOrder" 4.95/5

Max MurphyError using matlab.graphics.axis.Axes/set

There is no colorord property on the Axes class.

Error in aa_splot (line 18)

set(gca,'colorord',cord(mod([0:6]+1,7)+1,:));

Anyone with this problem, please change 'colorord' (or 'colororderer') in aa_splot.m to 'ColorOrder' (at least, that worked for me).

MichaelOI hqve the same problem as the others:

Error using matlab.graphics.axis.Axes/set

There is no colororderer property on the Axes class.

Error in aa_splot (line 18)

set(gca,'colororderer',cord(mod([0:6]+1,7)+1,:));

Error in addaxis (line 135)

hplts = aa_splot(varargin{:});

Any help please!!

ram vRene LabounekI have the same issue as Kartikeya Gupta with R2018b version.

There is no colorord property on the Axes class.'

Gabriel Bischofok I think i got it.

if you want to change the size you can do:

set(gca, 'Position', [ 0.10 0.1100 0.5 0.5150])

Ellyn GrayDoes anyone know why the zip file won't open? I've had no proble downloading other packages today. My computer says "Error 1 -- Operation not permitted"

hima nikLiam SmithWhen using GUIDE you have to make sure your Axes uses 'normalized' for the units (GUIDE sets this to 'characters'): set(handles.axes1, 'Units', 'normalized');

Kartikeya GuptaIndex in position 1 exceeds array bounds (must not exceed 1).

Error in aa_splot (line 32)

set(gca,'Color',cord(mod([0:6]+1,7)+1,:));

Error in addaxis (line 124)

hplts = aa_splot(varargin{:});

Kartikeya GuptaI am also getting error 'Error using matlab.graphics.axis.Axes/get

There is no colorord property on the Axes class.'

I changed 'colorord' with 'ColorOrder' with reviews of sir Antino Rufo, but now I am getting error

Error using matlab.graphics.axis.Axes/get

There is no ColorOrderer property on the Axes class.

I am using MATLAB2018b

Vince ClementiGreat code. Is there a way to specify the direction of each axis? It seems that all values much increase going up the y-axis. However, I have data that both increase and decrease, and whenever I reverse the y-direction it essentially flips the entire plot. Thanks.

Antonio RufoFound the error. In the file 'aa_splot.m' you must replace everything that says 'colorord' with 'ColorOrder'. Everything works after that.

Antonio RufoI am using 2017b and i get the following error 'Error using matlab.graphics.axis.Axes/get

There is no colorord property on the Axes class.'

Nikolai PuumalainenIs there any way I can move one of the axes to be in another X position instead of at the ends?

Thanks

Manyi HoWhen I ran the following code:

semilogy(x1, y1)

addaxis(x2, Y2)

addaxis(x3, y3)

addaix(x4, Y4)

However the y scale in Y4 is messed up and didn't reflect the true value. When I change the semilogy to just plot(x1, Y1), then everything is fine. Any solution? Thank you!!

Wesley NeillI have been playing with a way to get all axis to one side or the other. It seems that there is no parameter to state which side of the graph you would like your new Y axis to show on. This makes for some pretty ugly graphing, in my opinion.

Chris MartinIt is working well for me. However, is there a way to control the offset of the axis? My output currently has two y-axes on one side, but they are more or less on-top of each other. I need to add sufficient spacing to include the axis titles and maintain readability.

Rebecca EllisI am getting this error still after following the comments

Error using matlab.graphics.axis.Axes/get

There is no ColorOrderer property on the Axes class.

Error in aa_splot (line 13)

cord = get(gca,'ColorOrderer');

Error in addaxis (line 135)

hplts = aa_splot(varargin{:});

Ichiro TeradaWorks beautifully after the fix stated in the comments!

SANGHYEOK LEEJulio FuentealbaWorking great on R2016a after applying Keller's 'colorord' to 'colororder' fix.

Darshan JainNovy FrancisHarsh SinghHarsh SinghI am getting wrong values for an added axis when I use the data cursor in the plot. Any ideas on how to rectify this?

Oliver FerdinandUsing R2016b, same problem occured using this set of functions.

Here´s our solution, rather simple changes are needed:

Look-up line "lastColor = get(oldplots(1),'colorord');", I guess its line 16.Change used property from "colorord" to "Color".

Details:

Problem occures when "addaxis.m" calls "aa_splot" in line 135 by "hplts = aa_splot(varargin{:});"

Structure "if" shall compare last used "Color" from variable "oldplots" with upcoming plot color due to "ColorOrder".

I´d furthermore suggest to change all remaining "colorord" to "ColorOrder" for more simple reading.

regards, Oliver

Sathyamoorthy Rhow to add our x and y axis values in program?

Robert BrockIs it possible to use area or scatter plots on these added axes?

Lei ZhengAlysia HerrWithin aa_splot, you can comment out the ' set(gca,'colororder',cord(mod([0:6]+1,7)+1,:)); ' (both times it appears) if Jessica Keller's fix doesn't work. Then change colors manually.

Create an axis and line handles by changing the very first line of the addaxis.m function to:

[h a]=addaxis(varargin)

And adding this line to the very end of the addaxis.m code:

if nargout>0, h = hplts, a = h_ax; end

Then you can adjust color of the line using the 'h' handle (i.e., h.Color='k') and adjust the color of the axis using the 'a' handle (i.e. a.YColor='k'.

Bob photonicsEven after changing colorord to colororder I still get this issue (2016a)

Index exceeds matrix dimensions.

Error in aa_splot (line 18)

set(gca,'colororder',cord(mod([0:6]+1,7)+1,:));

Error in addaxis (line 135)

hplts = aa_splot(varargin{:});

Bob photonicsError using matlab.graphics.axis.Axes/get

There is no colorord property on the Axes class.

Error in aa_splot (line 13)

cord = get(gca,'colorord');

Error in addaxis (line 135)

hplts = aa_splot(varargin{:});

It probably works well most of the time but I'm getting this issue (2016a)

Shahar GrossbardChristian AlbrechtHow can i change the fontsize of the additional axes?

Ingrid KeupersThe userdata in the axes handle is empty so I am unable to manipulate the different axes (e.g. set one axes reverse). How can I obtain the axeshandles of the different axes?

Alistair KeffenI'm getting this error:

Undefined function or variable 'getaddaxisdata'.

Error in addaxis (line 66)

axh = getaddaxisdata(cah,'axisdata');

Does anyone know how to get around this?

Luca RaimondiYep, on MATLAB R2017b, following the suggestion of Jessica Keller, it really works like a charm. Thank you!!!

KelvinThanks Jessica Keller for the tip on colorord!!

Jessica KellerIf u have the error: 'There is no colorord property on the Axes class. go into aa_splot and replace all colorord with colororder commands. it worked for me with 2017 version.

Alon Ohev - ZionI'm having problems with zooming the plot:

1. With a single click zoom, I zoom "all the way" in both axes.

2. With the rbbox I can zoom X-Axis partially, but Y-Axis "all the way".

3. Using "zoom ON" or "zoom XON", doesn't make a difference with the X-Axis zoom abilities.

4. I'm using R2014a

Pleas assist.

Alon Ohev - ZionTo be more precise:

1. With a single click zoom, I zoom "all the way" in both axes.

2. With the rbbox I can zoom X-Axis partially, but Y-Axis "all the way".

3. Using "zoom ON" or "zoom XON" doesn't make a difference. in X-Axis zoom abilities.

4. I'm using R2014a

Pleas assist.

clksThis is the error code:

Index exceeds matrix dimensions.

Error in aa_splot (line 18)

set(gca,'ColorOrder',cord(mod([0:6]+1,7)+1,:));

Error in addaxis (line 135)

hplts = aa_splot(varargin{:});

Error in two_plots (line 19)

addaxis(x,y3);

clksHi, the solution to the problem 'There is no colorord property on the Axes class. does not help me. Have you got an other suggestion?

René FrankeHi,

solution to the problem

'There is no colorord property on the Axes class.

Error in aa_splot (line 13)

cord = get(gca,'colorord');'

Go into the file aa_splot and replace 'colorord' with 'ColorOrder' (3 times).

This solved the problem for me.

polepositionNate Horntrying to understand how to use this code while importing excel data. right now i am running the example code and trying to understand what is happening. i get these errors.

Error using matlab.graphics.axis.Axes/get

There is no colorord property on the Axes class.

Error in aa_splot (line 13)

cord = get(gca,'colorord');

Error in addaxis (line 145)

hplts = aa_splot(varargin{:});

Error in addplottest (line 3)

addaxis(x,sin((x-pi)/3));

the code i am trying to relate it to is

Forward = xlsread('MATLABsheet','Forward','U3:AD18')

%1 is Forward, 2 is Radial, and # is Reverse (A=TDH B=BH C=eff%

x= Forward(:,1);

y1= Forward(:,4);

y2= Forward(:,7);

y3= Forward(:,10);

plot(x,y1);

addaxis(x,y2);

addaxis(x,y3);

addaxislabel(1,'one');

addaxislabel(2,'two');

addaxislabel(3,'three');

i dont understand the rest though

Nate HornAndrey OliveiraGreat file.

I was wondering if there is a way to set a variable to addaxis like we do to plot.

for example:

p1 = plot(t, data, 'displayname', 'Data1')

flavThank you for this, it works great! However I was looking for the same in X-axis. Is it possible to adapt it for the x axis ?

Another modification would be to stick the first added axis with the right side of the figure instead of leaving a small space. I would find it visually cleaner.

VidzJanapati JayaLakshmiAlHi,

How can I move the axis label along with the plot itself?

I have 2 different subplots with addaxis function, but their orientation does not match, so I need to set it manually

I can modify the axislabel, but the plot itself will not change

Kristyna KantnerovaGreat function!

Can I somehow change the number of ticks on additional axes please? Thanks.

wenzhu wangWhen I copy the figure to word, there will be a gray bar on the added y-axises, how can I remove them?

wenzhu wangThis is just what I need! Multiple axes and zoom in or zoom out.

MehmetWorks great! I just had to remove the colorcord variable and realated ones. It kept giving error for "exceeded matrix index". It worked just fine without it.I only used one extra y axis though.

Thanks

Ha SenHi,

I have updated to R2016a. By using addaxis I get this error, Could someone give an advice? I am trying to plot two bars and a line with the addaxis.

Error in addaxis (line 131)

hplts = aa_splot(varargin{:});

Error in bar_line (line 41)

addaxis (dn, ComMean(:,1));

JEREMIEThanks for this nice tool.

Is it possible to use addaxis to add an axis on x-axis ?

Thanks

AmyIs there a way to add multiple lines to the same axes? For instance, I have current, power, and voltage for 2 different things. I need 3 different axes but I want 2 lines per.

Ford CreightonIs there a way to compact the axes a little more horizontally? Having 5 or 6 axes causes the plot are to become small.

Also, any plans on tweaking for 2015a or 2015b?

Thanks for the great work.

MichMichelThanks a loooooooooooooot .... Plotyy sucks totally ! Resolve all the problem of 2d Axes, very very nice :)

Thank you so much.

Mikko PesolaI got it working with 2014b with following changes:

aa_splot.m:

Change 'colorord' to 'ColorOrder'

aadwindowresizefcn.m:

Change "if ax_manage" to

"if isa(ax_manage,'matlab.graphics.axis.Axes')"

JanGreat! Only on Matlab 2014a I had to rename in aa_splot.m "colorord -> ColorOrder".

Florian HaaseThe paths mentioned the readme.txt doesn't exists so I can't replace them by the files comes with the download.

AllanGreat work !!

Very Useful. Anyone knows how to reverse a specific y axis? With ax=plotyy() you select the axis ax(1) or ax(2) and reverse it with 'ydir' property. But with addaxis i'm not getting it.

KhanhThank you so much Harry. It is very useful. By the way, I want to plot with multiple x axes instead of y axes. May I know to modify your files to work as I want?

JohnFor some reason this function causes a figure with visible = off to become visible. I can't figure out why from the code. Any ideas?

EdwardGreat function. Having trouble with the legend display for a corner case. Does anyone have a solution to the following problem? http://www.mathworks.com/matlabcentral/answers/158068-hide-legend-entries-with-addaxis-function

EdwardJohnanswered my own question. use the function below to get a handle for the new axis, then adjust like so:

set(haxis2,'Position',[ 0.90 0.1100 0.001 0.8150]), modifiying the X location (.90) and the width .001).

ElisaAli HummosI needed to get a handle for the newly created axis to change its properties. I found it very helpful to edit the first line in the file addaxis.m to be:

function [h_ax] = addaxis(varargin)

so that the function returns a handle to the newly created axis.

Solid work. Thanks!

ZhenjiaMy error is always:

Index exceeds matrix dimensions.

Error in aa_splot (line 18)

set(gca,'colorord',cord(mod([0:6]+1,7)+1,:));

Error in addaxis (line 131)

hplts = aa_splot(varargin{:});

The size of cord is 1*3, not 7*3. Does any one meet this problem? Thanks.

RenatoHi Harry, great work. Thanks a lot.

I've been searching for a version which make possible to undo addaxis. It means, return to the before status. If I added 3 axis, when undo figure shows the original plot and 2 axis added, etc...

Do you know how can I do it?

Thanks

bayern scienceGreat program! But could it be improved such that we can plot the error bars together with the plots?

CharlesI apologize for accidentally rating this function with just one star yesterday, I didn't mean to do that, but I can't figure out how to edit my previous comment or rating.

I did get the code to work today, although I haven't really changed anything. So I don't know what the problem was exactly.

CharlesI just downloaded this function and when running the sample code, I get an error. I have no idea what's going on. Any thoughts?

Sample code:

x = 0:.1:4*pi;

plot(x,sin(x));

addaxis(x,sin(x-pi/3));

addaxislabel(1,'one');

addaxislabel(2,'two');

legend('one','two');

The error reads as follows...

"??? Undefined function or method 'setaddaxisdata' for input arguments of type 'cell'.

Error in ==> addaxis at 137

setaddaxisdata(cah,axh,'axisdata');

Error in ==> test at 3

addaxis(x,sin(x-pi/3));"

DanHas anyone answered Ian's question about making one of the axes log scale? I would like to know how to do this. Thanks!

Priyesh Gosaiolumide odeyemihi guys, I have been trying to find a way to put 2 right and 1 left y axes in the same legend box before I came across this code. I want to ask if it can put all my objects in one legend box. thanks waiting for your reply and how to go about it

TobiasGreat function!

For those of you who can not figure out how to make the zooming and panning working, here is a solution:

1. Open the addaxis.m and find these lines: "% plot in new axis to get the automatically generated ylimits

hplt = plot(varargin{:});"

2. Add the following code after "hplt = plot(varargin{:});" :

h_new = zoom;

set(h_new,'ActionPostCallback',@postcallbackzoom);

set(h_new,'ActionPreCallback',@precallbackzoom);

set(h_new,'Enable','on');

set(h_new,'Enable','off');

h_new=pan;

set(h_new,'ActionPostCallback',@postcallbackpan);

set(h_new,'ActionPreCallback',@precallbackpan);

set(h_new,'Enable','on');

set(h_new,'Enable','off');

3. Goto the end of 'addaxis.m' and add the followong code:

function precallbackzoom(obj,evd)

old(1:2) = get(evd.Axes,'YLim');

old(3) = evd.Axes;

ax = findall(obj,'type','axes');

ax = ax(ax~=evd.Axes);

leg = findall(obj,'Tag','legend');

if(~isempty(leg))

ax = ax(ax~=findall(obj,'Tag','legend'));

end

for i=1:length(ax)

old(i+1,1:2)=get(ax(i),'YLim');

old(i+1,3)=ax(i);

end

setappdata(obj,'OldAxes',old);

function postcallbackzoom(obj,evd)

old = getappdata(obj,'OldAxes');

new(1:2) = get(evd.Axes,'YLim');

d=(old(1,2)-old(1,1));

d1=(new(1)-old(1,1))/d;

d2=(new(2)-old(1,2))/d;

s=size(old);

for i=2:s(1)

d=old(i,2)-old(i,1);

set(old(i,3),'YLim',[ (old(i,1))+d*d1 , (old(i,2))+d*d2]);

end

function postcallbackpan(obj,evd)

set(obj,'WindowButtonMotionFcn','');

function precallbackpan(obj,evd)

ax = findall(obj,'type','axes');

ax = ax(ax~=evd.Axes);

leg = findall(obj,'Tag','legend');

if(~isempty(leg))

ax = ax(ax~=findall(obj,'Tag','legend'));

end

OldY=[get(gca,'YLim'),ax'];

set(obj,'WindowButtonMotionFcn',{@CallbackPan,obj});

setappdata(obj,'OldY',OldY);

function CallbackPan(hObject, eventdata, handles)

old = getappdata(hObject,'OldY');

new(1:2) = get(gca,'YLim');

d=(new(1)-old(1))/(new(2)-new(1));

for i=3:length(old)

d1 = get(old(i),'YLim');

d1_= d1(2)-d1(1);

set(old(i),'YLim',d1+d*d1_);

end

old(1:2)=new;

setappdata(hObject,'OldY',old);

4. That's it. Save your addaxis.m and enjoy zooming and panning. By the way you don't have the use the new zoom-functions (zoom modifications for R11.1 and R14SP2) provided with this function.

Tested on Matlab 2012b.

martijnGREAT!

but does somebody have the solution to the zoomproblem. The readme does not apply to me, since I use Matlab 2012.

If you know the solution, can you mail me? or drop it here? martijnvanhooff89@gmail.com

LONG SHENFloErik:http://www.mathworks.com/matlabcentral/newsreader/view_thread/292235, thank you erik!

Do anybody know how to zoom in AND scale the additional axis and not only the main axis?

FloThank you! Does anybody know, how to get the right data cursor values? I only get the y-values from the main-y-axis and not from the "addaxis" :(

eparksThanks! Can anyone tell me how to make it so that all additonal axes are added to the same side (opposite the original)?

RalphChad GreeneMatthias PospiechI want to use this tool because plotyy does not provide the option to show the axis ticks onl on one side.

But the second axis on the right side is separated from the actual plot area which looks wrong. And there are not handles, so I have no clue how to modify the style.

And there is no documentation neither in the readme nor in the files so that I can only guess what I have to call.

Any help is welcome to get around all the plotyy problem.

I was linked here from this question:

http://mathworks.com/matlabcentral/answers/28436-plotyy-with-sync-yaxis-tics-on-both-sides

P KI figured it out!

I just used the following commands:

AX=findall(0,'type','axes');

set(AX(2),'fontsize',16,'fontweight','bold')

P KGreat tool!

I had problems with plotyy and this function solved them all. There is only one thing which I would like to know: how can I change the line thickness, font size, font style on the new axis?

Would appreciate any help.

David CWorks well without zoom. Can someone comment on how to fix the zoom issue? I'm also not sure how to fix the zoom issue with linkzoom. Would appreciate any help.

hoanGreat tool!

Gaurav GuptaErikI've answered my own question:

http://www.mathworks.com/matlabcentral/newsreader/view_thread/292235

Best,

Erik

ErikGreat tool!

Unfortunately I could not get Data Cursor to find the value of a plot at a given point. I tried using Ben's modifications in conjunction with suggestions from http://www.mathworks.com/support/solutions/en/data/1-31Q3HK/?solution=1-31Q3HK to no avail.

Does anyone have a workable solution?

BenGreat tool! I'm surprised matlab doesn't handle this better natively (the way gnuplot does).

If you need to change linestyles, ytics, etc, just change the declaration of addaxis to:

function [hplts,h_ax] = addaxis(varargin)

This give you back the handle to the plot (as if you called h=plot(...)) and the axes (h=axes(...)) yourself.

The only outstanding issue I have is positioning a legend outside the plot...one solution might be to put all the new y-axes on the right (instead of alternating left/right), and then legend Location NorthEast, but I haven't tried that yet.

JohnJohnGreat Tool. Would be great if you could update the zoom functionality to more recent versions of MATLAB.

Ibrahim MGreat work!

Ibrahim M.

AndresA good multiple y-axis tool - it could be a bit more customizable. Use linkzoom ( http://www.mathworks.com/matlabcentral/fileexchange/21414 ) to avoid the zoom modification, or use Carlos Adrian's derivative (not tested yet).

IanHi, good tool.

Is it possible to make some of the additional axis use a log scale?

R. JHi. This is a great tool, I used it to create something more specific for my needs, so thank you for the ideas. I'm wondering if anyone has figured out a fix to a legend..I can only add to the legend the number of entries on the left side.

Amir Abbas ZadpoorWell done! Thanks a lot

R MeyerI think this is a very useful tool, but I guess I have some problems, because there are always error messages when I am using the zoom function. Perhaps it is because I am using the new version of MatLab but I do not know exactly because I have got the software since only a few days. Perhaps anybody can help me.

Wang Dinga very useful tool! Thanks a lot

Xianyu ZhaoVery useful, thanks a lot

Ian HowatGreat tool. Much^10 easier to use than plotyy. I agree with fabiano that a good modification would be to add multiple horizontal labels.

beckali abdeluseful, thanks

Patrick CelkaBest to fix the plotyy bug

fabiano busdraghinice tool. it is too shame that you can not add x axis, that is what i'm looking for

fabiano

A PohlmannI wanted to plot several curves and then add another one on a second y-axis. Tried plotyy and a few different tools and finally used this. Works ok if you don't mess with the orignal axis after adding the second. However, like some other tools it affects the size of subplots with some of them being slimmer or flatter, at random, which means you need to resize manually. Also the second axis is shifted slightly upwards. Other tools seemed to have similar problems, so I wonder whether that has some other cause (thus 4*). Using Matlab 7.0.4 on X11. Nevertheless I get usable graphs.

Neelu DBest among the posted on the website for adding secondary axis or zooming.

Andrey LoginovA nice tool thank you,

It is better not redefine splot.m which is used for plotting freq and time resp of system SYS,

Just rename to say splot__.m and use

Johannes KorsaweA really superb tool. Just what i was about to write on my own. Thank you!

I would just allow the user to choose the color of subsequent plots to the same additional axis (addaxisplot line 43) and not force them to be the same color as the axis.