- https://www.mathworks.com/matlabcentral/answers/516657-global-legend-in-tiledlayout#answer_502561
- https://www.mathworks.com/matlabcentral/answers/505683-legend-positioning-in-tiled-chart-layout#answer_499216
- https://www.mathworks.com/matlabcentral/answers/542096-adding-a-global-legend-to-a-tiledlayout#answer_502549
Tiledlayout issues: colorbar title and spacing
40 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I've just discovered tiledlayout. At first, it seemed like a good solution to some of the difficulties with subplot, but I'm finding it comes with it's own difficulties. Here are two issues that I cannot resolve:
1.) If I want a common colorbar on the side for all plots, I cannot get the recommended approach to work: cb = colorbar; cb.Layout.Tile = 'east'; Could this be a version issue? I'm using 2019b. To get around this, I'm using the Position property of the colorbar. The problem now is that the colorbar title is always cut off. When I expand the figure horizontally, that leads to my second issue...
2.) The spacing between the tiles is not fixed, but seems to be proportional to the window size. So, when trying to see my colorbar title by expanding horizontally, the spacing between the figures all gets bigger despite setting it to compact or even none. Similarly, I find that the spacing is not fixed relative to the size of the plot in each tile. That is, when the x axis is longer, the horizontal spacing between tiles is smaller, but when the x axis is shorter, the spacing is large even when set to none.
UPDATE: I've noticed that the tile spacing remains at least more the same if the plot is stretched more or less equally in both directions to maintain its original aspect ratio.
I'd appreciate help on either of these issues if there are known solutions. Thanks.
0 commentaires
Réponse acceptée
Adam Danz
le 23 Oct 2020
Modifié(e) : Adam Danz
le 24 Oct 2020
"At first, it seemed like a good solution to some of the difficulties with subplot, but I'm finding it comes with it's own difficulties."
True. However, tiledlayout much younger than subplot and still in development.
"1.) If I want a common colorbar on the side for all plots..."
Well, you're in luck if you're able to upgrade to r2020b because this release supports a common colorbar as you describe it. (see release notes). Colorbar and legend positions can be set to 'east','west','north',or 'south'.
tiledlayout(2,2)
nexttile; nexttile; nexttile; nexttile
cb = colorbar;
cb.Layout.Tile = 'east';
Other examples
"2.) The spacing...."
In r2020b we are still unable to set 'Position', 'InnerPosition', 'OuterPosition', or 'ActivePositionProperty' for objects in a TiledChartLayout. However, the improvement mentioned above still helps with the problem you're describing. Colorbar and legend position is more flexible in r2020b.
As for earlier versions, you'll have to use subplot().
5 commentaires
Adam Danz
le 16 Juin 2022
Great question.
> Does the common colorbar takes into account different colorbar limits of other plots or does it just take the colorbar limit of last plot?
The colorbar responds to the colormap and color limits of the axes/tile it is assigned to. In my demo, it is assigned to the last axes.
> do I have to mention clim after each titled plot
Yes. If you want the colorbar to represent all axes, then all axes should share the same colormap and clim.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Subplots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!