I am trying to do a tiledlayout for MATLAB boxplots. My code is:
tiledlayout('flow');
boxplot(randn(10,5));
nexttile;
boxplot(randn(10,5)+5);
nexttile;
boxplot(randn(10,5)-6);
nexttile;
boxplot(randn(10,5));
But I always get the below warnings
Warning: Unable to set 'Position', 'InnerPosition', 'OuterPosition', or
'ActivePositionProperty' for objects in a TiledChartLayout
> In boxplot>renderLabels/setLabelappdata (line 3012)
In boxplot>renderLabels (line 2913)
In boxplot (line 407)
Any clues please?

 Akzeptierte Antwort

Sai Sri Pathuri
Sai Sri Pathuri am 26 Mai 2020

1 Stimme

The boxplot function sets the position of axes (If the axes are not UI axes -> line 3012) and according to the warning, it can not be set for tiled layout. This might be the reason for the warning. If you do not want the warning to show up, you may use
warning('MATLAB:handle_graphics:Layout:NoPositionSetInTiledChartLayout','off')
And for all the plots to be shown, use nexttile before first plot. Refer this example.
tiledlayout('flow');
nexttile;
boxplot(randn(10,5));

4 Kommentare

Benoit Espinola
Benoit Espinola am 17 Jun. 2020
That (exception in behaviour for boxplot with tiled layouts compared to other basic matlab plotting functions) is terrible programming from Mathworks' side.
Babak Zandi
Babak Zandi am 30 Jun. 2020
I have also received this warning message. Such simple things shouldn't be an issue for a company like MathWorks.
Adam Danz
Adam Danz am 16 Apr. 2021
I agree that this should be considered a bug.
  • Boxplot documentation does not specify the type of axes to use and does not mention any problems with tiledlayout
  • Other graphics functions such as bar(), histogram(), contour(), and many more do not have any problems with tiledlayout axes
  • One simple solution could be to skip running the setLabelappdata function in boxplot when the axes are created by nexttile.
If there aren't plans to make the position properties of tiledlayout axes editable, this problem should be addressed IMO.
Bill Tubbs
Bill Tubbs am 22 Mai 2023
I have this problem. As well as the warnings I am seeing the following defects in the pdfs created by exportgraphics. Any idea if this is related to the warnings or a separate issue?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Adam Danz
Adam Danz am 30 Jun. 2020
Bearbeitet: Adam Danz am 16 Apr. 2021

2 Stimmen

As of r2020a, you can use the new boxchart() function which is a "stand alone visualization" version of the boxplot() function but with a limited subset of optional parameters.
The boxchart() objects can be plotted on the tiledlayout without a warning message.
% requires release >= r2020a
tiledlayout('flow');
nexttile;
boxchart(randn(10,5));
nexttile;
boxchart(randn(10,5)+5);
nexttile;
boxchart(randn(10,5)-6);
nexttile;
boxchart(randn(10,5));

Kategorien

Mehr zu Data Distribution Plots finden Sie in Hilfe-Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by