How to set the matlab heatmap properties to all heatmaps without repetition?

1 回表示 (過去 30 日間)
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2020 年 4 月 7 日
回答済み: Walter Roberson 2020 年 4 月 10 日
h = heatmap(folder_name_cells,folder_name_cells,Mat_Linear,'ColorScaling','log','MissingDataColor','1.00,1.00,1.00',...
'GridVisible','off');
colormap(flipud(colormap('summer')));
I need to plot several heatmaps. How to set above properties (like colormap, cloring scale, ...) once with no need to repeat with each individual heatmap?

回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 4 月 10 日
You can copyobj(h, target_axes) to create a copy of h with all properties intact. Then you would set about 15 or so properties of the cloned object to adapt it to the data for the second heatmap. You could do that with a single call to set(), if you were sufficiently familiar with the meanings of the properties.
... I just counted, and my visual estimate of 15 properties was very close!
But, hey, setting "only" 15 properties manually is better than setting 4 properties, right?
Have you considered the possibility of just toasing the repeated option into a cell array, like
opt = {'ColorScaling','log','MissingDataColor','1.00,1.00,1.00',...
'GridVisible','off'};
and then using
h = heatmap(folder_name_cells,folder_name_cells,Mat_Linear, opt{:});
This does not meet your stated goal of not needing to repeat the properties for each heatmap, but I suspect that it would be sufficient for your purpose.

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by