MATLAB: Can I Specify Label Labels as Text Objects?
I am curious if it is possible to change the text properties of the labels of the labels independently of the properties of the axes. Do they have pens? I would like to have better control over their position, alignment, color, fonts, etc. I know I can replace them with text labels, but it has some drawbacks. Any alternative solutions?
In particular, is it possible to put xticklabels between ticks that are irregular?
plot(1:100)
set(gca,'xtick',[30 45 53 70 95])
grid on
I need to place the xticklabels in the middle between the grids.
+2
a source to share
1 answer
To put the xicklabels between ticks, I'll draw a second set of axes on top of the first. LINKZOOM from File Sharing makes sure you don't have any scaling issues.
plot(1:100),
ah=gca;
%# make arbitrary ticks
set(ah,'xtick',[30 45 53 70 95],'xticklabels',[])
%# create new axes with labels placed in the middle
ah2=axes('parent',gcf,'position',get(ah,'Position'),'color','none',...
'ticklength',[0,0],'xtick',([45 53 70 95]+[30 45 53 70])/2,'xlim',[0,100],'ylim',[0,100])
%# link all axes in the figure
linkzoom;
+2
a source to share