How to change axes during a for cycle?

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 Kommentare

Jan
Jan am 1 Okt. 2015
I do not understand the question. In the first sentence the axes is is visible. But in the second sentence, you do not want to make it visible. Then you want to use "the new axes" - which new axes? What do you mean by "reference coordinate system"? For which new plots?
Mr M.
Mr M. am 1 Okt. 2015
Ok. Lets see an example: I want a figure with x-asis from 1:10 and y-axis from 1:5. In the first step I want nothing on the figure (only the white background) just the axes shown. After this initialization, I want to draw for example squares. In each step for simplicity I want to use the same command: fill([0 0 1 1],[0 1 1 0],'r'); to draw a square. But I want to change the coordinate system or axes? so the square appears at different location. For example I want to change the axes origin to position: 1,1 instead of 0,0 (relative to the previous axes or absolute to the background figure), so the next square appears shifted.
Joseph Cheng
Joseph Cheng am 1 Okt. 2015
the the main question is why not adjust the fill() and keep the axis the same to get the same shifted square result.
Jan
Jan am 1 Okt. 2015
Bearbeitet: Jan am 1 Okt. 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. am 1 Okt. 2015
Fill is an example, but I would like to use plot, bar, hist, etc. Please help me in the primary question.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Jan
Jan am 1 Okt. 2015
Bearbeitet: Jan am 1 Okt. 2015

0 Stimmen

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 Kommentare

Mr M.
Mr M. am 1 Okt. 2015
yes, I know hot to change properties, what I dont know how to use axes, what does it mean, I cannot figure out, how to solve the problem above, see the example above in the comment. So I dont know how to use it and which order. I have to care about child and parent properties?
Jan
Jan am 1 Okt. 2015
Bearbeitet: Jan am 1 Okt. 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. am 2 Okt. 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)

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Line Plots finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 1 Okt. 2015

Kommentiert:

am 2 Okt. 2015

Community Treasure Hunt

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

Start Hunting!

Translated by