0

Get your subplots the way you want it with subplotHelper

 1 year ago
source link: https://blogs.mathworks.com/pick/2022/07/01/get-your-subplots-the-way-you-want-it-with-subplothelper/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Get your subplots the way you want it with subplotHelper » File Exchange Pick of the Week

Did you know that subplot can be used to create non-uniformly distributed axes? For example,
figure
subplot(3,3,1), text(0.5,0.5,"1","FontSize",24,"Color","red")
subplot(3,3,2), text(0.5,0.5,"2","FontSize",24,"Color","red")
subplot(3,3,3), text(0.5,0.5,"3","FontSize",24,"Color","red")
subplot(3,3,[4 7]), text([.5 .5],[.25 .75],["7" "4"],"FontSize",24,"Color","red")
subplot(3,3,[5 9]), text([.25 .25 .75 .75],[.25 .75 .25 .75],["8" "5" "9" "6"],"FontSize",24,"Color","red")
potw_subplothelper_1.png
As you can see, the third input argument to subplot can be a vector that specifies the corners of the rectangular region. It's not too complicated, but it does require some thought to figure out the appropriate parameters.
subplotHelper helps you get these parameters by allowing you to interactively select the layout. Here's the tool in action.
Very nice!

Check out tiledlayout (introduced in R2019b)

On a related note, if you're using R2019b or later, check out the new function tiledlayout and nexttile. These give you a bit more control and additional capabilities for axes layout over subplot. One of my favorite features of tiledlayout is the "flow" option that automatically adjusts the layout based on the figure size and shape.
Of course, tiledlayout can have non-uniform distribution, just like with subplot.

Comments

Give subplotHelper a try, and let us know what you think here.

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK