How to make xtick where there is a tick label in bold?
72 views (last 30 days)
Show older comments
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1048015/image.jpeg)
How can I do this?
Thank you
0 Comments
Answers (1)
Walter Roberson
on 28 Jun 2022
xticklabels({'','','\bf 1980','','','','','\bf 1985',...
'','','','','\bf 1990','','','','','\bf 1995','','','','','\bf 2000',...
'','','','','\bf 2005','','','','','\bf 2010','','','','','\bf 2015',...
'','','','','\bf 2020',''.''})
3 Comments
Walter Roberson
on 28 Jun 2022
Edited: Walter Roberson
on 28 Jun 2022
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
See Also
Categories
Find more on Axis Labels in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!