to use tiledlayout to arrange pre-existing axes ?

20 次查看(过去 30 天)
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?

采纳的回答

Bjorn Gustavsson
Bjorn Gustavsson 2021-12-9
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 个评论
Bjorn Gustavsson
Bjorn Gustavsson 2021-12-9
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Object Programming 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by