0
$\begingroup$

My output is a matrix. I want to save this matrix as a picture whose format is eps or png. How can I convert it? Thank you.

$\endgroup$
3
  • 1
    $\begingroup$ Try using ArrayPlot or MatixPlot to visualize it (you will need to consider your choice or color map), then use Export to export the image to either eps or png, your choice! $\endgroup$ Commented Dec 14, 2015 at 19:30
  • 1
    $\begingroup$ via GUI, right click the bar at the far right of the expression and choose Save Selection As $\endgroup$
    – george2079
    Commented Dec 14, 2015 at 19:32
  • $\begingroup$ thank you for your responce. These explanations are enough for me. $\endgroup$
    – MATIRMAK
    Commented Dec 14, 2015 at 19:36

2 Answers 2

3
$\begingroup$

The simplest way is to use Export

m = RandomInteger[{0, 9}, {8, 10}];
Export["mat.png", MatrixForm[m]]

enter image description here

If you want to make it good looking, you can use Style. Following the suggestions of Verbeia and Edmund, you can do either

m2 = Map[Style[ToString[#], 16, Bold, FontFamily -> Times, Blue] &, m, {2}]//MatrixForm
Export["mat.png", MatrixForm[m2]]

enter image description here

or

m2 = Style[MatrixForm@m, 16, Bold, FontFamily -> Times, Blue]
Export["mat.png", MatrixForm[m2]]

enter image description here

Notice that in first case (Verbia) the style is attributed only on the text part, whereas in second case (Edmund) the style is attributed over the whole form.

$\endgroup$
3
  • 1
    $\begingroup$ Map takes a third argument to specify the level. Map[yourfunction, yourmatrix, {2}] will work. This is the fifth in the list of "Basic examples" in the documentation. $\endgroup$
    – Verbeia
    Commented Dec 14, 2015 at 21:39
  • 1
    $\begingroup$ You can also just style it all without map. Style[MatrixForm@m, 16, Bold, FontFamily -> Times, Blue] $\endgroup$
    – Edmund
    Commented Dec 14, 2015 at 22:34
  • $\begingroup$ Thanks @Verbeia. I was missing the {} for the argument before. $\endgroup$
    – Sumit
    Commented Dec 15, 2015 at 9:27
0
$\begingroup$

Try using ArrayPlot or MatrixPlot to visualize it (you will need to consider your choice or color map), then use Export to export the image to either eps or png, your choice! (Quantum_Oli)

Via GUI, right click the bar at the far right of the expression and choose Save Selection As (george2079)

Or use Rasterize to rasterize your expression, and Export to export it.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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