Is this intended behavior?
When using histogram to plot the count of categories in a categorical array, the data tips for the bars whose values are above 10000 are rounded to the 10s digit (e.g. 10005 is rounded to 10010). This undocumented behavior gives the impression that extra data are included or data are missing.
cats = categorical();
for count = 9985:10:10015
cats = [cats; repmat(categorical(count), count, 1)];
end
h = histogram(cats, 'DisplayOrder', 'descend')
I've checked that the source of data for the data tip contains the correct values. To correct the data tips, I need to change the data tip template format from 'auto' to '%i' using h.DataTipTemplate.DataTipRows(1).Format = '%i'.
It seems like this behavior (auto format rounding data tips to the nearest 10s above 10000) is either a bug or an undocumented feature. Is this intended behavior?
Using: MATLAB Version: 9.8.0.1417392 (R2020a) Update 4

댓글 수: 5

Adam Danz
Adam Danz 2020년 7월 30일
편집: Adam Danz 2020년 7월 30일
[Edited to remove a mistake]
I'm not seeing what you are describing. The datatips below show the true x values of 10015 and 10005.
Steven
Steven 2020년 7월 30일
편집: Steven 2020년 7월 30일
Thank you for your reply, Adam.
The correct values in your data tips correspond to the labels I've given to the categories (x axis). The values in your plot (1.002e+4) should exactly match the category label. What's weird is that I was able to edit the data tip template, don't know what's going on there.
Before
After
Adam Danz
Adam Danz 2020년 7월 30일
편집: Adam Danz 2020년 7월 30일
Opps, I forgot I was temporarily using r2019b.
Switching over to r2020a, you're right that DataTip format changes are supported with histograms. But I'm still not seeing what you're seeing.
I've updated my previous comment with a new screenshot so readers aren't confused by the mistake I removed.
Steven
Steven 2020년 7월 30일
Good call on the edit, I appreciate your help.
Two of my teammates were able to reproduce the behavior on their machines. Maybe there's something weird going on with all of our environments but that seems unlikely. Here's everything I've got.
-----------------------------------------------------------------------------------------------------
MATLAB Version: 9.8.0.1417392 (R2020a) Update 4
MATLAB License Number: REDACTED
Operating System: Microsoft Windows 10 Enterprise Version 10.0 (Build 16299)
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
-----------------------------------------------------------------------------------------------------
MATLAB Version 9.8 (R2020a)
Database Toolbox Version 9.2.1 (R2020a)
Deep Learning Toolbox Version 14.0 (R2020a)
Parallel Computing Toolbox Version 7.2 (R2020a)
Signal Processing Toolbox Version 8.4 (R2020a)
Statistics and Machine Learning Toolbox Version 11.7 (R2020a)
Adam Danz
Adam Danz 2020년 7월 30일
편집: Adam Danz 2020년 7월 30일
The screenshot I shared was from Matlab Online.
_______________________________
MATLAB Version: 9.8.0.1417392 (R2020a) Update 4
MATLAB License Number:
Operating System: Linux 4.14.177-0414177-generic #202004250428 SMP Sat Apr 25 04:31:46 UTC 2020 x86_64
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
_______________________________
We're using the same version but different operating systems.

댓글을 달려면 로그인하십시오.

 채택된 답변

Cris LaPierre
Cris LaPierre 2020년 7월 30일

0 개 추천

Recently reported here as well. Feedback has been given internally about the current behavior.

댓글 수: 4

Adam Danz
Adam Danz 2020년 7월 30일
Thanks Cris. The problem doesn't seem to exist with Matlab Online (Linux) which makes me wonder if the problem depends on the OS.
Cris LaPierre
Cris LaPierre 2020년 7월 30일
편집: Cris LaPierre 2020년 7월 31일
Thanks for pointing that out. When I checked, MATLAB Online rounded 10015 up to 10020, but 10005 down to 10000 instead of up to 10010. I'll pass that along.
Adam Danz
Adam Danz 2020년 7월 31일
Well, that's weird. I just checked again, using Matlab online, and got the same result you described. Yet, my screen shot from 7 hours ago showed a successful result with the same code and OS.
Steven
Steven 2020년 7월 31일
Thank you both for your responses. Hope it gets patched!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

제품

릴리스

R2020a

질문:

2020년 7월 30일

댓글:

2020년 7월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by