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

55 Ansichten (letzte 30 Tage)
A LL
A LL am 28 Jun. 2022
Bearbeitet: Walter Roberson am 28 Jun. 2022
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

Antworten (1)

Walter Roberson
Walter Roberson am 28 Jun. 2022
xticklabels({'','','\bf 1980','','','','','\bf 1985',...
'','','','','\bf 1990','','','','','\bf 1995','','','','','\bf 2000',...
'','','','','\bf 2005','','','','','\bf 2010','','','','','\bf 2015',...
'','','','','\bf 2020',''.''})
  3 Kommentare
A LL
A LL am 28 Jun. 2022
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 am 28 Jun. 2022
Bearbeitet: Walter Roberson am 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

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by