What is the best way to transfer ALL the figure data to GUIDE (GUI) axes?

7 ビュー (過去 30 日間)
Mark Golberg
Mark Golberg 2021 年 3 月 11 日
コメント済み: Walter Roberson 2021 年 3 月 12 日
Hello,
I have the attached figure. It has:
  • xlabel & ylabel
  • xAxis & yAxis
  • title
  • grid
  • colorbar
  • surf (x,y,z) plot
I have handle to this figure in my code.
How can I insert ALL_OF_IT into my GUIDE (GUI) axes object?
I've tried to use copyobj, BUT:
  1. it copies only the surf map itself (with some wired change of colormap... but I suppose I can live with that).
  2. I don't know how to copy also all the other stuff (xlabel , title , color bar , etc...)
I've tried to save my figure as an image file (tiffn), and then load it (imread) onto the axes. It works basically, but it makes it in a very poor/small resolution.
Also, I want to be able to shift it back from my GUI axes to an external figure. So having it stored as an image on my axes is far from optimal (I'd like to be able to zoom, go over data points, etc...)
Any Ideas?
THANKS !!!

採用された回答

Walter Roberson
Walter Roberson 2021 年 3 月 11 日
fig1 = figure();
ax1 = axes(fig1);
[X, Y] = meshgrid(linspace(-5,5,50));
Z = tan(X).*cos(Y);
surf(ax1, X, Y, Z, 'edgecolor', 'none');
xlabel(ax1, 'x');
ylabel(ax1, 'y');
colorbar(ax1);
grid(ax1, 'on');
title(ax1, 'This is the original');
fig2 = figure();
copyobj(fig1.Children, fig2)
ax2 = gca(fig2);
title(ax2, 'This is the copy')
  6 件のコメント
Mark Golberg
Mark Golberg 2021 年 3 月 12 日
thanks, I've got exactly the result I wanted with the following code:
heatMapFigHandle = plotWM(heatMap_inputMat , '3 Sigma per site'); % my figure handle
heatMap_ax = gca(heatMapFigHandle);
cla(handles.twoD_axes , 'reset')
colormap(handles.twoD_axes , 'jet')
copyobj(heatMap_ax.Children, handles.twoD_axes);
colorbar(handles.twoD_axes)
Walter Roberson
Walter Roberson 2021 年 3 月 12 日
When you do that, the properties of the axes such as the labels and limits and axis direction and view do not copy over; also any special colormap customization will not get copied.

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

その他の回答 (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