Histogram x axis tick labels – string

Hi,
I've done a simple histogram in Matlab and now I want to change the last tick on x axis. Instead of the "3" number I want string "Others".
How can I do it? I'm at R2015b.
The histogram was done by histogram() function.
hist.jpg

 采纳的回答

Try
>> get(gca,'XTicklabel')
and hack that.

2 个评论

Please don’t keep adding answers , use comment on this answer.
This is working, thanks a lot!

请先登录,再进行评论。

更多回答(2 个)

Hack the final xticklabel
x = randn(1e5,1); x= x-min(x)+1;
histogram(log(x))
xlim([0,3])
xt = xticklabels;
xt{end} = 'other'
xticklabels(xt)

1 个评论

Unfortunately, this isn't working – error ''Undefined function or variable 'xticklabels'."

请先登录,再进行评论。

Released 2016b. What's your version?
>> which xticklabels
C:\Program Files\MATLAB\R2018b\toolbox\matlab\graph3d\xticklabels.m

类别

帮助中心File Exchange 中查找有关 Annotations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by