# Show entire matrix

**URL:** <https://discourse.julialang.org/t/show-entire-matrix/1437>\
**Category:** General Usage\
**Created:** [January 12, 2017, 2:34pm UTC](https://discourse.julialang.org/t/show-entire-matrix/1437 "2017-01-12T14:34:47Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![cstjean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cstjean/32/1444_2.png) [@cstjean](https://discourse.julialang.org/u/cstjean)\
**Post date:** [January 12, 2017, 2:34pm UTC](https://discourse.julialang.org/t/show-entire-matrix/1437/1 "2017-01-12T14:34:47Z")

</div>

I have some narrow but long matrix (dataframe-like), and I’d like it to be displayed entirely in IJulia (or in the REPL). `display(m)` cuts it in the middle and shows only ~25 rows. `show` and `print` show everything, but the rows are not aligned. Is there any way to nicely display the whole matrix in tabular format?

---

<div class="post-metadata">

**Author:** ![cstjean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cstjean/32/1444_2.png) [@cstjean](https://discourse.julialang.org/u/cstjean)\
**Post date:** [January 12, 2017, 3:18pm UTC](https://discourse.julialang.org/t/show-entire-matrix/1437/2 "2017-01-12T15:18:37Z")

</div>

`display("text/plain", rand(40, 5))` works. I’m not sure why “text/csv” isn’t supported - its error message is also very uninformative.

---

<div class="post-metadata">

**Author:** ![goretkin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goretkin/32/167_2.png) [@goretkin](https://discourse.julialang.org/u/goretkin)\
**Post date:** [November 19, 2019, 8:31pm UTC](https://discourse.julialang.org/t/show-entire-matrix/1437/3 "2019-11-19T20:31:46Z")

</div>

It seems like `display` on `MIME"text/plain"` defaults to `limit=>false` at least on Julia 1.2, so the current answer no longer works.

If there’s a better shorthand, let me know. But since this comes up on web searches still, I’ll revive the thread to show how to print the whole array:

`show(IOContext(stdout, :limit=>false), MIME"text/plain"(), rand(40, 5))`

---

<div class="post-metadata">

**Author:** ![ElectronicTeaCup](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/electronicteacup/32/12647_2.png) [@ElectronicTeaCup](https://discourse.julialang.org/u/ElectronicTeaCup)\
**Post date:** [November 19, 2019, 8:39pm UTC](https://discourse.julialang.org/t/show-entire-matrix/1437/4 "2019-11-19T20:39:14Z")

</div>

[This](https://github.com/JuliaComputing/TableView.jl) is also pretty cool.

---

<div class="post-metadata">

**Author:** ![bocc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bocc/32/7546_2.png) [@bocc](https://discourse.julialang.org/u/bocc)\
**Post date:** [April 30, 2020, 9:11am UTC](https://discourse.julialang.org/t/show-entire-matrix/1437/5 "2020-04-30T09:11:34Z")

</div>

It would be nice to have a macro with this included (`@showfull` or something).

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [April 30, 2020, 9:48am UTC](https://discourse.julialang.org/t/show-entire-matrix/1437/6 "2020-04-30T09:48:18Z")

</div>

I agree that easier access to something like this would be nice to have.

@bocc: Would you mind suggesting this in an issue / implementing this in a PR over on GitHub, [JuliaLang/julia](https://github.com/JuliaLang/julia)?

---

<div class="post-metadata">

**Author:** ![Paul\_Soderlind](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_soderlind/32/1753_2.png) [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)\
**Post date:** [April 30, 2020, 9:59am UTC](https://discourse.julialang.org/t/show-entire-matrix/1437/7 "2020-04-30T09:59:30Z")

</div>

A bit formatting (how many digits?) would also be useful. I have since long used my own (clumsy) `printmat()` function (available at [my github page](https://github.com/PaulSoderlind/JuliaTutorial)), but you are probably better off with  
`pretty_table(data, tf = borderless, noheader = true)`  
from [PrettyTables.jl](https://github.com/ronisbr/PrettyTables.jl)

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [April 30, 2020, 11:56am UTC](https://discourse.julialang.org/t/show-entire-matrix/1437/8 "2020-04-30T11:56:11Z")

</div>

`show(stdout, "text/plain", matrix)` should work and is pretty short. (No need to set an `IOContext` or create a `MIME` argument.)

---

<div class="post-metadata">

**Author:** ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Post date:** [May 1, 2020, 1:16am UTC](https://discourse.julialang.org/t/show-entire-matrix/1437/9 "2020-05-01T01:16:07Z")

</div>

If you want to use PrettyTables.jl to have more “freedom” then default Julia printing system, as @Paul_Soderlind mentioned, add the option `crop = :none` to avoid cropping or `crop = :horizontal` to only crop horizontally.

Furthermore, you can select how many digits will be printed using a formatter:

```nohighlight
julia> m = rand(5,3);

julia> pretty_table(m, tf = borderless, noheader = true, crop = :horizontal, formatters = ft_round(3))
  0.888 0.544 0.776
  0.886 0.364 0.562
  0.745 0.367 0.393
  0.341 0.748 0.282
  0.702 0.62 0.206

```

Or, you can use the formatter `ft_printf` to format your numbers anyway you like:

```julia
julia> pretty_table(m, tf = borderless, noheader = true, crop = :horizontal, formatters = ft_printf("%3.1e"))
  8.9e-01 5.4e-01 7.8e-01
  8.9e-01 3.6e-01 5.6e-01
  7.4e-01 3.7e-01 3.9e-01
  3.4e-01 7.5e-01 2.8e-01
  7.0e-01 6.2e-01 2.1e-01

```

If you want to always use the same configuration and do not want to type a lot, then the macros `@ptconf` and `@pt` can help you. The former add configurations to a stack. The latter call `pretty_table` with such configuration:

```nohighlight
julia> @ptconf tf = borderless noheader = true crop = :horizontal formatters = ft_printf("%3.2f")

julia> @pt m
  0.89 0.54 0.78
  0.89 0.36 0.56
  0.74 0.37 0.39
  0.34 0.75 0.28
  0.70 0.62 0.21

julia> @pt rand(4,4)
  0.66 0.91 0.37 0.77
  0.16 0.40 0.37 0.99
  0.58 0.04 0.87 0.86
  0.65 0.13 0.48 0.93

julia> @pt rand(5,5)
  0.67 0.50 0.72 0.33 0.32
  0.59 0.19 0.68 0.57 0.85
  0.21 0.75 0.08 0.35 0.01
  0.46 0.03 0.32 0.56 0.72
  0.73 0.92 0.25 0.97 0.12

```
