How to increase decimal places in corrplot function?
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Dyuman Joshi
le 26 Sep 2023
Modifié(e) : Dyuman Joshi
le 26 Sep 2023
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 commentaires
Voir également
Catégories
En savoir plus sur 2-D and 3-D 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!