How to move around subplots generated by sbiopredictionci?

I don't know if I accidentally changed some plotting configuration, but in the past weeks I have been having an issue with the subplots generated by sbiopredictionci. I can edit the data normally in the subplots and I can delete subplots as I wish, but for some reason I can't move the subplots around in the Figure window. It's like they have been fixed in place somehow.
Is this configurable?
Thanks!

7 Comments

I tried both, but still running into some issues. Can you help again?
Trying the first method, I have this error:
Assigning to 12 elements using a simple assignment statement is not supported. Consider using comma-separated list assignment.
Error using reshape
Product of known dimensions, 4, not divisible into
total number of elements, 1.
4 is the number of ResponseNames I have in the PredictionConfidenceInterval object. I am not sure what is causing it, though. Ideas?
Thanks!
Actually, the first method worked when I used the
set(findobj(fh, 'type', 'axes'), 'Parent', fh, 'Units', 'normalized');
instead of the less compact script. Thanks!!
Sorry, Rebeca,
For the first method, there was a mistake in the code I sent you - please try the edited version of the step-by-step code in the Answers section. You can also combine everything into a single line of code, which might be easier to use once you know how it maps to the different steps:
set(findobj(fh, 'type', 'axes'), 'Parent', fh, 'Units', 'normalized');
Let me know if this unblocks you. I will look into the error you are encountering with the second workaround and get back to you.
Priya
Hi,
I hope the issue is resolved, but I just mention that I just added a comment to this MATLAB Answers post that mentions selectivePlotCI. This comment contains updated code for selectivePlotCI that works for prediction confidence intervals computed in MATLAB releases R2023b or later.
-Florian
@Rebeca Hannah Oliveira, with Florian's updated function, the second workaround should also work for you now.

Sign in to comment.

 Accepted Answer

Hi, Rebeca,
Starting in R2023b, SimBiology uses tiledlayout to manage the layout of axes of its plots. This change improves the performance of rendering and resizing plots. Tiled layout also supports setting a global title, x-label and y-label. However, it does constrain your axes position to be fixed to a grid.
As a manual workaround, you can reparent the axes directly to the figure and delete the tiledlayout object. This will allow you to manually move and resize the axes again. For example, where ci_pred is a PredictionConfidenceInterval object:
% Create the plot
fh = ci_pred.plot();
% Get all the axes in the figure
allAxes = findobj(fh, 'type', 'axes');
% Reparent the axes to the figure
[allAxes.Parent] = deal(fh);
% Set the axes units to 'normalized' so they will resize with the figure
[allAxes.Units] = deal('normalized');
% Delete the unused tiled layout manager
delete(findobj(fh, 'type', 'tiledlayout'));
Note that you can combine the middle three actions into a single line of code for convenience:
set(findobj(fh, 'type', 'axes'), 'Parent', fh, 'Units', 'normalized');
Also, please see the following post for a discussion of how to change the layout of your plot programmatically: https://www.mathworks.com/matlabcentral/answers/367190-how-modify-the-number-of-rows-and-columns-of-plots-when-i-plot-a-sbiopredictionci-object.
I hope one of these workarounds help. Please reach out with any further questions.
Best,
Priya

More Answers (0)

Communities

More Answers in the  SimBiology Community

Products

Release

R2023b

Community Treasure Hunt

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

Start Hunting!