Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Looking at the Options for MatrixPlot, there doesn't seem to be a mechanism for lowerbound threshold - i.e. ignoring values that fall below a certain cutoff.

If my data set is very large, and I need a fast method of accomplishing this, would anyone have a recommendation?

share|improve this question
2  
is a rule too slow? mp = RandomReal[{-1, 1}, {40, 60}]; and MatrixPlot[mp /. a_ /; (a < .4) -> Null] –  gpap Jul 10 '13 at 12:14
2  
I'd use Chop. –  rcollyer Jul 10 '13 at 12:20
add comment

3 Answers

up vote 2 down vote accepted

To long for comment. Idea different than gpap's and rcollyer's:

n = 300;
s = SparseArray[{{1, 1} -> 5, {2, 2} -> 5, {3, 3} -> 5, {n, n} -> 5}] 
    + Table[RandomReal[], {n}, {n}];

SparseArray[
    Thread[Rule[#, s[[ ##]] & @@@ #]] &@Position[s, x_ /; x > 1, 2]
    ] // ArrayPlot 

Edit: Faster than ReplaceAll. Slower than Chop but I think this is more flexible.

share|improve this answer
1  
@J.M. Please, do not accept so quickly :) –  Kuba Jul 10 '13 at 12:40
    
However, it's a good answer! –  J.M. Jul 10 '13 at 14:12
    
FYI: Table[RandomReal[], {n}, {n}] would be better written RandomReal[1, {n, n}] –  Mr.Wizard Jul 10 '13 at 16:56
    
@Mr.Wizard Indeed, thanks. –  Kuba Jul 10 '13 at 17:23
add comment

I don't really see how Chop is (directly) applicable unless "minimum value" means absolute value, and replacement via patterns is always going to be slower than pure numerics. I think the flexible and fast function is Clip:

Clip[x, {min,max}, {vmin,vmax}] gives vmin for x < min and vmax for x > max.

Borrowing Bill's example:

m = RandomReal[{-1, 1}, {6, 6}];
Manipulate[MatrixPlot[Clip[m, {i, ∞}, {0, 0}]], {i, -1, 1}]

enter image description here

share|improve this answer
add comment

Move the slider to change the threshold value

m = RandomReal[{-1, 1}, {6, 6}]; 
Manipulate[MatrixPlot[Chop[m, i]], {i, 0, 1}]

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.