How to change axes during a for cycle?

3 views (last 30 days)
Mr M.
Mr M. on 1 Oct 2015
Commented: Mr M. on 2 Oct 2015
I would like to make a figure and show the axes and tics without any plot at this moment. After that I would like to plot several things using a for cycle and change the axes in every cycle, but do not make it visible, so I dont want to replot tics and labels, but use the new axes as a reference coordinate system for the new plots. How to do this? How to define and use new axes invisible, and how to set its position relative to the original figure?
  5 Comments
Jan
Jan on 1 Oct 2015
Edited: Jan on 1 Oct 2015
I agree with Joseph: This seems to be a job for the coordinates of the FILL-object. Creating a new AXES each time is an indirection without any benefit.
Mr M.
Mr M. on 1 Oct 2015
Fill is an example, but I would like to use plot, bar, hist, etc. Please help me in the primary question.

Sign in to comment.

Answers (1)

Jan
Jan on 1 Oct 2015
Edited: Jan on 1 Oct 2015
You create an axes, which is not visible, by defining its property 'Visibile' as 'off'. Setting the position relative to the figure is done by using 'normalized' 'units'. This is explained in the documentation of the axes command.
[EDITED] The X- and Y-limits can be defined by the set command also.
  3 Comments
Jan
Jan on 1 Oct 2015
Edited: Jan on 1 Oct 2015
The children are defined automatically and the parent is either the current figure or the specified figure or uipanel, repsectively.
I still do not see the problem you are asking for. Please explain the purpose of what you want to achieve.
Mr M.
Mr M. on 2 Oct 2015
Lets see the following example:
% code 1: fill([0 0 1 1],[0 1 1 0],'r'); xlim([0 3]); ylim([0 3]); hold on; fill([1 1 2 2],[1 2 2 1],'r');
Instead of code 1, I would like to use code 2 (please do not ask why, I think it is possible and easy, but I cannot figure out)
% code 2: fill([0 0 1 1],[0 1 1 0],'r'); xlim([0 3]); ylim([0 3]); hold on; % what to write here to achieve the same result? fill([0 0 1 1],[0 1 1 0],'r');
So the question is what to write before the second fill command.
I've tried lots of things, for example this:
% code 3: fill([0 0 1 1],[0 1 1 0],'r'); xlim([0 3]); ylim([0 3]); hold on; fill([0 0 1 1],[0 1 1 0],'r'); axes('Position', [1/3 1/3 1/3 1/3],'Visible','off');
and this
% code 4: fill([0 0 1 1],[0 1 1 0],'r'); xlim([0 3]); ylim([0 3]); hold on; axes('Position', [1/3 1/3 1/3 1/3],'Visible','off'); fill([0 0 1 1],[0 1 1 0],'r');
... and lots of other things. I've tried to play with Xtick, XLim, etc. But all results are far away from the wanted one.
I wander for example that the Position property of axes can be used before and after the second fill command also, but XTick or XLim affect the plot just in the second case (after the fill command)

Sign in to comment.

Categories

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

Community Treasure Hunt

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

Start Hunting!