필터 지우기
필터 지우기

YTickLabel does not align YTick, specifically in large heatmap.

조회 수: 1 (최근 30일)
Yihang Xu
Yihang Xu 2023년 4월 5일
댓글: Yihang Xu 2023년 4월 5일
feature_names = {
'cbo', 'cboModified', 'fanin', 'fanout', ...
'wmc', 'dit', 'noc', 'rfc', 'lcom', 'lcom*', 'tcc', ...
'lcc', 'totalMethodsQty', 'staticMethodsQty', 'publicMethodsQty', ...
'privateMethodsQty', 'protectedMethodsQty', 'defaultMethodsQty', ...
'visibleMethodsQty', 'abstractMethodsQty', 'finalMethodsQty', ...
'synchronizedMethodsQty', 'totalFieldsQty', 'staticFieldsQty', ...
'publicFieldsQty', 'privateFieldsQty', 'protectedFieldsQty', ...
'defaultFieldsQty', 'finalFieldsQty', 'synchronizedFieldsQty', ...
'nosi', 'loc', 'returnQty', 'loopQty', 'comparisonsQty', ...
'tryCatchQty', 'parenthesizedExpsQty', 'stringLiteralsQty', ...
'numbersQty', 'assignmentsQty', 'mathOperationsQty', ...
'variablesQty', 'maxNestedBlocksQty', 'anonymousClassesQty', ...
'innerClassesQty', 'lambdasQty', 'uniqueWordsQty', ...
'modifiers', 'logStatementsQty' ...
};
data = [0.41,0.41,0.27,0,0.29,0.18,0.05,0.37,0.30,0.29,0,0,0.12,0.04,0.17,0.25,0.03,0.01,0.07,0,0.01,0,0.18,0.05,0.14,0.02,0.02,0.03,0.08,0,0.33,0.84,0.26,0.08,0.12,0.05,0.09,0.18,0.23,0.20,0.12,0.22,0.11,0,0.03,0,1,0.01,0; 0.42,0.38,0.30,0,0.37,0.18,0.06,0.37,0.34,0.39,0,0,0.17,0.09,0.26,0.08,0.14,0.15,0.15,0.04,0,0.02,0.15,0.11,0.10,0.18,0.07,0.03,0.15,0,0.24,0.64,0.32,0.13,0.20,0.16,0.17,0.31,0.28,0.30,0.15,0.26,0.10,0.04,0.08,0.07,1,0.03,0.09; 0.51,0.57,0.31,0,0.41,0.21,0.060,0.58,0.47,0.49,0,0,0.24,0.15,0.36,0.21,0.15,0.17,0.27,0.06,0.04,0,0.19,0.15,0.11,0.20,0.04,0.08,0.19,0,0.40,0.88,0.42,0.22,0.33,0.15,0.15,0.57,0.46,0.41,0.28,0.43,0.23,0.11,0.15,0.26,1,0.12,0.13; 0.26,0.31,0.20,0,0.29,0.05,0.010,0.32,0.22,0.35,0,0,0.24,0.11,0.12,0.15,0.07,0.03,0.16,0,0.01,0,0.23,0.11,0.080,0.18,0,0,0.13,0,0.20,0.57,0.26,0.11,0.18,0.060,0.14,0.23,0.30,0.22,0.22,0.24,0.16,0.05,0.14,0.04,1,0.12,0;
0.33,0.19,0.14,0,0.13,0.09,0,0.58,0.16,0.17,0,0,0.14,0.05,0.12,0.05,0.06,0.02,0.09,0,0,0,0.070,0.060,0.040,0.060,0,0.04,0.02,0,0.090,0.91,0.09,0.05,0.07,0.03,0.05,0.46,0.27,0.27,0.17,0.32,0.07,0.12,0.21,0,1,0,0;
0.34,0.35,0.33,0,0.31,0.13,0.070,0.41,0.27,0.35,0,0,0.16,0.14,0.22,0.11,0.09,0.12,0.16,0.05,0.02,0,0.13,0.15,0.080,0.15,0.03,0.02,0.17,0,0.24,0.53,0.27,0.12,0.21,0.13,0.09,0.33,0.29,0.26,0.21,0.28,0.13,0.05,0.16,0.13,1,0.08,0.06; 0.30,0.44,0.22,0.28,0.27,0.25,0.06,0.42,0.29,0.29,0,0,0.18,0.15,0.23,0.15,0.12,0.13,0.17,0.04,0.11,0,0.09,0.09,0.01,0.09,0,0.03,0.15,0,0.28,0.76,0.33,0.10,0.12,0.12,0.07,0.39,0.37,0.27,0.22,0.29,0.10,0.07,0.15,0.04,1,0.14,0; 0.34,0.41,0.19,0.040,0.34,0.24,0.07,0.48,0.27,0.33,0,0,0.16,0.11,0.25,0.11,0.07,0.07,0.13,0.03,0.04,0.06,0.15,0.11,0.09,0.09,0.03,0.01,0.16,0,0.16,0.78,0.27,0.08,0.17,0.12,0.07,0.35,0.20,0.34,0.20,0.22,0.10,0.040,0.14,0.070,1,0.10,0];
h = heatmap({'A', 'B', 'C' , 'D', 'E', 'F', 'G', 'H'}, feature_names, data');
h.XLabel = 'Project';
h.YLabel = 'Metric';
h.CellLabelFormat = '%.2f';
Ytick is not perfectly aligned with yticklabel in the vertical direction. The yticklabel has a slight downward shift.
Could anyone tell me how to solve it? i have not found any settings about yticklabel alignment

답변 (1개)

Samyuktha
Samyuktha 2023년 4월 5일
Hi Yihang,
I understand that you are facing issue with Ytick not being aligned with YtickLabel.
Please note that the 'yvar' in the heatmap chart are aligned along the centre of the rows. This is in accordance with the various examples in heatmap documentation.
Hope this helps!!
  댓글 수: 2
Yihang Xu
Yihang Xu 2023년 4월 5일
When number of 'yvar' increases, 'yvar' will gradually shift downwards, causing YTickLabel not aligned with rows. The picture in heatmap documentation below also reveal the problem. 'fire' and 'wind' obviously are not aligned with the center of rows. When number of 'yvar' is large enough, the misalignment will be prominent, just like the first picture in my question.
Yihang Xu
Yihang Xu 2023년 4월 5일
I drew auxiliary lines to make the problem more apparent.

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

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by