# printing a matrix in jupyter

**URL:** https://discourse.julialang.org/t/printing-a-matrix-in-jupyter/12158
**Category:** New to Julia
**Tags:** jupyter
**Created:** [July 4, 2018, 12:23pm UTC](https://discourse.julialang.org/t/printing-a-matrix-in-jupyter/12158 "2018-07-04T12:23:15Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![abuttari](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abuttari/32/4165_2.png) [@abuttari](https://discourse.julialang.org/u/abuttari)
#### Post date: [July 4, 2018, 12:23pm UTC](https://discourse.julialang.org/t/printing-a-matrix-in-jupyter/12158/1 "2018-07-04T12:23:15Z")

</div>

Hello,  
I’m trying to visualize all the coefficients of a (relatively small) matrix, say 15x15. This works ok in the REPL since all the 15 columns fit on the screen. In a jupyter notebook, however, the width of cells is much smaller than the actual screen width and thus even for a smaller size matrix (10x10) the output is compressed and the dots appear in place of some columns. I was wondering whether there is a way to have a full printing of the matrix where (horizontal and vertical) scrollbars appear when the size of the cell is exceeded. Any ideas?

As for the REPL, is there any way to achieve a matlab-like printing of matrices, i.e., by block-columns?

Regards,  
Alfredo

---

<div class="post-metadata">

### Author: ![Evizero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evizero/32/10118_2.png) [@Evizero](https://discourse.julialang.org/u/Evizero)
#### Post date: [July 4, 2018, 12:56pm UTC](https://discourse.julialang.org/t/printing-a-matrix-in-jupyter/12158/2 "2018-07-04T12:56:58Z")

</div>

> [@abuttari](#):
>
> I was wondering whether there is a way to have a full printing of the matrix where (horizontal and vertical) scrollbars appear when the size of the cell is exceeded.

try:

```julia
show(STDOUT, MIME"text/plain"(), rand(30,10))

```

or for more control:

```julia
show(IOContext(STDOUT, limit=true, displaysize=(50,150)), MIME"text/plain"(), rand(30,10))

```

---

<div class="post-metadata">

### Author: ![abuttari](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abuttari/32/4165_2.png) [@abuttari](https://discourse.julialang.org/u/abuttari)
#### Post date: [July 4, 2018, 1:57pm UTC](https://discourse.julialang.org/t/printing-a-matrix-in-jupyter/12158/3 "2018-07-04T13:57:18Z")

</div>

Hello,  
and thanks for the quick response. With this (setting limit=false), jupyter wraps text, i.e., a line which is longer than the display (or the cell, in this case) width is split into multiple lines which makes the matrix unreadable. I would like to know if, rather than splitting the line, it is possible to have a horizontal scrollbar and thus keep the line in its entire length. BTW I have a vertical scrollbar but not a horizontal one:

 ![Screenshot%20from%202018-07-04%2015-13-05](https://global.discourse-cdn.com/julialang/original/3X/f/c/fc1abe403fb8470b675714073d26e23671616c26.png)

---

<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: [July 4, 2018, 1:57pm UTC](https://discourse.julialang.org/t/printing-a-matrix-in-jupyter/12158/4 "2018-07-04T13:57:39Z")

</div>

> [@abuttari](#):
>
> I would like to know if, rather than splitting the line, it is possible to have a horizontal scrollbar and thus keep the line in its entire length.

Yes: [Make cell output in Jupyter notebook scroll horizontally? - Stack Overflow](https://stackoverflow.com/questions/48357459/make-cell-output-in-jupyter-notebook-scroll-horizontally)

---

<div class="post-metadata">

### Author: ![abuttari](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abuttari/32/4165_2.png) [@abuttari](https://discourse.julialang.org/u/abuttari)
#### Post date: [July 4, 2018, 2:12pm UTC](https://discourse.julialang.org/t/printing-a-matrix-in-jupyter/12158/5 "2018-07-04T14:12:59Z")

</div>

stevengj,  
I actually get only vertical scrolling but not horizontal. I tried this both in my own jupyter and on JuliaBox.

---

<div class="post-metadata">

### Author: ![korsbo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/korsbo/32/15942_2.png) [@korsbo](https://discourse.julialang.org/u/korsbo)
#### Post date: [July 4, 2018, 4:11pm UTC](https://discourse.julialang.org/t/printing-a-matrix-in-jupyter/12158/6 "2018-07-04T16:11:33Z")

</div>

A quick but not very satisfying fix is to just use some package that is good at presenting your data.

```julia
using DataFrames
F = rand(15,15)
DataFrame(F)

```

or

```julia
using Latexify
F = rand(15,15)
latexify(F)

```

(this last one will be slow for large matrices)

Also, `signif.(F, 3)` is your friend.

---

<div class="post-metadata">

### Author: ![abuttari](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abuttari/32/4165_2.png) [@abuttari](https://discourse.julialang.org/u/abuttari)
#### Post date: [July 4, 2018, 7:02pm UTC](https://discourse.julialang.org/t/printing-a-matrix-in-jupyter/12158/7 "2018-07-04T19:02:19Z")

</div>

yep, “quick but not very satisfying” is the right definition 😀  
Thanks a lot though.

What is funny is that with DataFrames I have an horizontal scrollbar and I do not see any reason why this should not be possible with plain matrices. Maybe this issue should be submitted to the jupyter developers?
