Can't save figure that contains subplots and a legend

12 vues (au cours des 30 derniers jours)
Thomas Keefe
Thomas Keefe le 24 Fév 2020
Commenté : raym le 27 Fév 2021
I need a figure that uses most of the area for a heatmap, and then has subplots of bar graphs on the side. I am doing this by creating a uipanel for my heatmap, and then a smaller uipanel to hold all of the bar graphs. The following example shows the figure that I want, but when I save it I get the following error:
Error using alternatePrintPath
Dimensions of arrays being concatenated are not consistent.
Error in alternatePrintPath
Error in print (line 83)
pj = alternatePrintPath(pj);
Error in saveas (line 181)
print( h, name, ['-d' dev{i}] )
Error in mre (line 18)
saveas(fig, 'test.png');
The problem has something to do with the legend. Also, if we don't plot the heatmap, the error goes away. Here is the code. I am using R2019b.
fig = figure;
heatmap_panel = uipanel('Position', [0, 0, .7, 1]);
heatmap_data = magic(10);
my_heatmap = heatmap(heatmap_panel, heatmap_data);
bars_panel = uipanel('Position', [.7, 0, .3, 1]);
subplot(2, 1, 1, 'Parent', bars_panel);
bar_data = [.2, .4, .4; .3, .3, .4]';
my_bar = bar(bar_data);
my_legend = legend({'group1', 'group2'});
saveas(fig, 'test.png');

Réponse acceptée

Thomas Keefe
Thomas Keefe le 17 Fév 2021
Mathworks fixed it in 2020b.
  1 commentaire
raym
raym le 27 Fév 2021
the problem is at heatmap, which is not a real figure object.
Even if a single heatmap image object cannot be saved by saveas

Connectez-vous pour commenter.

Plus de réponses (1)

Sai Sri Pathuri
Sai Sri Pathuri le 28 Fév 2020
I have brought this issue to the notice of our developers. They will investigate the matter further.
  3 commentaires
Jaisav Bajoria
Jaisav Bajoria le 17 Fév 2021
I have encountered a similar issue with 2019b. The same code seems to work for 2018b. As this is an internal function, I request MATLAB to suggest a solution. Thanks and appreciate it.
Thomas Keefe
Thomas Keefe le 17 Fév 2021
They fixed it in 2020b

Connectez-vous pour commenter.

Catégories

En savoir plus sur Data Distribution Plots dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by