Azzera filtri
Azzera filtri

gplotmatrix compatability with tiledlayout

1 visualizzazione (ultimi 30 giorni)
Adam Watts
Adam Watts il 11 Mar 2022
I am trying to combine tiledlayout with gplotmatrix because of the ease of adding legends directly above multiple plots. Using a simple plot I can and commenting out the gplotmatrix line, I can get the legend that is directly north of the plot. However there appears to be compatibility issues with gplotmatrix as I get a warning "Property assignment is not allowed when the object is empty. Use subscripted assignment to create an array element."
Ideally, gplotmatrix would allow the legend to behave like tiledlayouts with ease of adding xlabels, ylabels, titles, and legends. However I have found that getting a center legend above the gplotmatrix is rather difficult.
randMat = randn(25, 5);
VarNames = "Var " + string((1:5))';
catNames = [repmat('Class A', 20, 1); repmat('Class B', 5, 1)];
catTable = table(catNames, 'VariableNames', {'Class Type'});
MyDataTable = array2table(randMat, "VariableNames", VarNames);
MyDataTable = [MyDataTable, catTable];
tt = tiledlayout(1,1);
nexttile
% plot(randi(100, 10, 1)) Works with legend due north
gplotmatrix(MyDataTable{:, 1:5}, [], MyDataTable.("Class Type"), [],[], [], true, 'stairs', VarNames)
lgd = legend();
lgd.Layout.Tile = 'north';

Risposte (0)

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by