How to make xtick where there is a tick label in bold?
Mostrar comentarios más antiguos
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
Respuestas (1)
Walter Roberson
el 28 de Jun. de 2022
xticklabels({'','','\bf 1980','','','','','\bf 1985',...
'','','','','\bf 1990','','','','','\bf 1995','','','','','\bf 2000',...
'','','','','\bf 2005','','','','','\bf 2010','','','','','\bf 2015',...
'','','','','\bf 2020',''.''})
3 comentarios
Walter Roberson
el 28 de Jun. de 2022
I would take a different approach, of setting xticks every 5, and setting MinorTicks every 1, and not specifying the tick labels. Instead, set
ax = gca; ax.xAxis.TickLabelFormat = '\bf %d';
A LL
el 28 de Jun. de 2022
Walter Roberson
el 28 de Jun. de 2022
Editada: Walter Roberson
el 28 de Jun. de 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
Categorías
Más información sobre Axis Labels en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!