Unable to Print Graph being Generated in axes.handle4

조회 수: 1 (최근 30일)
Avinav Kumar
Avinav Kumar 2021년 3월 9일
댓글: Avinav Kumar 2021년 3월 9일
Hi,
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
plot(handles.axes4)
The above code i want to use to print graph generated in handles.axes4. But i am unable to do so. What will be the solution. I have attached a screenshot, for pushbutton5 (reffered as Print) where on clicking the pushbutton5 graph should plot. Thanks
  댓글 수: 9
Avinav Kumar
Avinav Kumar 2021년 3월 9일
Thanks a lot Walter. It is working. Just one more query. The entire GUI is getting saved but i wanted to save only graph which is geeting plotted in axes4.
Avinav Kumar
Avinav Kumar 2021년 3월 9일
I am not getting accept this answer option. But this is accepted answer. Thanks

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2021년 3월 9일
You posted that you tried
saveas(handles.axes4)
but you would need
[file,filepath] = uiputfile('*.jpg');
if ~ischar(file); return; end %user cancel
filename = fullfile(filepath, file);
saveas(handles.axes4,filename);
However, to save just the axes, you should use the new https://www.mathworks.com/help/matlab/ref/exportgraphics.html (R202a or later), or use the File Exchange contribution export_fig if you have an older MATLAB than that.
  댓글 수: 1
Avinav Kumar
Avinav Kumar 2021년 3월 9일
Thanks a lot Walter. I could extract the figure / image.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by