How to make xtick where there is a tick label in bold?

조회 수: 71 (최근 30일)
A LL
A LL 2022년 6월 28일
편집: Walter Roberson 2022년 6월 28일
How to make the xtick mark where I have a label in bold (as shown in attached figure).
Here is the code I use to generate the figure:
years = [1979:1:2021];
figure(1);
hold on;
axis on;
grid on;
box on;
plot(years,TS_Mask,'LineWidth',3,'Color','black')
yline(M,'-k','LineWidth',2); %yline(M,'-k','mean');
yline(M+S,'--k','LineWidth',2); %yline(M+S,'--k','mean + 1*std');
yline(M-S,'--k','LineWidth',2); %yline(M-S,'--k','mean - 1*std');
p1=plot(positiveAnomaly,TS_Mask(find(TS_Mask >= M+S)),'^');
p1.MarkerSize = 12;
p1.MarkerFaceColor = 'black';
p1.MarkerEdgeColor = 'black';
p2=plot(negativeAnomaly,TS_Mask(find(TS_Mask <= M-S)),'v');
p2.MarkerSize = 12;
p2.MarkerFaceColor = 'black';
p2.MarkerEdgeColor = 'black';
p2007 = plot(2007,TS_Mask(29),'o','MarkerFaceColor','black','MarkerEdgeColor','black','MarkerSize',12);
p2012 = plot(2012,TS_Mask(34),'o','MarkerFaceColor','black','MarkerEdgeColor','black','MarkerSize',12);
xlabel('years','FontSize',24)
ylabel('SLP [hPa]','FontSize',24)
set(gca,'Fontsize',18);
xticks([1978:1:2022]);
xticklabels({'','','1980','','','','','1985',...
'','','','','1990','','','','','1995','','','','','2000',...
'','','','','2005','','','','','2010','','','','','2015',...
'','','','','2020',''.''})
xtickangle(0);
xlim([1978 2022]);
gcf;
I want to add bold tick mark in x where I have the x tick labels i.e. 1980, 1985, 1990, etc.
How can I do this?
Thank you

답변 (1개)

Walter Roberson
Walter Roberson 2022년 6월 28일
xticklabels({'','','\bf 1980','','','','','\bf 1985',...
'','','','','\bf 1990','','','','','\bf 1995','','','','','\bf 2000',...
'','','','','\bf 2005','','','','','\bf 2010','','','','','\bf 2015',...
'','','','','\bf 2020',''.''})
  댓글 수: 3
A LL
A LL 2022년 6월 28일
Thank you for your answer. I am not looking to put the xticklabels in bold but rather to have the xticksmark where I have labels be bold/ thicker than the other ticks for better vizualisation. Do you know how to do this? Thank you
Walter Roberson
Walter Roberson 2022년 6월 28일
편집: Walter Roberson 2022년 6월 28일
Do not xticks all the values. xticks the ones you want in bold, and set the minorticks to take care of everything else
https://www.mathworks.com/matlabcentral/answers/97759-how-do-i-add-minor-ticks-to-a-graph?s_tid=ta_ans_results

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

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by