필터 지우기
필터 지우기

How to change xticks on a histogram?

조회 수: 81 (최근 30일)
Elliot Jenkins
Elliot Jenkins 2023년 4월 17일
댓글: Star Strider 2023년 4월 17일
Hi,
I simply want to label the x axis of my histogram so every value is labelled. For example, the x tick labels are showing 2,4,6,8 etc automatically. I want it to do 1,2,3,4 etc. Here is the short code:
subplot(2,3,2)
a2= T2(:,8);
b2=table2array(a2);
histogram(b2, 'Facecolor', "k");
title('1980s');
xlabel('Frequency of drought');
ylabel('Number of sites');
j=gca
j.FontName='Times New Roman';
ylim ([0 50]);

채택된 답변

Star Strider
Star Strider 2023년 4월 17일
There are several ways to do this.
Using xticks should work in R2022b
T2 = array2table(rand(100,10)*10); % Create Data
subplot(2,3,2)
a2= T2(:,8);
b2=table2array(a2);
histogram(b2, 'Facecolor', "k");
title('1980s');
xlabel('Frequency of drought');
ylabel('Number of sites');
j=gca
j =
Axes (1980s) with properties: XLim: [-0.5000 10.5000] YLim: [0 30] XScale: 'linear' YScale: 'linear' GridLineStyle: '-' Position: [0.4108 0.5838 0.2134 0.3412] Units: 'normalized' Show all properties
j.FontName='Times New Roman';
ylim ([0 50]);
xticks(1:10)
.
  댓글 수: 2
Elliot Jenkins
Elliot Jenkins 2023년 4월 17일
Brilliant, thanks so much
Star Strider
Star Strider 2023년 4월 17일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by