YTickLabel does not align YTick, specifically in large heatmap.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1345844/image.bmp)
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1345849/image.png)
0 commentaires
Réponses (1)
Samyuktha
le 5 Avr 2023
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!!
Voir également
Catégories
En savoir plus sur Data Distribution Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!