millejoh / emacs-ipython-notebook

Jupyter notebook client in Emacs
http://millejoh.github.io/emacs-ipython-notebook/
GNU General Public License v3.0
1.47k stars 122 forks source link

Modify default output width in notebook buffer #610

Closed vale46 closed 5 years ago

vale46 commented 5 years ago

The width for displayed output in a notebook buffer is set to 80 characters. How do I override/customize this default to display wider text/tables without the forced line break and wrapping?

Setting ein:truncate-lines-on impacts only the input lines in a notebook buffer.

Running Emacs 26.1 on W10 box.

millejoh commented 5 years ago

I will need to see the code that is triggering this behavior on your system as I am not seeing this on my setup.

s = '.'*120
print(s)

Results in a single line of output of 120 .'s long. For the most part, printing cell output devolves into calls to insert without any fill-text-like calls. Multiple lines of output can be truncated via the variable ein:truncate-long-cell-output, but this code also does not do any text filling.

On the Python side there is the config variable PlainTextFormatter.max_width. You might play with that and see if it results in different output.

vale46 commented 5 years ago

Tried your suggestion, which prints the width of the emacs frame and wraps if needed.

As you mentioned, my issue is likely in IPython setup, because it happens when I print a pandas dataframe which is more than 80 characters wide, causing last 2 columns to wrap. Here's an example

import pandas as pd
mpg = pd.read_html("https://alliance.seas.upenn.edu/~cis520/wiki/index.php?n=Lectures.DecisionTrees", header=0)[0]
print(mpg)

Also, adjusting

%config PlainTextFormatter.max_width = 150

doesn't widen the output format.

vale46 commented 5 years ago

Setting pandas.set_option('expand_frame_repr', False) fixes the dataframe output wrapping. Thanks for your tips in helping get to my solution.