printing a matrix in jupyter

jupyter

#1

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


#2

try:

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

or for more control:

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

#3

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:


#4

Yes: https://stackoverflow.com/questions/48357459/make-cell-output-in-jupyter-notebook-scroll-horizontally


#5

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


#6

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

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

or

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

(this last one will be slow for large matrices)

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


#7

yep, “quick but not very satisfying” is the right definition :grinning:
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?