Novice_Developer
Novice_Developer

Reputation: 1492

Clearing the diagnal plots of the plotmatrix

Consider the following matrixplot

randdata = rand(1000,3);
[~,ax] = plotmatrix(randdata)

Now for example if i want to clear the diagnol plots , I am using the following method

ClrIndx = find(eye(size(randdata,2)))

ClrIndx =

     1
     5
     9

cla(ax(ClrIndx))

but the diagnol plots arent being cleared , just to be sure i compared the axes handles

double(ax)

ans =

    0.0029    3.0029    6.0029
    1.0029    4.0029    7.0029
    2.0029    5.0029    8.0029

double(ax(ClrIndx))

ans =

    0.0029
    4.0029
    8.0029

Which confirms i have got the right axes handles but still the cla()command does not clear the diagnol plots , what am i doing wrong ?

Upvotes: 1

Views: 61

Answers (1)

Turns out that there's a lot of axes magic going on with plotmatrix. Looking at the help, it turns out that it uses multiple kinds of auxiliary invisible axes. You need to clear the last one:

[~,~,~,~,pax]=plotmatrix(randdata);
cla(pax(LinearClrIndex));

where the indices should be linear: in case of a 5x5 matrix plot, pax will be a 5-element array.

If you want to delete the axes, not just clear it, you need the second output as well:

randdata = rand(5)
[~,ax,~,~,pax]=plotmatrix(randdata);
delete(pax(2));
delete(ax(2,2));

This will leave a gaping hole full of emptiness in the (2,2) position.

Upvotes: 2

Related Questions