how to save as .jpeg the result on axes including the colormap and color bar in GUI MATLAB

4 views (last 30 days)
Hi,
I want to ask how can I save the pcolor data type I got on the axes including the colormap that I had changed. Also the color bar. I have read the matlab documentation if I'm using the copyobj function, it will not copy the figure properties. So far, Im using the code as follow:
% --- Executes on button press in save_select.
function save_select_Callback(hObject, eventdata, handles)
% hObject handle to save_select (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
newfig1 = figure('Visible','off');
image=copyobj(handles.image_axes, newfig1);
saveas(image,'Tomogram.jpeg');
% Update handles structure
guidata(hObject, handles);
Its only save the pcolor image in jet (default) color.
This is the code for my pcolor image in the push button callback function for reference:
function lbp_select_Callback(hObject, eventdata, handles)
% hObject handle to lbp_select (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%each projection e1 till e16 from COMSOL in cell form :EachProj
singleProj=load('EveryProjection.mat');
SP=singleProj.EachProj; %SP=single projection
% ---------- Dot product to get each pairing projection -----------
i=1;
for i=1:16 %eliminate NAN values for each projection,e1 to e16
e=SP{1,i};
d=isnan(e);
e(d)=0;
SP{1,i}=e;
end
for i=1:16;
m1=SP{1,i};
for j=1:16
m2=SP{1,j};
c=m1.*m2; % Do the element multiplication to get Ei,j
E{i,j}=c;
end
end
%-------- Total Map/ Weight Balanced Map----------------------------------
WBMap = zeros(128);
for n=1:16;
for m=1:16;
WBMap = WBMap + E{n,m}; %%%Add coding for WBMap..x perlu load file WBMap yg buat cara panjang
end
end
%------------- Normalize each pair projection,NormEi,j--------------------
for i=1:16;
for j=1:16
N{i,j} = E{i,j}./WBMap;
end
end
%%-------------------- LINEAR BACK PROJECTION(LBP)-----------------------
disp('Displaying Tomogram...');
Resolution = 128; % --- IMAGE PIXEL SIZE
sensorLoss=load('SensorLossE1110mm.mat'); % load sensor loss file
Attenuate_xy=sensorLoss.SLe1110mm;
DispMap = zeros(Resolution); %view = 1;
for Tx = 1:16;
for Rx = 1:16;
DispMap = DispMap + (Attenuate_xy(Rx,Tx) * N{Rx, Tx}); %%%coding for getting LBP
end
end
% ----- DISPLAY TOMOGRAM RESULT--------------------------------------------
pcolor(DispMap, 'Parent',handles.image_axes);
shading interp;
getMax = max(DispMap(:)); % get max value in DispMap
caxis([0, getMax])
colormap (hot) % set color map to hot colour
colorbar
% update data
guidata(hObject,handles);
Thus, could anybody guide me how to code so that I can save the pcolor image including the figure properties? Thank you.

Answers (1)

Walter Roberson
Walter Roberson on 30 Jan 2016
I recommend that you install the export_fig File Exchange contribution, and invoke it on your (original) axes.

Community Treasure Hunt

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

Start Hunting!