How to save the axes include x-axis and y-axis

조회 수: 3 (최근 30일)
han han
han han 2020년 8월 9일
댓글: han han 2020년 8월 9일
I got a .jpg through my code, but it doesn't have x-axis and y-axis scales.
What can I do to make my saved jpg have these scales?
function pushbutton1_Callback(hObject, eventdata, handles)
[FileName, PathName, ~] = uiputfile( ...
{'*.jpg'},...
'Save as');
new=FileName(1:end-4);
x = rand(10,1);
y = rand(10,1);
axes(handles.axes1)
scatter(x,y,'^');
axis([0 1 0 1])
H = getframe(ax);
imwrite(H.cdata, [new, '.jpg'])
like [0 0.2 0.4 0.6 0.8 1]

답변 (1개)

Sudheer Bhimireddy
Sudheer Bhimireddy 2020년 8월 9일
Try this, after your axis() line:
ax=gca;
ax.XTick = 0:0.2:1;
ax.XTickLabel = 0:0.2:1;
ax.YTick = 0:0.2:1;
ax.YTickLabel = 0:0.2:1;
  댓글 수: 5
Sudheer Bhimireddy
Sudheer Bhimireddy 2020년 8월 9일
Circling back to your original approach of using imwrite, try the following:
H0 = getframe(ax);
H1 = frame2im(H0);
imwrite(H1, [new, '.jpg'])
han han
han han 2020년 8월 9일
The same, and no scale

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

카테고리

Help CenterFile Exchange에서 Labels and Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by