How to increase decimal places in corrplot function?
7 ビュー (過去 30 日間)
古いコメントを表示
I have this code data = [ x y z]; % here original dataswere added
% Calculate the correlation matrix
corrMatrix = corr(data)
% Create a correlation plot
corrplot(corrMatrix,'type', 'Pearson','testR', 'on', 'varNames', {'TO', 'AN', 'TC%', 'TN%', 'C/N', 'F', 'M', 'Temp°C'});
and I got this graph but i want to increase the decimal places of the r2 values in the graph as it is showing the rounded off values. How can i change the code to do so.![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1493277/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1493277/image.png)
0 件のコメント
回答 (1 件)
Dyuman Joshi
2023 年 9 月 26 日
編集済み: Dyuman Joshi
2023 年 9 月 26 日
load Data_Canada
[R,~,H] = corrplot(Data)
Here, H is the handle to the plotted graphics objects.
s = size(H);
%Indices of the elements of H to be modified
idx = find(~eye(s));
%Get the parent object of H
ax = get(H,'parent');
%Get the children of parent of H
ch = reshape(get([ax{:}],'Children'),s)
%Let's check the corresponding graphics
ch{2}
ch{2}(1)
The 'String' property of the 'Text' objects are the one you want to change.
for k=1:numel(idx)
%Change the text values to numbers in text form with 4 digits after decimal
set(ch{idx(k)}(1),'String',sprintf('%0.4f',R(idx(k))));
%Changing the font size
set(ch{idx(k)}(1),'FontSize',8)
end
2 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!