我正在尝试将xticklabels(单元格数组)设置为粗体。大多数先前的命令不起作用。
h=figure(1);
gca.XAxis.TickLabel='\bf{%g}' % xticklabel is preassigned in box plot as text from cell array {'AB','CD','EF','GH'}.
上面命令中的某些修改会产生错误,例如-“使用set时出错,无法从struct转换为double。”请建议进行修改,如果可能的话,建议使用相同的默认属性设置器。
以下将使XTickLabels
为粗体:
fig = figure(1);
ax = axes; % or: ax = gca;
plot(rand(10));
ax.XTickLabel = cellfun(@(a) ['\bf{' a '}'], ax.XTickLabel, 'UniformOutput',false);
您无法使用与gca
相同的方式来使用ax
,因为gca
是将返回当前轴的函数,并且无法对函数进行点索引。
如果要使用set
(和get
),可以按以下步骤进行,
currentLabels = get(gca, 'XTickLabel');
set(gca, 'XTickLabel', cellfun(@(a) ['\bf{' a '}'], currentLabels, 'UniformOutput',false));