Hi, I want to include the correlation coefficient on each of the subplots of GPLOTMATRIX.

2 ビュー (過去 30 日間)
My problem is how do I put some text on to the subplots.
This is one of my unsuccessful attempts -
X = randn(200,3);
r = corrcoef(X);
return
[H,AX,BigAx] = gplotmatrix(X,[],[],[0.5 0.5 1],[],1,'off','none');
set(AX(1,2));
plot(AX(1,2),[0],[0],'xk');
text(.1,.9,['r = ',num2str(r(1,2),2)],'units','norm');
thanks..

採用された回答

Geoff Hayes
Geoff Hayes 2016 年 1 月 17 日
Warwick - I don't have the Statistics and Machine Learning Toolbox (so can't validate the following), but in your code you do
[H,AX,BigAx] = gplotmatrix(X,[],[],[0.5 0.5 1],[],1,'off','none');
where AX is an array of handles to all of the axes. The subsequent line of code
set(AX(1,2));
seems incomplete. What are you trying to set for this axes? Perhaps you intend to set AX(1,2) as the current axes so that the text is written to it. Try using axes instead as
axes(AX(1,2));
% now draw and write the text
plot(AX(1,2),[0],[0],'xk');
text(.1,.9,['r = ',num2str(r(1,2),2)],'units','norm');
  2 件のコメント
Warwick
Warwick 2016 年 1 月 18 日
編集済み: Geoff Hayes 2016 年 1 月 18 日
Thanks so much, Geoff. With that suggestion I was able to get a very satisfactory result. This is the code snippet that I'm using now - in case it helps anyone else.
X = randn(100,3);
r = corrcoef(X);
[H,AX,BigAx] = gplotmatrix(X,[],[],[0.5 0.5 1],[],1,'off','none');
for row = 1:3
for col = 1:3
if row == col; continue; end
axes(AX(row,col));
hold on
text(.1,.9,['r = ',num2str(r(row,col),2)],'units','norm');
end
end
return
Geoff Hayes
Geoff Hayes 2016 年 1 月 18 日
Glad it worked out, Warwick!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by