how to get your x and y axis to skip every other tick mark?

13 ビュー (過去 30 日間)
Minka Califf
Minka Califf 2018 年 5 月 18 日
編集済み: Minka Califf 2018 年 5 月 19 日
I simply want the graph on the left to show '500' '600' '700' for the y axis and '9' '10' '11'for the x axis.
%data
data1 = [9.3 480; 9.7 501; 9.7 540; 9.7 552; 9.9 547; 10.2 622; 10.5 655; 11 701; 10.6 712; 10.6 708];
data2 = [16 9.8; 9 9; 12 9; 15 9.1;10 8.8; 11 8.7;7 8.4; 2 7.8; 5 7.9;1 7.6];
%make 2 figures
figure;
% add first plot in 2 x 1 grid
subplot(1,2,1);
scatter(data1(:,1), data1(:,2), '+', 'MarkerFaceColor', 'k');
ylabel('Engineering Doctorates');
xlabel ('Cheese Consumption');
box 'on'
axis square;
axis([8.5 11.5 450 750]);
% add second plot in 2 x 1 grid
subplot(1,2,2);
scatter(data2(:,1), data2(:,2), 'x', 'MarkerFaceColor', 'k');
ylabel('Kentucky Marriage Rate');
xlabel('Fishing Boat Drownings');
box 'on'
axis square;
axis([0 20 7 10]);
%ticks off
set(gca,'Ticklength',[0 0])
%white background
set(gcf,'color','w');
%correlation coefficient
r = corrcoef(data1(:, 1), data1(:, 2));
disp(r(1,2));

採用された回答

Rik
Rik 2018 年 5 月 18 日
You can set the XTick property of your axes:
data1 = [9.3 480; 9.7 501; 9.7 540; 9.7 552; 9.9 547; 10.2 622; 10.5 655; 11 701; 10.6 712; 10.6 708];
data2 = [16 9.8; 9 9; 12 9; 15 9.1;10 8.8; 11 8.7;7 8.4; 2 7.8; 5 7.9;1 7.6];
figure(1),clf(1)
scatter(data1(:,1), data1(:,2), '+', 'MarkerFaceColor', 'k');
ylabel('Engineering Doctorates');
xlabel ('Cheese Consumption');
box 'on'
axis square;
axis([8.5 11.5 450 750]);
set(gca,'XTick',9:11)
set(gca,'YTick',500:100:700)
  2 件のコメント
Minka Califf
Minka Califf 2018 年 5 月 18 日
Works great! Thank you!
Rik
Rik 2018 年 5 月 18 日
If it works, please mark it as accepted answer.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by