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 Center および File ExchangeLabels and Annotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by