I want to add a text in each of my plot of the PlotMatrix
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello, In Figure that I attached I got a PlotMatrix, and I would like to add a text in each of the different plots, and the text that i want to add it is a number that is in a matrix
R = [1 1.5 3.7; -0.564 1 5.6; 0.101 0.105 1] so in plot(1,1) i want to add R(1,1), in plot (1,2) i want to add R(1,2), etc
This is what i got
X = randn(50,3);
[R,P] = corrcoef(X)
[~,ax] = plotmatrix(X);
ax(1,1).YLabel.String = 'X1';
ax(2,1).YLabel.String = 'X2';
ax(3,1).YLabel.String = 'X3';
ax(3,1).XLabel.String = 'X1';
ax(3,2).XLabel.String = 'X2';
ax(3,3).XLabel.String = 'X3';
Thanks for your time
0 Commenti
Risposte (1)
lokender Rawat
il 5 Apr 2018
Since you want the values of R(3x3) matrix row-wise to be displayed on the plot in a column-wise fashion. You need to keep track of the 'chart line' objects(represented by S) and 'histogram' objects(represented by H).
The below code does your job, maximize the output figure to see the desired result:
X = randn(50,3);
[R,P] = corrcoef(X)
[S,ax,BigAx,H,HAx]=plotmatrix(X);
ax(1,1).YLabel.String = 'X1';
ax(2,1).YLabel.String = 'X2';
ax(3,1).YLabel.String = 'X3';
ax(3,1).XLabel.String = 'X1';
ax(3,2).XLabel.String = 'X2';
ax(3,3).XLabel.String = 'X3';
[r,c]=size(R)
k=1;
for j=1:c
for i=1:r
if(i==j)
H(i).DisplayName=num2str(R(i,j));
legend(H(i),'Location','northwest')
else
S(k).DisplayName=num2str(R(i,j))
legend(S(k),'Location','northwest')
end
k=k+1;
end
end
Read more on plotmatrix command from the following link and how you can use 'S' and 'H':
>>[S,AX,BigAx,H,HAx] = plotmatrix(___)
Once you have the S and H objects from the plotmatrix, then you can set the display text for each plot. You can read more on Scatter properties from the below link:
Use 'legend' function to align the text to your plot and other features. Read more on 'legend' command:
Vedere anche
Categorie
Scopri di più su Annotations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!