フィルターのクリア

how to add lines to histograms plotted by plotmatrix

1 回表示 (過去 30 日間)
Etsuko
Etsuko 2018 年 12 月 4 日
コメント済み: Etsuko 2018 年 12 月 5 日
Hi,
I want to add vertical lines to histograms plotted in the diagonal of a matrix of pair-wise scatter plots. I tried to use the graphic objects returned by plotmatrix;
[S,AX,BigAx,H,HAx] = plotmatrix(X); % X has 15 columns
for example,
subplot(15,15,1); hold on; line([1.2,1.2],get(AX(1),'YLim'),'Color','r')
AX(15); plot([1.2,1.2],[0,1.5],'Color','r')
etc. But so far none has worked out. I would appreciate any clue as I am clueless.
I use Matlab 2018a. Thanks.

採用された回答

Akira Agata
Akira Agata 2018 年 12 月 4 日
How about the following?
% Sample data
X = rand(50,3);
figure
[~,ax] = plotmatrix(X);
hold(ax(1,3),'on')
plot(ax(1,3),[0.2 0.2],ax(1,3).YLim,'r:','LineWidth',2)
hold(ax(2,1),'on')
plot(ax(2,1),[0.5 0.5],ax(2,1).YLim,'r','LineWidth',2)
Just FYI:
If you can upgrade your MATLAB to R2018b, you can do the same thing slightly easier by using newly introduced xline function, like:
figure
[~,ax] = plotmatrix(X);
xline(ax(1,3),0.2,'r:','LineWidth',2)
xline(ax(2,1),0.5,'r','LineWidth',2)
plotmatrix.png
  1 件のコメント
Etsuko
Etsuko 2018 年 12 月 5 日
Thank you very much!
It needed to specify the axis of the histograms. Just an easy modification of your suggestion did what I wanted. Thank you!
[S,AX,BigAx,H,HAx] = plotmatrix(X); % X has 15 columns
hold(HAx(1,1),'on')
plot(HAx(1,1),[2.2 2.2],HAx(1,1).YLim,'r:','LineWidth',2)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by