MATLAB Answers

Dzerald
0

Histogram x axis tick labels – string

Asked by Dzerald
on 12 Apr 2019
Latest activity Commented on by Dzerald
on 12 Apr 2019
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

  0 Comments

Sign in to comment.

3 Answers

Answer by David Wilson on 12 Apr 2019
 Accepted Answer

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

  2 Comments

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

Sign in to comment.


Answer by David Wilson on 12 Apr 2019

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 Comment

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

Sign in to comment.


Answer by David Wilson on 12 Apr 2019

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

  1 Comment

It's 2015b.. Is there any way to do it on this version?

Sign in to comment.