フィルターのクリア

Copying a heatmap (in a subplot) to clipboard

2 ビュー (過去 30 日間)
Jason
Jason 2019 年 9 月 30 日
コメント済み: Jason 2019 年 10 月 1 日
Hi, I have 4 subplots of which the 1st one is a heatmap. I would like to automatically put this into clipboard and have tried the following/
ax1=subplot(1,4,1)
h = heatmap(T,'data1','data2','ColorVariable','data5');
h.Colormap = cool;
%h.FontSize = 6
h.XLabel = 'X position (um)';
h.YLabel = 'Y position (um)';
h.CellLabelFormat = '%.1f'
%Copy to clipboard
currAxes = gca
newFig = figure('visible','off');
newHandle = copyobj(currAxes,newFig);
print(newFig,'-dmeta');
%print('-clipboard','-dmeta')
However this doesn't seem to work, is what I want to achieve possible?
thanks
Jason

採用された回答

Adam Danz
Adam Danz 2019 年 9 月 30 日
You can copy the heatmap handle on to a new figure. Here's a functional demo with comments.
% load built-in matlab data
load patients
tbl = table(LastName,Age,Gender,SelfAssessedHealthStatus,...
Smoker,Weight,Location);
% Plot a scatter plot & heatmap
fh1 = figure();
subplot(2,1,1)
plot(tbl.Age, tbl.Weight,'bo')
subplot(2,1,2)
h = heatmap(tbl,'Smoker','SelfAssessedHealthStatus');
% Create new figure and copy heatmap to figure
fh2 = figure();
h2 = copyobj(h,fh2);
% reposition heatmap axes
h2.Position = [0.13 0.11 0.65 0.80];
  3 件のコメント
Adam Danz
Adam Danz 2019 年 9 月 30 日
編集済み: Adam Danz 2019 年 9 月 30 日
In the code from your question, it appeared to me as if you are trying to copy the heatmap to another figure. You mentioned that it's not working but didn't provide more detail.
To copy the figure on the clipboard,
print(fh2, '-dmeta')
Where fh2 is the figure handle.
If the problem persists, please provide the full error message or a detailed description of what's not working.
Jason
Jason 2019 年 10 月 1 日
Thankyou

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeColormaps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by