to use tiledlayout to arrange pre-existing axes ?

19 views (last 30 days)
I would like to arrange otherwise created axes-objects with there lines axis limits colors legend etc. on a figure.
The handling of axes as tiledlayout does seems comfortable. But nexttile generates a new axis.
What was a suggested way, to inserte pre-existing axis-objects into the pattern generated with tiledlayout?
Copyobj might copy just individual line-handles into the nexttile-generated axis, but not all the line-objects.
Getting the position-properties of the nexttile-axis and using set, to assign it to the previously designed axis might be another idea of start-concept
What would be a suggested way?

Accepted Answer

Bjorn Gustavsson
Bjorn Gustavsson on 9 Dec 2021
When I need control of the figure layout and design I always save away the handles to "everything" - which makes it at least somewhat convenient(*) to adjust all their properties. In your case seems to me that you ought to save away the axes-handles when creating them, with nexttile or subplot:
tiledlayout(m,n)
for i1 = 1:m*n
axh(i1) = nexttile;
ph{i1} = plot(randn(2*i1)); % more plottery-functions_et_al
end
set(ph{3},'linewidth',2)
set(axh(2),'XColor','m')
That should be something similar to what you want to achieve?
(*) somewhat convenient - since I still have to set things, very convenient would be to only have to think "I'd like that in blue" and it would be done...
HTH
  7 Comments
Bjorn Gustavsson
Bjorn Gustavsson on 9 Dec 2021
The way I have always understood this is that you only plot things to/into an axes. If none exists one is generated, alternatively one can generate an axes first (either with axes, subplot or nexttile). If one has an axes-handle, one can get and set its properties.
If you want to get the positions and whatever other properties that and axes get from nexttile then I don't see why you couldn't simply create that/those axes and then plot whatever you need into them.
You could plot into some arbitrarily generated axes, then move them far out of the way such that they don't get anihilated by you nexttile call, then use copyobj to copy everything you want - but this seems to be a very steep price to pay for you to keep your intuition of first creating the plots into some nebulous place and then showing the plots in a later defined axes. To me it seems far simpler to you in the long run (2 days++) to modify your understanding to accept that in matlab you plot into an axes, if none is specified or doesn't exist it will be generated and then plotted into.

Sign in to comment.

More Answers (0)

Categories

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

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!